From 20eadcf2f8c313638b824225fe8b501d72bef909 Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 28 Jul 2024 11:53:15 +0900 Subject: [PATCH] fix (backend): set name and description for existing Mastodon API tokens --- docs/downgrade.sql | 1 + .../1722134626110-set-access-token-name.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 packages/backend/src/migration/1722134626110-set-access-token-name.ts diff --git a/docs/downgrade.sql b/docs/downgrade.sql index a645eb1b65..24f0f4baa8 100644 --- a/docs/downgrade.sql +++ b/docs/downgrade.sql @@ -1,6 +1,7 @@ BEGIN; DELETE FROM "migrations" WHERE name IN ( + 'SetAccessTokenName1722134626110', 'CreateSystemActors1720618854585', 'AddMastodonSubscriptionType1715181461692', 'SwSubscriptionAccessToken1709395223611', diff --git a/packages/backend/src/migration/1722134626110-set-access-token-name.ts b/packages/backend/src/migration/1722134626110-set-access-token-name.ts new file mode 100644 index 0000000000..4b9824b11c --- /dev/null +++ b/packages/backend/src/migration/1722134626110-set-access-token-name.ts @@ -0,0 +1,16 @@ +import type { MigrationInterface, QueryRunner } from "typeorm"; + +export class SetAccessTokenName1722134626110 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `UPDATE "access_token" SET "name" = "app"."name" FROM "app" WHERE "access_token"."name" IS NULL AND "access_token"."appId" = "app"."id"`, + ); + await queryRunner.query( + `UPDATE "access_token" SET "description" = "app"."description" FROM "app" WHERE "access_token"."description" IS NULL AND "access_token"."appId" = "app"."id"`, + ); + } + + public async down(_: QueryRunner): Promise { + /* You don't need to revert this migration. */ + } +}