UNPKG

985 Bapplication/x-sqlView Raw
1CREATE TABLE "fileGroup"
2(
3 "id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
4 "order" int NOT NULL,
5 "file" uuid NULL,
6 "parent" uuid NULL,
7 "name" varchar NULL,
8 "meta" jsonb NOT NULL,
9 "createdAt" timestamptz NOT NULL DEFAULT now(),
10 "updatedAt" timestamptz NOT NULL DEFAULT now(),
11 "deletedAt" timestamptz NULL,
12 -- Bother file and parent fields are optional, since we expect either one of them to exists
13 -- However we still want to cascade hard deletes
14 constraint "fileGroupFileFk" foreign key ("file")
15 references "file" ("id")
16 ON DELETE CASCADE,
17 constraint "fileGroupParentFk" foreign key ("parent")
18 references "fileGroup" ("id")
19 ON DELETE CASCADE
20);
21
22CREATE INDEX "fileGroupFileIdx" ON "fileGroup" ("file");
23CREATE INDEX "fileGroupParentIdx" ON "fileGroup" ("parent");
24CREATE INDEX "fileGroupDeletedAtIdx" ON "fileGroup" ("deletedAt");