|
| 1 | +import { MigrationInterface, QueryRunner } from "typeorm"; |
| 2 | + |
| 3 | +export class RealmFeedItemComment1663081197272 implements MigrationInterface { |
| 4 | + name = 'RealmFeedItemComment1663081197272' |
| 5 | + |
| 6 | + public async up(queryRunner: QueryRunner): Promise<void> { |
| 7 | + await queryRunner.query(` |
| 8 | + CREATE TABLE "realm_feed_item_comment" ( |
| 9 | + "id" SERIAL NOT NULL, |
| 10 | + "authorId" uuid NOT NULL, |
| 11 | + "data" jsonb NOT NULL, |
| 12 | + "feedItemId" integer NOT NULL, |
| 13 | + "environment" character varying NOT NULL, |
| 14 | + "metadata" jsonb NOT NULL, |
| 15 | + "parentCommentId" integer, |
| 16 | + "realmPublicKeyStr" character varying NOT NULL, |
| 17 | + "created" TIMESTAMP NOT NULL DEFAULT now(), |
| 18 | + "deleted" TIMESTAMP, |
| 19 | + "updated" TIMESTAMP NOT NULL DEFAULT now(), |
| 20 | + CONSTRAINT "PK_241ee9ad70d478bea24f5cad849" PRIMARY KEY ("id") |
| 21 | + ) |
| 22 | + `); |
| 23 | + await queryRunner.query(` |
| 24 | + CREATE TABLE "realm_feed_item_comment_vote" ( |
| 25 | + "commentId" integer NOT NULL, |
| 26 | + "userId" uuid NOT NULL, |
| 27 | + "realmPublicKeyStr" character varying NOT NULL, |
| 28 | + "data" jsonb NOT NULL, |
| 29 | + "created" TIMESTAMP NOT NULL DEFAULT now(), |
| 30 | + "deleted" TIMESTAMP, |
| 31 | + "updated" TIMESTAMP NOT NULL DEFAULT now(), |
| 32 | + CONSTRAINT "PK_e163f06bd5b24e570a1e3502598" PRIMARY KEY ("commentId", "userId", "realmPublicKeyStr") |
| 33 | + ) |
| 34 | + `); |
| 35 | + await queryRunner.query(` |
| 36 | + ALTER TABLE "realm_feed_item_comment" |
| 37 | + ADD CONSTRAINT "FK_d9738a44f8f8e8436c9bbdcf0d6" FOREIGN KEY ("authorId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION |
| 38 | + `); |
| 39 | + await queryRunner.query(` |
| 40 | + ALTER TABLE "realm_feed_item_comment" |
| 41 | + ADD CONSTRAINT "FK_8f105becc4961c4627e11ec0ed9" FOREIGN KEY ("feedItemId") REFERENCES "realm_feed_item"("id") ON DELETE NO ACTION ON UPDATE NO ACTION |
| 42 | + `); |
| 43 | + } |
| 44 | + |
| 45 | + public async down(queryRunner: QueryRunner): Promise<void> { |
| 46 | + await queryRunner.query(` |
| 47 | + ALTER TABLE "realm_feed_item_comment" DROP CONSTRAINT "FK_8f105becc4961c4627e11ec0ed9" |
| 48 | + `); |
| 49 | + await queryRunner.query(` |
| 50 | + ALTER TABLE "realm_feed_item_comment" DROP CONSTRAINT "FK_d9738a44f8f8e8436c9bbdcf0d6" |
| 51 | + `); |
| 52 | + await queryRunner.query(` |
| 53 | + DROP TABLE "realm_feed_item_comment_vote" |
| 54 | + `); |
| 55 | + await queryRunner.query(` |
| 56 | + DROP TABLE "realm_feed_item_comment" |
| 57 | + `); |
| 58 | + } |
| 59 | + |
| 60 | +} |
0 commit comments