-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwdiconfapi.sql
174 lines (159 loc) · 4.04 KB
/
wdiconfapi.sql
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
-- DROP DATABASE wdiconfapi;
-- CREATE DATABASE wdiconfapi;
\c wdiconfapi
DROP TABLE Events_Users;
DROP TABLE Events_Presenters;
DROP TABLE Events;
DROP TABLE Venues;
DROP TABLE Presenters;
DROP TABLE Users;
CREATE TABLE Venues (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
address TEXT,
image_url TEXT
);
CREATE TABLE Events (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
date DATE,
time TIME,
description TEXT,
image_url TEXT,
venue_id INT references Venues(id)
);
CREATE TABLE Presenters (
id SERIAL PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255),
company VARCHAR(255),
title VARCHAR(255),
email VARCHAR(255),
bio TEXT,
image_url TEXT
);
CREATE TABLE Events_Presenters (
id SERIAL PRIMARY KEY,
event_id INT references Events(id),
presenter_id INT references Presenters(id)
);
CREATE TABLE Users (
id SERIAL PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255),
email VARCHAR(255) NOT NULL UNIQUE,
username VARCHAR(255),
password_digest VARCHAR(255),
image_url TEXT,
admin BOOLEAN
);
CREATE TABLE Events_Users (
id SERIAL PRIMARY KEY,
event_id INT references Events(id),
user_id INT references Users(id)
);
CREATE TABLE Tickets (
id SERIAL PRIMARY KEY,
ticket_number INT,
user_id INT references Users(id)
);
-- Seed files
INSERT INTO Venues(name, address, image_url)
VALUES
(
'General Assembly',
'80 William St, Melbourne',
'http://placehold.it/150x150'
), (
'Federation Square',
'Swanston St, Melbourne',
'http://placehold.it/150x150'
);
INSERT INTO Events(name, date, time, description, venue_id, image_url)
VALUES
(
'Introduction to HTML',
'9 December 2016',
'9:00AM',
'The best introduction to HTML ever.',
1,
'http://placehold.it/150x150'
), (
'Introduction to CSS',
'9 December 2016',
'10:00AM',
'The best introduction to CSS ever.',
1,
'http://placehold.it/150x150'
), (
'Introduction to JavaScript',
'9 December 2016',
'11:00AM',
'The best introduction to JavaScript ever.',
1,
'http://placehold.it/150x150'
), (
'Introduction to Ruby',
'10 December 2016',
'9:00AM',
'The best introduction to Ruby ever.',
2,
'http://placehold.it/150x150'
), (
'Introduction to Sinatra',
'10 December 2016 11:00',
'11:00AM',
'The best introduction to Sinatra ever.',
2,
'http://placehold.it/150x150'
);
INSERT INTO Presenters(first_name, last_name, company, title, email, bio, image_url)
VALUES
(
'James',
'Mah',
'Kepler Analytics',
'Industrial Designer',
'jamesmah@workmail.com',
'Synth kickstarter locavore hell of man braid knausgaard. Hoodie raw denim craft beer, hammock seitan small batch copper mug snackwave tofu PBR&B flannel synth next level vegan echo park. Fashion axe chillwave tacos, trust fund intelligentsia small batch cliche meditation. Tacos subway tile post-ironic, tumblr listicle man braid mixtape ennui kinfolk lumbersexual',
'http://placehold.it/150x150'
), (
'Ka Seng',
'Chan',
'NHP Electrical',
'Electrical Engineer',
'kasengchan@gmail.com',
'Synth kickstarter locavore hell of man braid knausgaard. Hoodie raw denim craft beer, hammock seitan small batch copper mug snackwave tofu PBR&B flannel synth next level vegan echo park. Fashion axe chillwave tacos, trust fund intelligentsia small batch cliche meditation. Tacos subway tile post-ironic, tumblr listicle man braid mixtape ennui kinfolk lumbersexual',
'http://placehold.it/150x150'
);
INSERT INTO Events_Presenters(event_id, presenter_id)
VALUES (1, 1), (1, 2), (2, 2);
INSERT INTO Users(first_name, last_name, email, username, password_digest, image_url,admin)
VALUES
(
'admin',
'admin',
'admin',
'',
'$2a$10$hg3DoYZP.NVqAJSLmah83eMrhFFbCxmkeLR5hBZ/7UGYCV7bvbR8.',
'http://placehold.it/150x150',
'true'
), (
'James',
'Mah',
'james',
'',
'$2a$10$I.SexHZDHau5IIBKOzYCYuP84ZBr8sbDaLKVkbLYf4XEzD4jxyWLa',
'http://placehold.it/150x150',
'true'
), (
'Tim',
'Timmy',
'tim@gmail.com',
'timmy',
'timmy',
'http://placehold.it/150x150',
'false'
);
INSERT INTO Events_Users(event_id , user_id)
VALUES (1, 1), (1, 2), (2, 2);