forked from CodewarsClone/Codewars
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.sql
More file actions
49 lines (40 loc) · 1.39 KB
/
Copy pathtables.sql
File metadata and controls
49 lines (40 loc) · 1.39 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
DROP TABLE IF EXISTS ratings, rating, solutions, katas, kata, users;
CREATE TABLE users (
id serial primary key,
github_id varchar(255),
name varchar(80),
email varchar(255),
username varchar (40),
picture_url text
);
CREATE TABLE katas (
id serial primary key,
kyu integer not null,
test_script json not null,
description text,
starter_code text not null,
name varchar(255),
examples json
);
CREATE TABLE solutions (
id serial primary key,
user_id integer references users(id),
kata_id integer references katas(id),
script text not null
);
CREATE TABLE ratings (
id serial primary key,
user_id integer references users(id),
kata_id integer references katas(id),
solution_id integer references solutions(id),
liked boolean not null
);
INSERT INTO users (github_id, name, email, username, picture_url)
VALUES ('12', 'Bob Smith', 'bob@smith.com', 'bobIScool', null);
INSERT INTO katas (kyu, description, starter_code, name, examples, test_script)
VALUES (8, 'var a should equal 1', 'var a = 1', 'Sumbit This', '[{"test":"Test.assertEquals(a, 1)","result":""}]', '[{"test":"Test.assertEquals(a, 0)","result":""},{"test":"Test.assertEquals(a, 2)","result":""},{"test":"Test.assertEquals(a, 1)","result":""}]');
INSERT INTO solutions (user_id, kata_id, script)
VALUES (1, 1, 'var a = 1'),
(1,1, 'let a = 1');
INSERT INTO ratings (user_id, solution_id, liked)
VALUES (1, 1, true);