-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql
423 lines (369 loc) · 12.3 KB
/
create.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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
create sequence hibernate_sequence start with 2 increment by 1
drop table if exists t_role;
create table t_role (
id varchar(255) not null,
name varchar(60),
primary key (id)
);
drop table if exists t_user;
create table t_user (
id varchar(255) not null,
create_time timestamp,
create_user varchar(255),
create_userip varchar(255),
deleted varchar(255),
update_time timestamp default CURRENT_TIMESTAMP,
update_user varchar(255),
update_userip varchar(255),
version integer,
birth_date TIMESTAMP(26,6) not null,
email varchar(255),
facebook_id varchar(255),
fcm_token_id varchar(255),
instagram_id varchar(255),
mobile_phone varchar(255),
name varchar(255),
password varchar(255),
twitter_id varchar(255),
user_name varchar(255),
primary key (id)
);
alter table t_user
add constraint T_USER_TWITTER_ID_UNIQUE unique (twitter_id);
alter table t_user
add constraint T_USER_USER_NAME_UNIQUE unique (user_name);
alter table t_user
add constraint T_USER_FACEBOOK_ID_UNIQUE unique (facebook_id);
alter table t_user
add constraint T_USER_INSTAGRAM_ID_UNIQUE unique (instagram_id);
alter table t_user
add constraint T_USER_EMAIL_UNIQUE unique (email);
drop table if exists t_user_roles;
create table t_user_roles (
user_id varchar(255) not null,
role_id varchar(255) not null,
primary key (user_id, role_id)
);
alter table t_user_roles
add constraint FKlbohd47sbyyx5eqbjgwi4sjky
foreign key (role_id)
references t_role;
alter table t_user_roles
add constraint FKn3jfyu68eps3hj1bgy577lrfs
foreign key (user_id)
references t_user;
-- AUTH-SERVER
drop table if exists oauth_client_token;
create table oauth_client_token (
token_id VARCHAR(255),
token BYTEA,
authentication_id VARCHAR(255),
user_name VARCHAR(255),
client_id VARCHAR(255)
);
drop table if exists oauth_client_details;
CREATE TABLE oauth_client_details (
client_id varchar(255) NOT NULL,
resource_ids varchar(255) DEFAULT NULL,
client_secret varchar(255) DEFAULT NULL,
scope varchar(255) DEFAULT NULL,
authorized_grant_types varchar(255) DEFAULT NULL,
web_server_redirect_uri varchar(255) DEFAULT NULL,
authorities varchar(255) DEFAULT NULL,
access_token_validity integer DEFAULT NULL,
refresh_token_validity integer DEFAULT NULL,
additional_information varchar(255) DEFAULT NULL,
autoapprove varchar(255) DEFAULT NULL
);
drop table if exists oauth_access_token;
create table oauth_access_token (
token_id VARCHAR(255),
token BYTEA,
authentication_id VARCHAR(255),
user_name VARCHAR(255),
client_id VARCHAR(255),
authentication BYTEA,
refresh_token VARCHAR(255)
);
drop table if exists oauth_refresh_token;
create table oauth_refresh_token(
token_id VARCHAR(255),
token BYTEA,
authentication BYTEA
);
drop table if exists authority;
CREATE TABLE authority (
id integer,
authority varchar(255),
primary key (id)
);
drop table if exists credentials;
CREATE TABLE credentials (
id integer,
enabled boolean not null,
username varchar(255) not null,
password varchar(255) not null,
version integer,
primary key (id)
);
drop table if exists credentials_authorities;
CREATE TABLE credentials_authorities (
credentials_id bigint not null,
authorities_id bigint not null
);
drop table if exists oauth_code;
create table oauth_code (
code VARCHAR(255), authentication BYTEA
);
drop table if exists oauth_approvals;
create table oauth_approvals (
userId VARCHAR(255),
clientId VARCHAR(255),
scope VARCHAR(255),
status VARCHAR(10),
expiresAt DATE,
lastModifiedAt DATE
);
-- QUARTZ
drop table if exists qrtz_job_details CASCADE;
create table qrtz_job_details
(
sched_name varchar(120) not null,
job_name varchar(200) not null,
job_group varchar(200) not null,
description varchar(250),
job_class_name varchar(250) not null,
is_durable boolean not null,
is_nonconcurrent boolean not null,
is_update_data boolean not null,
requests_recovery boolean not null,
job_data bytea,
constraint qrtz_job_details_pkey
primary key (sched_name, job_name, job_group)
)
;
create index idx_qrtz_j_req_recovery
on qrtz_job_details (sched_name, requests_recovery)
;
create index idx_qrtz_j_grp
on qrtz_job_details (sched_name, job_group)
;
drop table if exists qrtz_triggers CASCADE;
create table qrtz_triggers
(
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
job_name varchar(200) not null,
job_group varchar(200) not null,
description varchar(250),
next_fire_time bigint,
prev_fire_time bigint,
priority integer,
trigger_state varchar(16) not null,
trigger_type varchar(8) not null,
start_time bigint not null,
end_time bigint,
calendar_name varchar(200),
misfire_instr smallint,
job_data bytea,
constraint qrtz_triggers_pkey
primary key (sched_name, trigger_name, trigger_group),
constraint qrtz_triggers_sched_name_fkey
foreign key (sched_name, job_name, job_group) references qrtz_job_details
)
;
create index idx_qrtz_t_j
on qrtz_triggers (sched_name, job_name, job_group)
;
create index idx_qrtz_t_jg
on qrtz_triggers (sched_name, job_group)
;
create index idx_qrtz_t_c
on qrtz_triggers (sched_name, calendar_name)
;
create index idx_qrtz_t_g
on qrtz_triggers (sched_name, trigger_group)
;
create index idx_qrtz_t_state
on qrtz_triggers (sched_name, trigger_state)
;
create index idx_qrtz_t_n_state
on qrtz_triggers (sched_name, trigger_name, trigger_group, trigger_state)
;
create index idx_qrtz_t_n_g_state
on qrtz_triggers (sched_name, trigger_group, trigger_state)
;
create index idx_qrtz_t_next_fire_time
on qrtz_triggers (sched_name, next_fire_time)
;
create index idx_qrtz_t_nft_st
on qrtz_triggers (sched_name, trigger_state, next_fire_time)
;
create index idx_qrtz_t_nft_misfire
on qrtz_triggers (sched_name, misfire_instr, next_fire_time)
;
create index idx_qrtz_t_nft_st_misfire
on qrtz_triggers (sched_name, misfire_instr, next_fire_time, trigger_state)
;
create index idx_qrtz_t_nft_st_misfire_grp
on qrtz_triggers (sched_name, misfire_instr, next_fire_time, trigger_group, trigger_state)
;
drop table if exists qrtz_simple_triggers CASCADE;
create table qrtz_simple_triggers
(
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
repeat_count bigint not null,
repeat_interval bigint not null,
times_triggered bigint not null,
constraint qrtz_simple_triggers_pkey
primary key (sched_name, trigger_name, trigger_group),
constraint qrtz_simple_triggers_sched_name_fkey
foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers
)
;
drop table if exists qrtz_cron_triggers CASCADE;
create table qrtz_cron_triggers
(
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
cron_expression varchar(120) not null,
time_zone_id varchar(80),
constraint qrtz_cron_triggers_pkey
primary key (sched_name, trigger_name, trigger_group),
constraint qrtz_cron_triggers_sched_name_fkey
foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers
)
;
drop table if exists qrtz_simprop_triggers CASCADE;
create table qrtz_simprop_triggers
(
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
str_prop_1 varchar(512),
str_prop_2 varchar(512),
str_prop_3 varchar(512),
int_prop_1 integer,
int_prop_2 integer,
long_prop_1 bigint,
long_prop_2 bigint,
dec_prop_1 numeric(13,4),
dec_prop_2 numeric(13,4),
bool_prop_1 boolean,
bool_prop_2 boolean,
constraint qrtz_simprop_triggers_pkey
primary key (sched_name, trigger_name, trigger_group),
constraint qrtz_simprop_triggers_sched_name_fkey
foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers
)
;
drop table if exists qrtz_blob_triggers CASCADE;
create table qrtz_blob_triggers
(
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
blob_data bytea,
constraint qrtz_blob_triggers_pkey
primary key (sched_name, trigger_name, trigger_group),
constraint qrtz_blob_triggers_sched_name_fkey
foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers
)
;
drop table if exists qrtz_calendars CASCADE;
create table qrtz_calendars
(
sched_name varchar(120) not null,
calendar_name varchar(200) not null,
calendar bytea not null,
constraint qrtz_calendars_pkey
primary key (sched_name, calendar_name)
)
;
drop table if exists qrtz_paused_trigger_grps CASCADE;
create table qrtz_paused_trigger_grps
(
sched_name varchar(120) not null,
trigger_group varchar(200) not null,
constraint qrtz_paused_trigger_grps_pkey
primary key (sched_name, trigger_group)
)
;
drop table if exists qrtz_fired_triggers CASCADE;
create table qrtz_fired_triggers
(
sched_name varchar(120) not null,
entry_id varchar(95) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
instance_name varchar(200) not null,
fired_time bigint not null,
sched_time bigint not null,
priority integer not null,
state varchar(16) not null,
job_name varchar(200),
job_group varchar(200),
is_nonconcurrent boolean,
requests_recovery boolean,
constraint qrtz_fired_triggers_pkey
primary key (sched_name, entry_id)
)
;
create index idx_qrtz_ft_trig_inst_name
on qrtz_fired_triggers (sched_name, instance_name)
;
create index idx_qrtz_ft_inst_job_req_rcvry
on qrtz_fired_triggers (sched_name, instance_name, requests_recovery)
;
create index idx_qrtz_ft_j_g
on qrtz_fired_triggers (sched_name, job_name, job_group)
;
create index idx_qrtz_ft_jg
on qrtz_fired_triggers (sched_name, job_group)
;
create index idx_qrtz_ft_t_g
on qrtz_fired_triggers (sched_name, trigger_name, trigger_group)
;
create index idx_qrtz_ft_tg
on qrtz_fired_triggers (sched_name, trigger_group)
;
drop table if exists qrtz_scheduler_state CASCADE;
create table qrtz_scheduler_state
(
sched_name varchar(120) not null,
instance_name varchar(200) not null,
last_checkin_time bigint not null,
checkin_interval bigint not null,
constraint qrtz_scheduler_state_pkey
primary key (sched_name, instance_name)
)
;
drop table if exists qrtz_locks CASCADE;
create table qrtz_locks
(
sched_name varchar(120) not null,
lock_name varchar(40) not null,
constraint qrtz_locks_pkey
primary key (sched_name, lock_name)
)
;
INSERT INTO authority VALUES(1,'ROLE_OAUTH_ADMIN');
INSERT INTO authority VALUES(2,'ROLE_RESOURCE_ADMIN');
INSERT INTO authority VALUES(3,'ROLE_API_ADMIN');
INSERT INTO credentials VALUES(1,true,'oauth_admin','$2a$10$TXYbtrgn5/6hO9xpd/bkPuUJ9abOxXzWrbRzlse0djMUO51vJ2h1i','0');
INSERT INTO credentials VALUES(2,true,'resource_admin','$2a$10$TXYbtrgn5/6hO9xpd/bkPuUJ9abOxXzWrbRzlse0djMUO51vJ2h1i','0');
INSERT INTO credentials VALUES(3,true,'regular_user','$2a$10$TXYbtrgn5/6hO9xpd/bkPuUJ9abOxXzWrbRzlse0djMUO51vJ2h1i','0');
--$2a$10$TXYbtrgn5/6hO9xpd/bkPuUJ9abOxXzWrbRzlse0djMUO51vJ2h1i = password
INSERT INTO credentials_authorities VALUES (1,1);
INSERT INTO credentials_authorities VALUES (2,2);
INSERT INTO credentials_authorities VALUES (3,3);
INSERT INTO oauth_client_details VALUES('curl_client','backend-bootstrap-api', '$2a$10$TXYbtrgn5/6hO9xpd/bkPuUJ9abOxXzWrbRzlse0djMUO51vJ2h1i', 'read,write', 'client_credentials,authorization_code,refresh_token,password', 'http://127.0.0.1:9091/callback', 'ROLE_API_ADMIN', 7200, 1200, NULL, 'true');
INSERT INTO T_ROLE(id,name) VALUES('f2ce1a80-b6c5-4b8c-a640-d8969958c385','ROLE_USER');
INSERT INTO T_ROLE(id,name) VALUES('c1e2d554-ffd2-4918-9a64-9a5c2e74d5e6','ROLE_ADMIN');
INSERT INTO t_user (id, create_time, create_user, create_userip, deleted, update_time, update_user, update_userip, version, birth_date, email, facebook_id, fcm_token_id, instagram_id, mobile_phone, name, password, twitter_id, user_name) VALUES ('9B18591A-C518-4CDE-BA3B-9ADC3145D677', parsedatetime('17-09-2012 18:47:52.69', 'dd-MM-yyyy hh:mm:ss.SS'), 'SYSTEM', '127.0.0.1', '0', parsedatetime('17-09-2012 18:47:52.69', 'dd-MM-yyyy hh:mm:ss.SS'), 'SYSTEM', '127.0.0.1', 0, parsedatetime('17-09-2012 18:47:52.69', 'dd-MM-yyyy hh:mm:ss.SS'), '[email protected]', 'fbid', 'fcmtknid', 'insid', '905553332211', 'Name Surname', '$2a$10$xn4D7VzCdkJd23URcQyrgupo/sEJEuwPEAyRA68n6AmHULXNCY3/e', 'twid', 'testuser');
INSERT INTO t_user_roles(user_id, role_id) VALUES('9B18591A-C518-4CDE-BA3B-9ADC3145D677','f2ce1a80-b6c5-4b8c-a640-d8969958c385');
commit;