mizzkey/packages/backend/migration/1718015380000-add-channel-muting.js
2024-06-30 20:51:37 +09:00

38 lines
1.3 KiB
JavaScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class AddChannelMuting1718015380000 {
name = 'AddChannelMuting1718015380000'
async up(queryRunner) {
await queryRunner.query(`
CREATE TABLE "channel_muting"
(
"id" varchar(32) NOT NULL,
"userId" varchar(32) NOT NULL,
"channelId" varchar(32) NOT NULL,
"expiresAt" timestamp with time zone,
CONSTRAINT "PK_channel_muting_id" PRIMARY KEY ("id"),
CONSTRAINT "FK_channel_muting_userId" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT "FK_channel_muting_channelId" FOREIGN KEY ("channelId") REFERENCES "channel"("id") ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE INDEX "IDX_channel_muting_userId" ON "channel_muting" ("userId");
CREATE INDEX "IDX_channel_muting_channelId" ON "channel_muting" ("channelId");
`);
}
async down(queryRunner) {
await queryRunner.query(`
ALTER TABLE "channel_muting"
DROP CONSTRAINT "FK_channel_muting_userId";
ALTER TABLE "channel_muting"
DROP CONSTRAINT "FK_channel_muting_channelId";
DROP INDEX "IDX_channel_muting_userId";
DROP INDEX "IDX_channel_muting_channelId";
DROP TABLE "channel_muting";
`);
}
}