-
Notifications
You must be signed in to change notification settings - Fork 2
/
cw_database_generate.sql
291 lines (285 loc) · 9.43 KB
/
cw_database_generate.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
use cw_portal;
CREATE TABLE IF NOT EXISTS auth_user (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
password varchar(128) NOT NULL,
last_login datetime DEFAULT "1970-01-01 00:00:01",
is_superuser bool NOT NULL,
username varchar(30) NOT NULL UNIQUE,
first_name varchar(30) NOT NULL,
last_name varchar(30) NOT NULL,
email varchar(75) NOT NULL,
is_staff bool NOT NULL,
is_active bool NOT NULL,
date_joined datetime NOT NULL
);
CREATE TABLE IF NOT EXISTS studentportal_category (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(300) NOT NULL DEFAULT "",
description varchar(1000) NOT NULL DEFAULT ""
);
CREATE TABLE IF NOT EXISTS studentportal_ngo (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(1000) NOT NULL,
link varchar(200) NOT NULL,
details text NOT NULL,
category_id integer,
FOREIGN KEY(category_id) REFERENCES studentportal_category(id)
);
CREATE TABLE IF NOT EXISTS studentportal_project (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
title varchar(1000) NOT NULL,
date_created datetime NOT NULL,
credits integer NOT NULL,
NGO_name varchar(1000) NOT NULL,
NGO_details varchar(1000) NOT NULL,
NGO_super varchar(1000) NOT NULL,
NGO_super_contact varchar(100) NOT NULL,
goals text NOT NULL,
schedule_text text NOT NULL,
finish_date datetime,
stage integer NOT NULL,
deleted bool NOT NULL,
NGO_id integer,
category_id integer NOT NULL,
student_id integer NOT NULL,
FOREIGN KEY(category_id) REFERENCES studentportal_category(id),
FOREIGN KEY(NGO_id) REFERENCES studentportal_ngo(id),
FOREIGN KEY(student_id) REFERENCES auth_user(id)
);
CREATE TABLE IF NOT EXISTS supervisor_example (
project_id integer NOT NULL,
date_created datetime NOT NULL,
likes_count integer NOT NULL,
comments_count integer NOT NULL,
FOREIGN KEY(project_id) REFERENCES studentportal_project(id),
PRIMARY KEY(project_id)
);
CREATE TABLE IF NOT EXISTS supervisor_comment (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
text varchar(200) NOT NULL,
commentor_id integer NOT NULL,
project_id integer NOT NULL,
FOREIGN KEY(commentor_id) REFERENCES auth_user(id),
FOREIGN KEY(project_id) REFERENCES supervisor_example(project_id)
);
CREATE TABLE IF NOT EXISTS supervisor_diff (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
diff_type integer NOT NULL,
details text,
`when` datetime NOT NULL,
person_id integer,
project_id integer,
FOREIGN KEY(person_id) REFERENCES auth_user(id),
FOREIGN KEY(project_id) REFERENCES studentportal_project(id)
);
CREATE TABLE IF NOT EXISTS supervisor_ta (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
email varchar(100) NOT NULL,
instructor bool NOT NULL
);
CREATE TABLE IF NOT EXISTS supervisor_notification (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
noti_type integer,
NGO_name varchar(200) NOT NULL,
NGO_link varchar(200) NOT NULL,
NGO_details text NOT NULL,
NGO_sugg_by_id integer,
project_id integer,
FOREIGN KEY(NGO_sugg_by_id) REFERENCES auth_user(id),
FOREIGN KEY(project_id) REFERENCES studentportal_project(id)
);
CREATE TABLE IF NOT EXISTS supervisor_news (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
content text NOT NULL,
date_created datetime NOT NULL,
priority bool NOT NULL
);
CREATE TABLE IF NOT EXISTS supervisor_like (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
liked_by_id integer NOT NULL,
project_id integer NOT NULL,
FOREIGN KEY(project_id) REFERENCES supervisor_example(project_id),
FOREIGN KEY(liked_by_id) REFERENCES auth_user(id)
);
CREATE TABLE IF NOT EXISTS studentportal_document (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
document varchar(100) NOT NULL,
name varchar(100) NOT NULL,
date_added datetime NOT NULL,
category integer NOT NULL,
project_id integer NOT NULL,
FOREIGN KEY(project_id) REFERENCES studentportal_project(id)
);
CREATE TABLE IF NOT EXISTS studentportal_feedback (
project_id integer NOT NULL,
hours integer NOT NULL,
achievements text NOT NULL,
experience integer NOT NULL,
FOREIGN KEY(project_id) REFERENCES studentportal_project(id),
PRIMARY KEY(project_id)
);
CREATE TABLE IF NOT EXISTS studentportal_bug (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
suggestions text NOT NULL,
rating integer NOT NULL,
user_id integer,
FOREIGN KEY(user_id) REFERENCES auth_user(id)
);
CREATE TABLE IF NOT EXISTS socialaccount_socialapp (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(40) NOT NULL,
client_id varchar(100) NOT NULL,
secret varchar(100) NOT NULL,
`key` varchar(100) NOT NULL,
provider varchar(30) NOT NULL
);
CREATE TABLE IF NOT EXISTS socialaccount_socialaccount (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
provider varchar(30) NOT NULL,
uid varchar(255) NOT NULL,
last_login datetime DEFAULT "1970-01-01 00:00:01",
date_joined datetime NOT NULL,
extra_data text NOT NULL,
user_id integer NOT NULL,
FOREIGN KEY(user_id) REFERENCES auth_user(id),
UNIQUE(provider,uid)
);
CREATE TABLE IF NOT EXISTS socialaccount_socialtoken (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
token text NOT NULL,
token_secret text NOT NULL,
expires_at datetime,
account_id integer NOT NULL,
app_id integer NOT NULL,
FOREIGN KEY(account_id) REFERENCES socialaccount_socialaccount(id),
FOREIGN KEY(app_id) REFERENCES socialaccount_socialapp(id),
UNIQUE(app_id,account_id)
);
CREATE TABLE IF NOT EXISTS django_site (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
domain varchar(100) NOT NULL,
name varchar(50) NOT NULL
);
CREATE TABLE IF NOT EXISTS socialaccount_socialapp_sites (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
socialapp_id integer NOT NULL,
site_id integer NOT NULL,
UNIQUE(socialapp_id,site_id),
FOREIGN KEY(site_id) REFERENCES django_site(id),
FOREIGN KEY(socialapp_id) REFERENCES socialaccount_socialapp(id)
);
CREATE TABLE IF NOT EXISTS django_session (
session_key varchar(40) NOT NULL,
session_data text NOT NULL,
expire_date datetime NOT NULL,
PRIMARY KEY(session_key)
);
CREATE TABLE IF NOT EXISTS social_auth_nonce (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
server_url varchar(255) NOT NULL,
timestamp integer NOT NULL,
salt varchar(65) NOT NULL,
UNIQUE(server_url,timestamp,salt)
);
CREATE TABLE IF NOT EXISTS social_auth_code (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
email varchar(75) NOT NULL,
code varchar(32) NOT NULL,
verified bool NOT NULL,
UNIQUE(email,code)
);
CREATE TABLE IF NOT EXISTS social_auth_usersocialauth (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
provider varchar(32) NOT NULL,
uid varchar(255) NOT NULL,
extra_data text NOT NULL,
user_id integer NOT NULL,
FOREIGN KEY(user_id) REFERENCES auth_user(id),
UNIQUE(provider,uid)
);
CREATE TABLE IF NOT EXISTS social_auth_association (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
server_url varchar(255) NOT NULL,
handle varchar(255) NOT NULL,
secret varchar(255) NOT NULL,
issued integer NOT NULL,
lifetime integer NOT NULL,
assoc_type varchar(64) NOT NULL
);
CREATE TABLE IF NOT EXISTS django_content_type (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(100) NOT NULL,
app_label varchar(100) NOT NULL,
model varchar(100) NOT NULL,
UNIQUE(app_label,model)
);
CREATE TABLE IF NOT EXISTS django_admin_log (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
action_time datetime NOT NULL,
object_id text,
object_repr varchar(200) NOT NULL,
action_flag smallint unsigned NOT NULL,
change_message text NOT NULL,
content_type_id integer,
user_id integer NOT NULL,
FOREIGN KEY(content_type_id) REFERENCES django_content_type(id),
FOREIGN KEY(user_id) REFERENCES auth_user(id)
);
CREATE TABLE IF NOT EXISTS account_emailaddress (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
email varchar(75) NOT NULL UNIQUE,
verified bool NOT NULL,
`primary` bool NOT NULL,
user_id integer NOT NULL,
FOREIGN KEY(user_id) REFERENCES auth_user(id)
);
CREATE TABLE IF NOT EXISTS account_emailconfirmation (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
created datetime NOT NULL,
sent datetime,
`key` varchar(64) NOT NULL UNIQUE,
email_address_id integer NOT NULL,
FOREIGN KEY(email_address_id) REFERENCES account_emailaddress(id)
);
CREATE TABLE IF NOT EXISTS auth_permission (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(50) NOT NULL,
content_type_id integer NOT NULL,
codename varchar(100) NOT NULL,
FOREIGN KEY(content_type_id) REFERENCES django_content_type(id),
UNIQUE(content_type_id,codename)
);
CREATE TABLE IF NOT EXISTS auth_user_user_permissions (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id integer NOT NULL,
permission_id integer NOT NULL,
FOREIGN KEY(permission_id) REFERENCES auth_permission(id),
FOREIGN KEY(user_id) REFERENCES auth_user(id),
UNIQUE(user_id,permission_id)
);
CREATE TABLE IF NOT EXISTS auth_group (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(80) NOT NULL UNIQUE
);
CREATE TABLE IF NOT EXISTS auth_user_groups (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
user_id integer NOT NULL,
group_id integer NOT NULL,
FOREIGN KEY(group_id) REFERENCES auth_group(id),
FOREIGN KEY(user_id) REFERENCES auth_user(id),
UNIQUE(user_id,group_id)
);
CREATE TABLE IF NOT EXISTS auth_group_permissions (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
group_id integer NOT NULL,
permission_id integer NOT NULL,
FOREIGN KEY(permission_id) REFERENCES auth_permission(id),
FOREIGN KEY(group_id) REFERENCES auth_group(id),
UNIQUE(group_id,permission_id)
);
CREATE TABLE IF NOT EXISTS django_migrations (
id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
app varchar(255) NOT NULL,
name varchar(255) NOT NULL,
applied datetime NOT NULL
);