fix (backend): set name and description for existing Mastodon API tokens

This commit is contained in:
naskya 2024-07-28 11:53:15 +09:00
parent 0fcb17d9b6
commit 20eadcf2f8
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
2 changed files with 17 additions and 0 deletions

View file

@ -1,6 +1,7 @@
BEGIN; BEGIN;
DELETE FROM "migrations" WHERE name IN ( DELETE FROM "migrations" WHERE name IN (
'SetAccessTokenName1722134626110',
'CreateSystemActors1720618854585', 'CreateSystemActors1720618854585',
'AddMastodonSubscriptionType1715181461692', 'AddMastodonSubscriptionType1715181461692',
'SwSubscriptionAccessToken1709395223611', 'SwSubscriptionAccessToken1709395223611',

View file

@ -0,0 +1,16 @@
import type { MigrationInterface, QueryRunner } from "typeorm";
export class SetAccessTokenName1722134626110 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
/* You don't need to revert this migration. */
}
}