hmm
This commit is contained in:
parent
f370a2fe68
commit
e335c65506
21 changed files with 33471 additions and 86 deletions
|
|
@ -1,51 +1,63 @@
|
|||
CREATE TABLE users (
|
||||
user_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT NOT NULL
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
UNIQUE(username)
|
||||
);
|
||||
|
||||
CREATE TABLE structures (
|
||||
structure_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
user_id INTEGER,
|
||||
FOREIGN KEY(user_id) REFERENCES users(user_id)
|
||||
FOREIGN KEY(user_id) REFERENCES users(id),
|
||||
UNIQUE(name, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE dbs (
|
||||
db_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
belongs_to_struct INTEGER,
|
||||
FOREIGN KEY(belongs_to_struct) REFERENCES structures(structure_id)
|
||||
FOREIGN KEY(belongs_to_struct) REFERENCES structures(id),
|
||||
UNIQUE(name, belongs_to_struct)
|
||||
);
|
||||
|
||||
CREATE TABLE templates (
|
||||
template_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
content TEXT NOT NULL,
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
file_path TEXT NOT NULL,
|
||||
user_id INTEGER,
|
||||
belongs_to_struct INTEGER,
|
||||
FOREIGN KEY(user_id) REFERENCES users(user_id),
|
||||
FOREIGN KEY(belongs_to_struct) REFERENCES structures(structure_id)
|
||||
engine TEXT NOT NULL,
|
||||
FOREIGN KEY(user_id) REFERENCES users(id),
|
||||
FOREIGN KEY(belongs_to_struct) REFERENCES structures(id),
|
||||
UNIQUE(name, belongs_to_struct)
|
||||
);
|
||||
|
||||
CREATE TABLE routes (
|
||||
route_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
verb TEXT CHECK(verb IN ('POST', 'GET', 'PUT', 'DELETE')),
|
||||
path TEXT NOT NULL,
|
||||
structure_id INTEGER,
|
||||
user_id INTEGER,
|
||||
handler TEXT NOT NULL,
|
||||
FOREIGN KEY(structure_id) REFERENCES structures(structure_id),
|
||||
FOREIGN KEY(user_id) REFERENCES users(user_id)
|
||||
language TEXT NOT NULL,
|
||||
FOREIGN KEY(structure_id) REFERENCES structures(id),
|
||||
FOREIGN KEY(user_id) REFERENCES users(id) UNIQUE(verb, path)
|
||||
);
|
||||
|
||||
CREATE TABLE structure_dbs (
|
||||
db_id INTEGER,
|
||||
structure_id INTEGER,
|
||||
PRIMARY KEY(db_id, structure_id),
|
||||
FOREIGN KEY(db_id) REFERENCES dbs(db_id),
|
||||
FOREIGN KEY(structure_id) REFERENCES structures(structure_id)
|
||||
FOREIGN KEY(db_id) REFERENCES dbs(id),
|
||||
FOREIGN KEY(structure_id) REFERENCES structures(id)
|
||||
);
|
||||
|
||||
CREATE TABLE structure_templates (
|
||||
template_id INTEGER,
|
||||
structure_id INTEGER,
|
||||
alias TEXT NOT NULL,
|
||||
PRIMARY KEY(template_id, structure_id),
|
||||
FOREIGN KEY(template_id) REFERENCES templates(template_id),
|
||||
FOREIGN KEY(structure_id) REFERENCES structures(structure_id)
|
||||
);
|
||||
FOREIGN KEY(template_id) REFERENCES templates(id),
|
||||
FOREIGN KEY(structure_id) REFERENCES structures(id),
|
||||
UNIQUE(structure_id, alias)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue