-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbinit.sql
41 lines (27 loc) · 989 Bytes
/
dbinit.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
--
DROP TABLE users CASCADE;
DROP TABLE authorities CASCADE;
CREATE TABLE users (
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
shared_secret VARCHAR(255) NOT NULL,
enabled BOOLEAN NOT NULL,
two_factor_enabled BOOLEAN NOT NULL,
PRIMARY KEY (username)
);
CREATE TABLE authorities (
username VARCHAR(255) NOT NULL,
authority VARCHAR(255) NOT NULL,
PRIMARY KEY (username),
CONSTRAINT fk_user_authorities FOREIGN KEY (username) REFERENCES users (username)
);
-- TwoFAUser "user", has ROLE_USER
INSERT INTO users (username, password, shared_secret, enabled, two_factor_enabled)
VALUES ('user', '123456', 'X', TRUE, FALSE);
INSERT INTO authorities (username, authority)
VALUES ('user', 'ROLE_USER');
-- TwoFAUser "admin" has ROLE_ADMIN
INSERT INTO users (username, password, shared_secret, enabled, two_factor_enabled)
VALUES ('admin', '123456', 'X', TRUE, FALSE);
INSERT INTO authorities (username, authority)
VALUES ('admin', 'ROLE_ADMIN');