-
Notifications
You must be signed in to change notification settings - Fork 0
fix: チャンネル管理と投稿の連合設定を修正 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: syuilo and misskey-project | ||
| * SPDX-License-Identifier: AGPL-3.0-only | ||
| */ | ||
|
|
||
| export class NormalizeChannelCollaboratorIds1787277329377 { | ||
| name = 'NormalizeChannelCollaboratorIds1787277329377' | ||
|
|
||
| async up(queryRunner) { | ||
| await queryRunner.query(`ALTER TABLE "channel" ADD "collaboratorIdsNormalized" character varying(32) array NOT NULL DEFAULT '{}'`); | ||
| await queryRunner.query(` | ||
| DO $$ | ||
| DECLARE | ||
| collaborator_ids_type text; | ||
| BEGIN | ||
| SELECT data_type | ||
| INTO collaborator_ids_type | ||
| FROM information_schema.columns | ||
| WHERE table_schema = 'public' | ||
| AND table_name = 'channel' | ||
| AND column_name = 'collaboratorIds'; | ||
|
|
||
| IF collaborator_ids_type = 'ARRAY' THEN | ||
| UPDATE "channel" | ||
| SET "collaboratorIdsNormalized" = CASE | ||
| WHEN "collaboratorIds" IS NULL OR EXISTS ( | ||
| SELECT 1 | ||
| FROM unnest("collaboratorIds"::text[]) AS element | ||
| WHERE element IS NULL OR length(element) > 32 | ||
| ) THEN '{}' | ||
| ELSE "collaboratorIds"::text[] | ||
| END; | ||
| ELSIF collaborator_ids_type IN ('json', 'jsonb') THEN | ||
| UPDATE "channel" | ||
| SET "collaboratorIdsNormalized" = CASE | ||
| WHEN "collaboratorIds" IS NULL OR jsonb_typeof("collaboratorIds"::jsonb) <> 'array' THEN '{}' | ||
| WHEN EXISTS ( | ||
| SELECT 1 | ||
| FROM jsonb_array_elements("collaboratorIds"::jsonb) AS element | ||
| WHERE jsonb_typeof(element) <> 'string' | ||
| OR length(element #>> '{}') > 32 | ||
| ) THEN '{}' | ||
| ELSE ARRAY(SELECT jsonb_array_elements_text("collaboratorIds"::jsonb)) | ||
| END; | ||
| END IF; | ||
| END $$; | ||
| `); | ||
| await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "collaboratorIds"`); | ||
| await queryRunner.query(`ALTER TABLE "channel" RENAME COLUMN "collaboratorIdsNormalized" TO "collaboratorIds"`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."collaboratorIds" IS 'Collaborator user IDs.'`); | ||
| } | ||
|
|
||
| async down(queryRunner) { | ||
| await queryRunner.query(`ALTER TABLE "channel" ADD "collaboratorIdsBeforeNormalization" character varying(64) array DEFAULT '{}'`); | ||
| await queryRunner.query(`UPDATE "channel" SET "collaboratorIdsBeforeNormalization" = "collaboratorIds"::text[]`); | ||
| await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "collaboratorIds"`); | ||
| await queryRunner.query(`ALTER TABLE "channel" RENAME COLUMN "collaboratorIdsBeforeNormalization" TO "collaboratorIds"`); | ||
|
Comment on lines
+54
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Line 41 は nullable な列を作成します。
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.