summaryrefslogtreecommitdiff
path: root/packages/backend
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2025-03-05 16:49:49 +0900
committerGitHub <noreply@github.com>2025-03-05 16:49:49 +0900
commite8a6629cb5b8e10ec3d6d15dfc5d13d220883f2b (patch)
tree81ee8af1c688c51e32d649e123a289f57afb2615 /packages/backend
parentBump version to 2025.3.0-beta.0 (diff)
downloadsharkey-e8a6629cb5b8e10ec3d6d15dfc5d13d220883f2b.tar.gz
sharkey-e8a6629cb5b8e10ec3d6d15dfc5d13d220883f2b.tar.bz2
sharkey-e8a6629cb5b8e10ec3d6d15dfc5d13d220883f2b.zip
fix(backend): システムアカウント系のマイグレーション不足を修正 (#15586)
* fix(backend): プロキシアカウントのロールバック用マイグレーションを追加 * fix * separate newly-added `up` command * drop backwards-compatibility * docs
Diffstat (limited to 'packages/backend')
-rw-r--r--packages/backend/migration/1740129169650-system-accounts-2.js4
-rw-r--r--packages/backend/migration/1740133121105-system-accounts-3.js8
-rw-r--r--packages/backend/migration/1740993126937-system-accounts-4.js17
3 files changed, 25 insertions, 4 deletions
diff --git a/packages/backend/migration/1740129169650-system-accounts-2.js b/packages/backend/migration/1740129169650-system-accounts-2.js
index 07270855bf..c03f0337ab 100644
--- a/packages/backend/migration/1740129169650-system-accounts-2.js
+++ b/packages/backend/migration/1740129169650-system-accounts-2.js
@@ -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`);
}
}
diff --git a/packages/backend/migration/1740133121105-system-accounts-3.js b/packages/backend/migration/1740133121105-system-accounts-3.js
index 02f9207cdc..a1f8c996f5 100644
--- a/packages/backend/migration/1740133121105-system-accounts-3.js
+++ b/packages/backend/migration/1740133121105-system-accounts-3.js
@@ -10,10 +10,10 @@ export class SystemAccounts31740133121105 {
await queryRunner.query(`ALTER TABLE "meta" ADD "rootUserId" character varying(32)`);
await queryRunner.query(`ALTER TABLE "meta" ADD CONSTRAINT "FK_c80e4079d632f95eac06a9d28cc" FOREIGN KEY ("rootUserId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
- const users = await queryRunner.query(`SELECT "id" FROM "user" WHERE "isRoot" = true LIMIT 1`);
- if (users.length > 0) {
- await queryRunner.query(`UPDATE "meta" SET "rootUserId" = $1`, [users[0].id]);
- }
+ const users = await queryRunner.query(`SELECT "id" FROM "user" WHERE "isRoot" = true LIMIT 1`);
+ if (users.length > 0) {
+ await queryRunner.query(`UPDATE "meta" SET "rootUserId" = $1`, [users[0].id]);
+ }
}
async down(queryRunner) {
diff --git a/packages/backend/migration/1740993126937-system-accounts-4.js b/packages/backend/migration/1740993126937-system-accounts-4.js
new file mode 100644
index 0000000000..83654aca80
--- /dev/null
+++ b/packages/backend/migration/1740993126937-system-accounts-4.js
@@ -0,0 +1,17 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+export class SystemAccounts41740993126937 {
+ name = 'SystemAccounts41740993126937'
+
+ async up(queryRunner) {
+ await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "isRoot"`);
+ }
+
+ async down(queryRunner) {
+ // down 実行時は isRoot = true のユーザーが存在しなくなるため手動で対応する必要あり
+ await queryRunner.query(`ALTER TABLE "user" ADD "isRoot" boolean NOT NULL DEFAULT false`);
+ }
+}