-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editing/creating newspaper and using it on publish
- Loading branch information
Showing
17 changed files
with
380 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Add migration script here | ||
-- Add migration script here | ||
-- Add migration script here | ||
|
||
alter table public.newspapers | ||
add "background" text; |
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,88 @@ | ||
CREATE TABLE | ||
users ( | ||
id BIGSERIAL PRIMARY KEY, | ||
email text NOT NULL UNIQUE, | ||
avatar text, | ||
name varchar(40), | ||
skill_0 smallint default 0, | ||
skill_1 smallint default 0, | ||
skill_2 smallint default 0, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE TABLE | ||
newspapers ( | ||
id BIGSERIAL PRIMARY KEY, | ||
avatar text NOT NULL, | ||
name varchar(40) NOT NULL, | ||
background text, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
CREATE TYPE newspaper_ranks AS ENUM ( | ||
'author','editor', 'owner'); | ||
CREATE TABLE | ||
journalists ( | ||
user_id bigint, | ||
newspaper_id bigint, | ||
rank newspaper_ranks, | ||
primary key (user_id, newspaper_id), | ||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users (id), | ||
CONSTRAINT fk_newspaper_id FOREIGN KEY ( newspaper_id) REFERENCES newspapers (id) | ||
); | ||
|
||
CREATE TABLE | ||
articles ( | ||
id BIGSERIAL PRIMARY KEY, | ||
title varchar(40) not null, | ||
content text NOT NULL, | ||
author_id bigint NOT NULL, | ||
newspaper_id bigint, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
CONSTRAINT fk_author_id FOREIGN KEY (author_id) REFERENCES users (id), | ||
CONSTRAINT fk_newspaper_id FOREIGN KEY (newspaper_id) REFERENCES newspapers (id) | ||
); | ||
|
||
CREATE TABLE | ||
upvotes ( | ||
user_id bigint, | ||
article_id bigint, | ||
primary key (user_id, article_id), | ||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users (id), | ||
CONSTRAINT fk_article_id FOREIGN KEY (article_id) REFERENCES articles (id) | ||
); | ||
|
||
CREATE TABLE | ||
vouchers ( | ||
id BIGSERIAL PRIMARY KEY, | ||
code varchar(20) not null UNIQUE, | ||
reward smallint not null | ||
); | ||
|
||
CREATE TABLE | ||
used_vouchers ( | ||
user_id bigint, | ||
voucher_id bigint, | ||
primary key (user_id, voucher_id), | ||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users (id), | ||
CONSTRAINT fk_voucher_id FOREIGN KEY (voucher_id) REFERENCES vouchers (id) | ||
); | ||
|
||
CREATE TABLE | ||
user_sessions ( | ||
id BIGSERIAL PRIMARY KEY, | ||
user_id bigint NOT NULL, | ||
session_token_p1 text NOT NULL, | ||
session_token_p2 text NOT NULL, | ||
created_at bigint NOT NULL, | ||
expires_at bigint NOT NULL, | ||
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES users (id) | ||
); | ||
|
||
CREATE TABLE | ||
oauth2_state_storage ( | ||
id bigSERIAL PRIMARY KEY, | ||
csrf_state text NOT NULL, | ||
pkce_code_verifier text NOT NULL, | ||
return_url text NOT NULL | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.