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