fix(backend): システムアカウント系のマイグレーション不足を修正 (#15586)

* fix(backend): プロキシアカウントのロールバック用マイグレーションを追加

* fix

* separate newly-added `up` command

* drop backwards-compatibility

* docs
This commit is contained in:
かっこかり
2025-03-05 16:49:49 +09:00
committed by GitHub
parent 44658ae981
commit e8a6629cb5
3 changed files with 25 additions and 4 deletions

View File

@@ -13,6 +13,10 @@ export class SystemAccounts21740129169650 {
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "proxyAccountId" character varying(32)`);
const proxyAccountId = await queryRunner.query(`SELECT "userId" FROM "system_account" WHERE "type" = 'proxy' ORDER BY "id" DESC LIMIT 1`);
if (proxyAccountId && proxyAccountId.length >= 1) {
await queryRunner.query(`UPDATE "meta" SET "proxyAccountId" = '${proxyAccountId[0].userId}'`);
}
await queryRunner.query(`ALTER TABLE "meta" ADD CONSTRAINT "FK_ab1bc0c1e209daa77b8e8d212ad" FOREIGN KEY ("proxyAccountId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
}
}