Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
store: support nested file groups with custom ordering (#393)
Closes #319
- Loading branch information
Showing
18 changed files
with
1,629 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
CREATE TABLE "fileGroup" | ||
( | ||
"id" uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(), | ||
"order" int NOT NULL, | ||
"file" uuid NULL, | ||
"parent" uuid NULL, | ||
"name" varchar NULL, | ||
"meta" jsonb NOT NULL, | ||
"createdAt" timestamptz NOT NULL DEFAULT now(), | ||
"updatedAt" timestamptz NOT NULL DEFAULT now(), | ||
"deletedAt" timestamptz NULL, | ||
-- Bother file and parent fields are optional, since we expect either one of them to exists | ||
-- However we still want to cascade hard deletes | ||
constraint "fileGroupFileFk" foreign key ("file") | ||
references "file" ("id") | ||
ON DELETE CASCADE, | ||
constraint "fileGroupParentFk" foreign key ("parent") | ||
references "fileGroup" ("id") | ||
ON DELETE CASCADE | ||
); | ||
|
||
CREATE INDEX "fileGroupFileIdx" ON "fileGroup" ("file"); | ||
CREATE INDEX "fileGroupParentIdx" ON "fileGroup" ("parent"); | ||
CREATE INDEX "fileGroupDeletedAtIdx" ON "fileGroup" ("deletedAt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE OR REPLACE VIEW "fileGroupView" AS | ||
SELECT | ||
fg.*, | ||
CASE WHEN (calc."childCount" > 0) THEN TRUE ELSE FALSE END as "isDirectory" | ||
FROM | ||
"fileGroup" fg | ||
LEFT JOIN LATERAL ( SELECT | ||
count(nfg."id") as "childCount" | ||
FROM | ||
"fileGroup" nfg | ||
WHERE | ||
nfg."parent" = fg."id" ) "calc" | ||
ON TRUE; |
Oops, something went wrong.