Last active
April 28, 2023 00:06
-
-
Save mgwedd/ad8ba5e74ce617533d5d2238c777c4f5 to your computer and use it in GitHub Desktop.
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
CREATE TABLE Users ( | |
id SERIAL PRIMARY KEY, | |
email VARCHAR(255) UNIQUE NOT NULL, | |
name VARCHAR(255) | |
); | |
CREATE TABLE Booklets ( | |
id SERIAL PRIMARY KEY, | |
title VARCHAR(255) NOT NULL | |
); | |
CREATE TABLE Clips ( | |
id SERIAL PRIMARY KEY, | |
title VARCHAR(255) NOT NULL | |
); | |
CREATE TYPE RoleType AS ENUM ('EDITOR', 'COMMENTER', 'VIEWER', 'OWNER'); | |
CREATE TABLE UserBookletRoles ( | |
id SERIAL PRIMARY KEY, | |
role RoleType NOT NULL, | |
userId INT NOT NULL, | |
bookletId INT NOT NULL, | |
FOREIGN KEY (userId) REFERENCES Users(id), | |
FOREIGN KEY (bookletId) REFERENCES Booklets(id), | |
UNIQUE (userId, bookletId) | |
); | |
CREATE TABLE UserClipRoles ( | |
id SERIAL PRIMARY KEY, | |
role RoleType NOT NULL, | |
userId INT NOT NULL, | |
clipId INT NOT NULL, | |
FOREIGN KEY (userId) REFERENCES Users(id), | |
FOREIGN KEY (clipId) REFERENCES Clips(id), | |
UNIQUE (userId, clipId) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment