From 08e2e473c5fe858ddaa6f8a662a4dfa5899eb37f Mon Sep 17 00:00:00 2001 From: Cleo John <30842467+CutestNekoAqua@users.noreply.github.com> Date: Thu, 2 Feb 2023 10:30:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8FNote=20Edit=20DB=20Migrati?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/1674000000000-NoteEdits.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/backend/migration/1674000000000-NoteEdits.js diff --git a/packages/backend/migration/1674000000000-NoteEdits.js b/packages/backend/migration/1674000000000-NoteEdits.js new file mode 100644 index 0000000000..2bbdb34576 --- /dev/null +++ b/packages/backend/migration/1674000000000-NoteEdits.js @@ -0,0 +1,31 @@ +export class PollChoiceLength1674000000000 { + name = 'PollChoiceLength1674000000000' + + async up(queryRunner) { + await queryRunner.query(`CREATE TABLE "post_edits" ( + "id" VARCHAR(32) NOT NULL, + "post_id" VARCHAR(32) REFERENCES "note" (id) ON DELETE CASCADE, + "user_id" VARCHAR(32) REFERENCES "user" (id) ON DELETE CASCADE, + "text" TEXT, + "cw" TEXT, + "media_attachments_changed" BOOLEAN, + "modified_at" DATE, + PRIMARY KEY ("id") + )`); + await queryRunner.query(`ALTER TABLE "note" ADD "modified_at" DATE DEFAULT NULL`); + + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."id" IS 'Unique Identified for this Edit.'`); + await queryRunner.query(`COMMENT ON COLUMN "note"."modified_at" IS 'Null if not modified, else the time it was last modified'`) + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."post_id" IS 'The Post the Edit belongs to.'`); + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."user_id" IS 'The User that made the edit.'`); + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."text" IS 'The modified Text.'`); + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."cw" IS 'The modified CW.'`); + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."media_attachments_changed" IS 'Did media attachments got changed?'`); + await queryRunner.query(`COMMENT ON COLUMN "post_edits"."modified_at" IS 'When was the post modified?'`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "modified_at"`); + await queryRunner.query(`DROP TABLE "post_edits"`); + } +}