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. */ + } +}