-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
5,603 additions
and
252 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
BEGIN; | ||
|
||
DROP TABLE IF EXISTS bookbrainz.user_collection; | ||
DROP TABLE IF EXISTS bookbrainz.user_collection_collaborator; | ||
DROP TABLE IF EXISTS bookbrainz.user_collection_item; | ||
|
||
COMMIT; |
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,38 @@ | ||
BEGIN; | ||
|
||
CREATE TABLE IF NOT EXISTS bookbrainz.user_collection ( | ||
id UUID PRIMARY KEY DEFAULT public.uuid_generate_v4(), | ||
owner_id INT NOT NULL, | ||
name VARCHAR(80) NOT NULL CHECK (name <> ''), | ||
description TEXT NOT NULL DEFAULT '', | ||
entity_type bookbrainz.entity_type NOT NULL, | ||
public BOOLEAN NOT NULL DEFAULT FALSE, | ||
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT timezone('UTC'::TEXT, now()), | ||
last_modified TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT timezone('UTC'::TEXT, now()) | ||
); | ||
ALTER TABLE bookbrainz.user_collection ADD FOREIGN KEY (owner_id) REFERENCES bookbrainz.editor (id); | ||
|
||
CREATE TABLE IF NOT EXISTS bookbrainz.user_collection_item ( | ||
collection_id UUID, | ||
bbid UUID, | ||
added_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT timezone('UTC'::TEXT, now()), | ||
PRIMARY KEY ( | ||
collection_id, | ||
bbid | ||
) | ||
); | ||
ALTER TABLE bookbrainz.user_collection_item ADD FOREIGN KEY (collection_id) REFERENCES bookbrainz.user_collection (id) ON DELETE CASCADE; | ||
ALTER TABLE bookbrainz.user_collection_item ADD FOREIGN KEY (bbid) REFERENCES bookbrainz.entity (bbid); | ||
|
||
CREATE TABLE IF NOT EXISTS bookbrainz.user_collection_collaborator ( | ||
collection_id UUID, | ||
collaborator_id INT, | ||
PRIMARY KEY ( | ||
collection_id, | ||
collaborator_id | ||
) | ||
); | ||
ALTER TABLE bookbrainz.user_collection_collaborator ADD FOREIGN KEY (collection_id) REFERENCES bookbrainz.user_collection (id) ON DELETE CASCADE; | ||
ALTER TABLE bookbrainz.user_collection_collaborator ADD FOREIGN KEY (collaborator_id) REFERENCES bookbrainz.editor (id); | ||
|
||
COMMIT; |
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
Oops, something went wrong.