1 |
drop database if exists yakka; |
2 |
create database yakka; |
3 |
use yakka; |
4 |
|
5 |
create table if not exists yakka_users ( |
6 |
user_id int(10) auto_increment, |
7 |
user_tag varchar(128) not null, |
8 |
|
9 |
user_name varchar(128) not null default '', |
10 |
user_username varchar(128) not null, |
11 |
user_password varchar(32) not null, |
12 |
user_email varchar(128), |
13 |
user_page_id int(10), |
14 |
|
15 |
user_create_user_tag varchar(128), |
16 |
user_modify_user_tag varchar(128), |
17 |
user_create_date datetime not null default '0000-00-00 00:00:00', |
18 |
user_modify_date datetime not null default '0000-00-00 00:00:00', |
19 |
|
20 |
primary key pk_user (user_id), |
21 |
unique key udx_tag (user_tag), |
22 |
unique key udx_signature (user_username, user_password) |
23 |
) type=myisam; |
24 |
|
25 |
create table if not exists yakka_roles ( |
26 |
role_id int(10) auto_increment, |
27 |
role_tag varchar(128) not null, |
28 |
|
29 |
role_name varchar(128) not null default '', |
30 |
role_comment text, |
31 |
|
32 |
role_create_user_tag varchar(128), |
33 |
role_modify_user_tag varchar(128), |
34 |
role_create_date datetime not null default '0000-00-00 00:00:00', |
35 |
role_modify_date datetime not null default '0000-00-00 00:00:00', |
36 |
|
37 |
primary key pk_role (role_id), |
38 |
unique key udx_tag (role_tag) |
39 |
) type=myisam; |
40 |
|
41 |
create table if not exists yakka_user_role_asgs ( |
42 |
uras_id int(10) auto_increment, |
43 |
|
44 |
uras_user_id int(10) not null, |
45 |
uras_role_id int(10) not null, |
46 |
|
47 |
uras_create_user_tag varchar(128), |
48 |
uras_modify_user_tag varchar(128), |
49 |
uras_create_date datetime not null default '0000-00-00 00:00:00', |
50 |
uras_modify_date datetime not null default '0000-00-00 00:00:00', |
51 |
|
52 |
primary key pk_uras (uras_id), |
53 |
unique key udx_assignment (uras_user_id, uras_role_id) |
54 |
) type=myisam; |
55 |
|
56 |
create table if not exists yakka_pages ( |
57 |
page_id int(10) auto_increment, |
58 |
page_tag varchar(128) not null, |
59 |
|
60 |
page_name varchar(128) not null default '', |
61 |
page_source text not null, |
62 |
page_comment text, |
63 |
page_version varchar(32) not null default '0.0.0.0', |
64 |
page_is_latest_flag enum('Y','N') not null default 'Y', |
65 |
|
66 |
page_create_user_tag varchar(128), |
67 |
page_modify_user_tag varchar(128), |
68 |
page_create_date datetime not null default '0000-00-00 00:00:00', |
69 |
page_modify_date datetime not null default '0000-00-00 00:00:00', |
70 |
|
71 |
primary key pk_page (page_id), |
72 |
fulltext key idx_text (page_tag, page_name, page_source, page_comment), |
73 |
|
74 |
key idx_tag (page_tag), |
75 |
key idx_version (page_version), |
76 |
key idx_creator (page_create_user_tag), |
77 |
key idx_modifier (page_modify_user_tag) |
78 |
) type=myisam; |
79 |
|
80 |
create table if not exists yakka_permissions ( |
81 |
perm_id int(10) auto_increment, |
82 |
|
83 |
perm_object_tag varchar(128) not null, |
84 |
perm_object_type varchar(128) not null, |
85 |
|
86 |
perm_privilege varchar(32) not null, |
87 |
|
88 |
perm_create_user_tag varchar(128), |
89 |
perm_modify_user_tag varchar(128), |
90 |
perm_create_date datetime not null default '0000-00-00 00:00:00', |
91 |
perm_modify_date datetime not null default '0000-00-00 00:00:00', |
92 |
|
93 |
primary key pk_perm (perm_id), |
94 |
unique key udx_object_permission (perm_object_tag, perm_object_type, perm_privilege), |
95 |
|
96 |
key idx_object (perm_object_tag, perm_object_type) |
97 |
) type=myisam; |
98 |
|
99 |
create table if not exists yakka_permission_grants ( |
100 |
pgra_id int(10) auto_increment, |
101 |
|
102 |
pgra_perm_id int(10) not null, |
103 |
|
104 |
pgra_accessor_tag varchar(128) not null, |
105 |
pgra_accessor_type varchar(128) not null, |
106 |
|
107 |
pgra_create_user_tag varchar(128), |
108 |
pgra_modify_user_tag varchar(128), |
109 |
pgra_create_date datetime not null default '0000-00-00 00:00:00', |
110 |
pgra_modify_date datetime not null default '0000-00-00 00:00:00', |
111 |
|
112 |
primary key pk_pgra (pgra_id), |
113 |
unique key udx_grant (pgra_perm_id, pgra_accessor_tag, pgra_accessor_type), |
114 |
|
115 |
key idx_accessor (pgra_accessor_tag, pgra_accessor_type) |
116 |
) type=myisam; |
117 |
|
118 |
create table if not exists yakka_permission_revokes ( |
119 |
prev_id int(10) auto_increment, |
120 |
|
121 |
prev_perm_id int(10) not null, |
122 |
|
123 |
prev_accessor_tag varchar(128) not null, |
124 |
prev_accessor_type varchar(128) not null, |
125 |
|
126 |
prev_create_user_tag varchar(128), |
127 |
prev_modify_user_tag varchar(128), |
128 |
prev_create_date datetime not null default '0000-00-00 00:00:00', |
129 |
prev_modify_date datetime not null default '0000-00-00 00:00:00', |
130 |
|
131 |
primary key pk_prev (prev_id), |
132 |
unique key udx_revoke (prev_perm_id, prev_accessor_tag, prev_accessor_type), |
133 |
|
134 |
key idx_accessor (prev_accessor_tag, prev_accessor_type) |
135 |
) type=myisam; |
136 |
|
137 |
insert into yakka_users values ( |
138 |
1, 'SystemUser', 'System', 'system', 'system', null, null, 'YakkaSystem', 'YakkaSystem', now(), now() |
139 |
); |
140 |
|
141 |
insert into yakka_users values ( |
142 |
2, 'AdminUser', 'Administrator', 'admin', 'admin', null, null, 'YakkaSystem', 'YakkaSystem', now(), now() |
143 |
); |
144 |
|
145 |
insert into yakka_users values ( |
146 |
3, 'AnonymousUser', 'Anonymous', 'anonymous', 'anonymous', null, null, 'YakkaSystem', 'YakkaSystem', now(), now() |
147 |
); |
148 |
|
149 |
insert into yakka_roles values ( |
150 |
1, 'SystemRole', 'System', null, 'YakkaSystem', 'YakkaSystem', now(), now() |
151 |
); |
152 |
|
153 |
insert into yakka_roles values ( |
154 |
2, 'AdminRole', 'Administrators', null, 'YakkaSystem', 'YakkaSystem', now(), now() |
155 |
); |
156 |
|
157 |
insert into yakka_roles values ( |
158 |
3, 'AnonymousRole', 'Anonymous Users', null, 'YakkaSystem', 'YakkaSystem', now(), now() |
159 |
); |
160 |
|
161 |
insert into yakka_roles values ( |
162 |
4, 'EveryoneRole', 'Everyone', null, 'YakkaSystem', 'YakkaSystem', now(), now() |
163 |
); |
164 |
|
165 |
insert into yakka_user_role_asgs values ( |
166 |
1, 2, 2, 'YakkaSystem', 'YakkaSystem', now(), now() |
167 |
); |
168 |
|
169 |
insert into yakka_user_role_asgs values ( |
170 |
2, 3, 3, 'YakkaSystem', 'YakkaSystem', now(), now() |
171 |
); |
172 |
|
173 |
insert into yakka_user_role_asgs values ( |
174 |
3, 2, 4, 'YakkaSystem', 'YakkaSystem', now(), now() |
175 |
); |
176 |
|
177 |
insert into yakka_user_role_asgs values ( |
178 |
4, 3, 4, 'YakkaSystem', 'YakkaSystem', now(), now() |
179 |
); |
180 |
|
181 |
insert into yakka_pages values ( |
182 |
1, |
183 |
'HomePage', |
184 |
'Yakka Homepage', |
185 |
'====Welcome to the Home of Yakka====\n\nThis is the starting page of your new YakkaWiki application. **Enjoy!**', |
186 |
'Automagically created...', |
187 |
'0.1.0', |
188 |
'Y', |
189 |
'YakkaSystem', |
190 |
'YakkaSystem', |
191 |
now(), |
192 |
now() |
193 |
); |
194 |
|
195 |
insert into yakka_permissions values ( |
196 |
1, '?', 'YakkaPage', 'read', 'YakkaSystem', 'YakkaSystem', now(), now() |
197 |
); |
198 |
|
199 |
insert into yakka_permissions values ( |
200 |
2, '?', 'YakkaPage', 'write', 'YakkaSystem', 'YakkaSystem', now(), now() |
201 |
); |
202 |
|
203 |
insert into yakka_permissions values ( |
204 |
3, '?', 'YakkaPage', 'create', 'YakkaSystem', 'YakkaSystem', now(), now() |
205 |
); |
206 |
|
207 |
insert into yakka_permission_grants values ( |
208 |
1, 1, 'EveryoneRole', 'YakkaRole', 'YakkaSystem', 'YakkaSystem', now(), now() |
209 |
); |
210 |
|
211 |
insert into yakka_permission_grants values ( |
212 |
2, 2, 'EveryoneRole', 'YakkaRole', 'YakkaSystem', 'YakkaSystem', now(), now() |
213 |
); |
214 |
|
215 |
insert into yakka_permission_grants values ( |
216 |
3, 3, 'EveryoneRole', 'YakkaRole', 'YakkaSystem', 'YakkaSystem', now(), now() |
217 |
); |