-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sql
More file actions
35 lines (30 loc) · 1.02 KB
/
setup.sql
File metadata and controls
35 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(255),
last_name VARCHAR(255),
created_at DEFAULT CURRENT_TIMESTAMP
);
DROP TABLE IF EXISTS user_tags;
CREATE TABLE user_tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
tag_id INTEGER NOT NULL,
type VARCHAR(8),
created_at DEFAULT CURRENT_TIMESTAMP
);
DROP TABLE IF EXISTS tags;
CREATE TABLE tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
body VARCHAR(255),
created_at DEFAULT CURRENT_TIMESTAMP
);
insert into users (first_name, last_name) values ('John', 'Doe');
insert into tags (body) values ('tag1');
insert into tags (body) values ('tag2');
insert into tags (body) values ('tag3');
insert into tags (body) values ('tag4');
insert into user_tags (user_id, tag_id, type) values (1, 1, 'a');
insert into user_tags (user_id, tag_id, type) values (1, 2, 'b');
insert into user_tags (user_id, tag_id, type) values (1, 3, 'a');
insert into user_tags (user_id, tag_id, type) values (1, 4, 'b');