-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstructure.ddl
63 lines (63 loc) · 2.35 KB
/
structure.ddl
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
CREATE TABLE acl_privileges
(
roleId int unsigned NOT NULL,
module varchar(255) NOT NULL,
privilege varchar(255) NOT NULL
);
CREATE TABLE acl_roles
(
id int unsigned NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
created timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id, name)
);
CREATE TABLE acl_usersToRoles
(
userId bigint unsigned NOT NULL,
roleId int unsigned NOT NULL,
PRIMARY KEY (userId, roleId)
);
CREATE TABLE auth
(
userId bigint unsigned NOT NULL,
provider varchar(255) NOT NULL,
foreignKey varchar(255) NOT NULL,
token varchar(64) NOT NULL,
tokenSecret varchar(64) NOT NULL,
tokenType char(8) NOT NULL,
created timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (provider, foreignKey)
);
CREATE TABLE pages
(
id int unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT,
title longtext NOT NULL,
alias varchar(255) NOT NULL,
content longtext,
keywords longtext,
description longtext,
created timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated timestamp DEFAULT '0000-00-00 00:00:00' NOT NULL,
userId bigint unsigned
);;
CREATE TABLE users
(
id bigint unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT,
login varchar(255),
password varchar(32),
email text,
created timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated timestamp DEFAULT '0000-00-00 00:00:00' NOT NULL,
status char(8) DEFAULT 'disabled' NOT NULL
);
ALTER TABLE acl_privileges ADD FOREIGN KEY ( roleId ) REFERENCES acl_roles ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
CREATE UNIQUE INDEX role_privilege ON acl_privileges ( roleId, module, privilege );
CREATE UNIQUE INDEX unique_name ON acl_roles ( name );
ALTER TABLE acl_usersToRoles ADD FOREIGN KEY ( roleId ) REFERENCES acl_roles ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE acl_usersToRoles ADD FOREIGN KEY ( userId ) REFERENCES users ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE auth ADD FOREIGN KEY ( userId ) REFERENCES users ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
CREATE UNIQUE INDEX UNIQUE_user_provider ON auth ( userId, provider );
ALTER TABLE pages ADD FOREIGN KEY ( userId ) REFERENCES users ( id ) ON DELETE CASCADE ON UPDATE CASCADE;
CREATE UNIQUE INDEX `unique` ON pages ( alias );
CREATE INDEX FK_pages_to_users ON pages ( userId );
CREATE UNIQUE INDEX UNIQUE_login ON users ( login );