import { MigrationInterface , QueryRunner } from "typeorm" ; export class Messages1605313319843 implements MigrationInterface { name = 'Messages1605313319843' ; public async up ( queryRunner ) { await queryRunner . query ( `CREATE TABLE "message" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "senderId" uuid NOT NULL, "recipientId" uuid NOT NULL, "text" text NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), CONSTRAINT "PK_ba01f0a3e0123651915008bc578" PRIMARY KEY ("id"))` ) ; await queryRunner . query ( `COMMENT ON COLUMN "user"."codeImgIds" IS NULL` ) ; await queryRunner . query ( `ALTER TABLE "user" ALTER COLUMN "codeImgIds" SET DEFAULT '{}'::text[]` ) ; await queryRunner . query ( `ALTER TABLE "message" ADD CONSTRAINT "FK_bc096b4e18b1f9508197cd98066" FOREIGN KEY ("senderId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` ) ; await queryRunner . query ( `ALTER TABLE "message" ADD CONSTRAINT "FK_445b786f516688cf2b81b8981b6" FOREIGN KEY ("recipientId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` ) ; } public async down ( queryRunner ) { await queryRunner . query ( `ALTER TABLE "message" DROP CONSTRAINT "FK_445b786f516688cf2b81b8981b6"` ) ; await queryRunner . query ( `ALTER TABLE "message" DROP CONSTRAINT "FK_bc096b4e18b1f9508197cd98066"` ) ; await queryRunner . query ( `ALTER TABLE "user" ALTER COLUMN "codeImgIds" SET DEFAULT '{}'` ) ; await queryRunner . query ( `COMMENT ON COLUMN "user"."codeImgIds" IS NULL` ) ; await queryRunner . query ( `DROP TABLE "message"` ) ; } }