more robust sql scripts

This commit is contained in:
anon 2023-08-02 20:54:18 +02:00
parent f363df0e74
commit 941f924608
2 changed files with 32 additions and 13 deletions

22
defaults.sql Normal file
View File

@ -0,0 +1,22 @@
INSERT INTO difficulty VALUES('easy');
INSERT INTO difficulty VALUES('medium');
INSERT INTO difficulty VALUES('hard');
INSERT INTO difficulty VALUES('fuck you');
INSERT INTO tag VALUES('math');
INSERT INTO tag VALUES('AI');
INSERT INTO tag VALUES('networking');
INSERT INTO tag VALUES('games');
INSERT INTO tag VALUES('rendering');
INSERT INTO tag VALUES('simulation');
--
INSERT INTO project (title, body) VALUES (
'test project',
'desc'
);
INSERT INTO assignment VALUES (
'#/g/chad',
1
);

View File

@ -1,3 +1,4 @@
DROP TABLE IF EXISTS project;
CREATE TABLE project (
title VARCHAR(64) NOT NULL,
body TEXT DEFAULT NULL,
@ -8,29 +9,25 @@ CREATE TABLE project (
span INT NOT NULL DEFAULT 7 -- time to last for in days
);
DROP TABLE IF EXISTS difficulty;
CREATE TABLE difficulty (
diff VARCHAR(16)
);
INSERT INTO difficulty VALUES('easy');
INSERT INTO difficulty VALUES('medium');
INSERT INTO difficulty VALUES('hard');
INSERT INTO difficulty VALUES('fuck you');
DROP TABLE IF EXISTS tag;
CREATE TABLE tag (
t VARCHAR(16)
);
-- Some default (not all) tags
INSERT INTO tag VALUES('math');
INSERT INTO tag VALUES('AI');
INSERT INTO tag VALUES('networking');
INSERT INTO tag VALUES('games');
INSERT INTO tag VALUES('rendering');
INSERT INTO tag VALUES('simulation');
DROP TABLE IF EXISTS project_tag;
CREATE TABLE project_tag (
project INT REFERENCES project(rowid),
tag INT REFERENCES tag(rowid)
);
DROP TABLE IF EXISTS assignment;
CREATE TABLE assignment (
who VARCHAR(32) NOT NULL,
project INT NOT NULL REFERENCES project(rowid)
);