Initial commit
This commit is contained in:
commit
ce518aeeb5
16 changed files with 1755 additions and 0 deletions
10
db/00-states.sql
Normal file
10
db/00-states.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE states (
|
||||
state varchar UNIQUE NOT NULL,
|
||||
PRIMARY KEY(state)
|
||||
);
|
||||
|
||||
INSERT INTO states (state) VALUES
|
||||
('Requested'),
|
||||
('Rejected'),
|
||||
('Accepted'),
|
||||
('Learned');
|
9
db/10-requests.sql
Normal file
9
db/10-requests.sql
Normal file
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE requests (
|
||||
id int GENERATED ALWAYS AS IDENTITY,
|
||||
url varchar UNIQUE,
|
||||
requester varchar NOT NULL,
|
||||
score int DEFAULT 0,
|
||||
state varchar NOT NULL DEFAULT 'Requested',
|
||||
PRIMARY KEY(id),
|
||||
FOREIGN KEY (state) REFERENCES states(state)
|
||||
);
|
2
db/50-views.sql
Normal file
2
db/50-views.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
CREATE VIEW requests_vw AS
|
||||
SELECT * FROM requests WHERE state = 'Requested' ORDER BY score DESC;
|
Loading…
Add table
Add a link
Reference in a new issue