· 8 years ago · Mar 16, 2018, 10:54 AM
1# --- Created by Ebean DDL
2# To stop Ebean DDL generation, remove this comment and start using Evolutions
3
4# --- !Ups
5
6create table account_status (
7 id bigserial not null,
8 code integer,
9 title varchar(255),
10 platform_user_id bigint,
11 account_id bigint,
12 r_version bigint not null,
13 when_created timestamptz not null,
14 when_updated timestamptz not null,
15 constraint uq_account_status_account_id unique (account_id),
16 constraint pk_account_status primary key (id)
17);
18
19create table account_type (
20 id bigserial not null,
21 code integer,
22 title varchar(255),
23 platform_user_id bigint,
24 account_id bigint,
25 r_version bigint not null,
26 when_created timestamptz not null,
27 when_updated timestamptz not null,
28 constraint uq_account_type_account_id unique (account_id),
29 constraint pk_account_type primary key (id)
30);
31
32create table accounts (
33 id bigserial not null,
34 platform_user_id bigint,
35 number varchar(255),
36 account_type_id bigint,
37 account_status_id bigint,
38 balance float,
39 activation_date timestamptz,
40 expire_date timestamptz,
41 r_version bigint not null,
42 when_created timestamptz not null,
43 when_updated timestamptz not null,
44 constraint uq_accounts_account_type_id unique (account_type_id),
45 constraint uq_accounts_account_status_id unique (account_status_id),
46 constraint pk_accounts primary key (id)
47);
48
49create table city (
50 id bigserial not null,
51 name varchar(255),
52 region_id bigint,
53 platform_user_id bigint,
54 r_version bigint not null,
55 when_created timestamptz not null,
56 when_updated timestamptz not null,
57 constraint pk_city primary key (id)
58);
59
60create table contract_status (
61 id bigserial not null,
62 code integer not null,
63 title varchar(255),
64 platform_user_id bigint,
65 contract_id bigint,
66 r_version bigint not null,
67 when_created timestamptz not null,
68 when_updated timestamptz not null,
69 constraint uq_contract_status_contract_id unique (contract_id),
70 constraint pk_contract_status primary key (id)
71);
72
73create table contract_type (
74 id bigserial not null,
75 code integer not null,
76 title varchar(255),
77 platform_user_id bigint,
78 contract_id bigint,
79 r_version bigint not null,
80 when_created timestamptz not null,
81 when_updated timestamptz not null,
82 constraint uq_contract_type_contract_id unique (contract_id),
83 constraint pk_contract_type primary key (id)
84);
85
86create table contracts (
87 id bigserial not null,
88 contract_type_id bigint,
89 contract_status_id bigint,
90 contract_start_date timestamptz,
91 contract_end_date timestamptz,
92 contract_number varchar(255),
93 contract_currency_id bigint,
94 contract_amount float not null,
95 platform_user_id bigint,
96 r_version bigint not null,
97 when_created timestamptz not null,
98 when_updated timestamptz not null,
99 constraint uq_contracts_contract_type_id unique (contract_type_id),
100 constraint uq_contracts_contract_status_id unique (contract_status_id),
101 constraint pk_contracts primary key (id)
102);
103
104create table country (
105 id bigserial not null,
106 name varchar(255),
107 platform_user_id bigint,
108 r_version bigint not null,
109 when_created timestamptz not null,
110 when_updated timestamptz not null,
111 constraint pk_country primary key (id)
112);
113
114create table currency (
115 id bigserial not null,
116 platform_user_id bigint,
117 currency_type_id bigint,
118 r_version bigint not null,
119 when_created timestamptz not null,
120 when_updated timestamptz not null,
121 constraint uq_currency_currency_type_id unique (currency_type_id),
122 constraint pk_currency primary key (id)
123);
124
125create table currency_type (
126 id bigserial not null,
127 code integer not null,
128 title varchar(255),
129 currency_id bigint,
130 r_version bigint not null,
131 when_created timestamptz not null,
132 when_updated timestamptz not null,
133 constraint uq_currency_type_currency_id unique (currency_id),
134 constraint pk_currency_type primary key (id)
135);
136
137create table gallery (
138 id bigserial not null,
139 status_id bigint,
140 type_id bigint,
141 comment_approval boolean default false not null,
142 title varchar(255),
143 platform_user_id bigint,
144 r_version bigint not null,
145 when_created timestamptz not null,
146 when_updated timestamptz not null,
147 constraint uq_gallery_status_id unique (status_id),
148 constraint uq_gallery_type_id unique (type_id),
149 constraint pk_gallery primary key (id)
150);
151
152create table gallery_photo (
153 id bigserial not null,
154 gallery_status_id bigint,
155 gallery_type_id bigint,
156 gallery_id bigint,
157 comments_approval boolean default false not null,
158 link varchar(255),
159 platform_user_id bigint,
160 r_version bigint not null,
161 when_created timestamptz not null,
162 when_updated timestamptz not null,
163 constraint pk_gallery_photo primary key (id)
164);
165
166create table gallery_status (
167 id bigserial not null,
168 code integer not null,
169 title varchar(255),
170 platform_user_id bigint,
171 gallery_id bigint,
172 r_version bigint not null,
173 when_created timestamptz not null,
174 when_updated timestamptz not null,
175 constraint uq_gallery_status_gallery_id unique (gallery_id),
176 constraint pk_gallery_status primary key (id)
177);
178
179create table gallery_type (
180 id bigserial not null,
181 code integer not null,
182 title varchar(255),
183 platform_user_id bigint,
184 gallery_id bigint,
185 r_version bigint not null,
186 when_created timestamptz not null,
187 when_updated timestamptz not null,
188 constraint uq_gallery_type_gallery_id unique (gallery_id),
189 constraint pk_gallery_type primary key (id)
190);
191
192create table group_permissions (
193 id bigserial not null,
194 title varchar(255),
195 platform_user_id bigint,
196 r_version bigint not null,
197 when_created timestamptz not null,
198 when_updated timestamptz not null,
199 constraint pk_group_permissions primary key (id)
200);
201
202create table group_status (
203 id bigserial not null,
204 code integer,
205 title varchar(255),
206 platform_user_id bigint,
207 group_id bigint,
208 r_version bigint not null,
209 when_created timestamptz not null,
210 when_updated timestamptz not null,
211 constraint uq_group_status_group_id unique (group_id),
212 constraint pk_group_status primary key (id)
213);
214
215create table group_type (
216 id bigserial not null,
217 code integer,
218 title varchar(255),
219 platform_user_id bigint,
220 group_id bigint,
221 r_version bigint not null,
222 when_created timestamptz not null,
223 when_updated timestamptz not null,
224 constraint uq_group_type_group_id unique (group_id),
225 constraint pk_group_type primary key (id)
226);
227
228create table groups (
229 id bigserial not null,
230 parent_group_id bigint,
231 group_name varchar(255),
232 platform_user_id bigint,
233 r_version bigint not null,
234 when_created timestamptz not null,
235 when_updated timestamptz not null,
236 constraint pk_groups primary key (id)
237);
238
239create table groups_group_permissions (
240 groups_id bigint not null,
241 group_permissions_id bigint not null,
242 constraint pk_groups_group_permissions primary key (groups_id,group_permissions_id)
243);
244
245create table groups_roles (
246 groups_id bigint not null,
247 roles_id bigint not null,
248 constraint pk_groups_roles primary key (groups_id,roles_id)
249);
250
251create table permissions (
252 id bigserial not null,
253 description varchar(255),
254 platform_user_id bigint,
255 r_version bigint not null,
256 when_created timestamptz not null,
257 when_updated timestamptz not null,
258 constraint pk_permissions primary key (id)
259);
260
261create table permissions_roles (
262 permissions_id bigint not null,
263 roles_id bigint not null,
264 constraint pk_permissions_roles primary key (permissions_id,roles_id)
265);
266
267create table platform_user (
268 id bigserial not null,
269 status_id bigint,
270 type_id bigint,
271 name varchar(255),
272 gallery_id integer,
273 parent_user_id bigint,
274 telephone_number varchar(255),
275 email varchar(255),
276 password varchar(255),
277 photo_url varchar(255),
278 role_status_id bigint,
279 r_version bigint not null,
280 when_created timestamptz not null,
281 when_updated timestamptz not null,
282 constraint uq_platform_user_status_id unique (status_id),
283 constraint uq_platform_user_type_id unique (type_id),
284 constraint uq_platform_user_role_status_id unique (role_status_id),
285 constraint pk_platform_user primary key (id)
286);
287
288create table platform_user_roles (
289 platform_user_id bigint not null,
290 roles_id bigint not null,
291 constraint pk_platform_user_roles primary key (platform_user_id,roles_id)
292);
293
294create table region (
295 id bigserial not null,
296 name varchar(255),
297 country_id bigint,
298 platform_user_id bigint,
299 r_version bigint not null,
300 when_created timestamptz not null,
301 when_updated timestamptz not null,
302 constraint pk_region primary key (id)
303);
304
305create table role_status (
306 id bigserial not null,
307 code integer,
308 title varchar(255),
309 platform_user_id bigint,
310 role_id bigint,
311 r_version bigint not null,
312 when_created timestamptz not null,
313 when_updated timestamptz not null,
314 constraint uq_role_status_platform_user_id unique (platform_user_id),
315 constraint uq_role_status_role_id unique (role_id),
316 constraint pk_role_status primary key (id)
317);
318
319create table role_type (
320 id bigserial not null,
321 code integer,
322 title varchar(255),
323 platform_user_id bigint,
324 role_type_id bigint,
325 r_version bigint not null,
326 when_created timestamptz not null,
327 when_updated timestamptz not null,
328 constraint uq_role_type_role_type_id unique (role_type_id),
329 constraint pk_role_type primary key (id)
330);
331
332create table roles (
333 id bigserial not null,
334 role_name varchar(255),
335 role_type_id bigint,
336 role_status_id bigint,
337 platform_user_id bigint,
338 r_version bigint not null,
339 when_created timestamptz not null,
340 when_updated timestamptz not null,
341 constraint uq_roles_role_type_id unique (role_type_id),
342 constraint uq_roles_role_status_id unique (role_status_id),
343 constraint pk_roles primary key (id)
344);
345
346create table roles_groups (
347 roles_id bigint not null,
348 groups_id bigint not null,
349 constraint pk_roles_groups primary key (roles_id,groups_id)
350);
351
352create table roles_permissions (
353 roles_id bigint not null,
354 permissions_id bigint not null,
355 constraint pk_roles_permissions primary key (roles_id,permissions_id)
356);
357
358create table user_status (
359 id bigserial not null,
360 code integer,
361 title varchar(255),
362 platform_user_id bigint,
363 r_version bigint not null,
364 when_created timestamptz not null,
365 when_updated timestamptz not null,
366 constraint uq_user_status_platform_user_id unique (platform_user_id),
367 constraint pk_user_status primary key (id)
368);
369
370create table user_type (
371 id bigserial not null,
372 code integer,
373 title varchar(255),
374 platform_user_id bigint,
375 r_version bigint not null,
376 when_created timestamptz not null,
377 when_updated timestamptz not null,
378 constraint uq_user_type_platform_user_id unique (platform_user_id),
379 constraint pk_user_type primary key (id)
380);
381
382create index ix_account_status_id on account_status (id);
383create index ix_account_type_id on account_type (id);
384create index ix_accounts_id on accounts (id);
385create index ix_city_id on city (id);
386create index ix_contract_status_id on contract_status (id);
387create index ix_contract_type_id on contract_type (id);
388create index ix_contracts_id on contracts (id);
389create index ix_country_id on country (id);
390create index ix_currency_id on currency (id);
391create index ix_currency_type_id on currency_type (id);
392create index ix_gallery_id on gallery (id);
393create index ix_gallery_photo_id on gallery_photo (id);
394create index ix_gallery_status_id on gallery_status (id);
395create index ix_gallery_type_id on gallery_type (id);
396create index ix_group_permissions_id on group_permissions (id);
397create index ix_group_status_id on group_status (id);
398create index ix_group_type_id on group_type (id);
399create index ix_groups_id on groups (id);
400create index ix_permissions_id on permissions (id);
401create index ix_platform_user_id on platform_user (id);
402create index ix_region_id on region (id);
403create index ix_role_status_id on role_status (id);
404create index ix_role_type_id on role_type (id);
405create index ix_roles_id on roles (id);
406create index ix_user_status_id on user_status (id);
407create index ix_user_type_id on user_type (id);
408alter table account_status add constraint fk_account_status_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
409create index ix_account_status_platform_user_id on account_status (platform_user_id);
410
411alter table account_status add constraint fk_account_status_account_id foreign key (account_id) references accounts (id) on delete restrict on update restrict;
412
413alter table account_type add constraint fk_account_type_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
414create index ix_account_type_platform_user_id on account_type (platform_user_id);
415
416alter table account_type add constraint fk_account_type_account_id foreign key (account_id) references accounts (id) on delete restrict on update restrict;
417
418alter table accounts add constraint fk_accounts_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
419create index ix_accounts_platform_user_id on accounts (platform_user_id);
420
421alter table accounts add constraint fk_accounts_account_type_id foreign key (account_type_id) references account_type (id) on delete restrict on update restrict;
422
423alter table accounts add constraint fk_accounts_account_status_id foreign key (account_status_id) references account_status (id) on delete restrict on update restrict;
424
425alter table city add constraint fk_city_region_id foreign key (region_id) references region (id) on delete restrict on update restrict;
426create index ix_city_region_id on city (region_id);
427
428alter table city add constraint fk_city_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
429create index ix_city_platform_user_id on city (platform_user_id);
430
431alter table contract_status add constraint fk_contract_status_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
432create index ix_contract_status_platform_user_id on contract_status (platform_user_id);
433
434alter table contract_status add constraint fk_contract_status_contract_id foreign key (contract_id) references contracts (id) on delete restrict on update restrict;
435
436alter table contract_type add constraint fk_contract_type_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
437create index ix_contract_type_platform_user_id on contract_type (platform_user_id);
438
439alter table contract_type add constraint fk_contract_type_contract_id foreign key (contract_id) references contracts (id) on delete restrict on update restrict;
440
441alter table contracts add constraint fk_contracts_contract_type_id foreign key (contract_type_id) references contract_type (id) on delete restrict on update restrict;
442
443alter table contracts add constraint fk_contracts_contract_status_id foreign key (contract_status_id) references contract_status (id) on delete restrict on update restrict;
444
445alter table contracts add constraint fk_contracts_contract_currency_id foreign key (contract_currency_id) references currency (id) on delete restrict on update restrict;
446create index ix_contracts_contract_currency_id on contracts (contract_currency_id);
447
448alter table contracts add constraint fk_contracts_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
449create index ix_contracts_platform_user_id on contracts (platform_user_id);
450
451alter table country add constraint fk_country_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
452create index ix_country_platform_user_id on country (platform_user_id);
453
454alter table currency add constraint fk_currency_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
455create index ix_currency_platform_user_id on currency (platform_user_id);
456
457alter table currency add constraint fk_currency_currency_type_id foreign key (currency_type_id) references currency_type (id) on delete restrict on update restrict;
458
459alter table currency_type add constraint fk_currency_type_currency_id foreign key (currency_id) references currency (id) on delete restrict on update restrict;
460
461alter table gallery add constraint fk_gallery_status_id foreign key (status_id) references gallery_status (id) on delete restrict on update restrict;
462
463alter table gallery add constraint fk_gallery_type_id foreign key (type_id) references gallery_type (id) on delete restrict on update restrict;
464
465alter table gallery add constraint fk_gallery_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
466create index ix_gallery_platform_user_id on gallery (platform_user_id);
467
468alter table gallery_photo add constraint fk_gallery_photo_gallery_status_id foreign key (gallery_status_id) references gallery_status (id) on delete restrict on update restrict;
469create index ix_gallery_photo_gallery_status_id on gallery_photo (gallery_status_id);
470
471alter table gallery_photo add constraint fk_gallery_photo_gallery_type_id foreign key (gallery_type_id) references gallery_type (id) on delete restrict on update restrict;
472create index ix_gallery_photo_gallery_type_id on gallery_photo (gallery_type_id);
473
474alter table gallery_photo add constraint fk_gallery_photo_gallery_id foreign key (gallery_id) references gallery (id) on delete restrict on update restrict;
475create index ix_gallery_photo_gallery_id on gallery_photo (gallery_id);
476
477alter table gallery_photo add constraint fk_gallery_photo_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
478create index ix_gallery_photo_platform_user_id on gallery_photo (platform_user_id);
479
480alter table gallery_status add constraint fk_gallery_status_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
481create index ix_gallery_status_platform_user_id on gallery_status (platform_user_id);
482
483alter table gallery_status add constraint fk_gallery_status_gallery_id foreign key (gallery_id) references gallery (id) on delete restrict on update restrict;
484
485alter table gallery_type add constraint fk_gallery_type_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
486create index ix_gallery_type_platform_user_id on gallery_type (platform_user_id);
487
488alter table gallery_type add constraint fk_gallery_type_gallery_id foreign key (gallery_id) references gallery (id) on delete restrict on update restrict;
489
490alter table group_permissions add constraint fk_group_permissions_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
491create index ix_group_permissions_platform_user_id on group_permissions (platform_user_id);
492
493alter table group_status add constraint fk_group_status_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
494create index ix_group_status_platform_user_id on group_status (platform_user_id);
495
496alter table group_status add constraint fk_group_status_group_id foreign key (group_id) references groups (id) on delete restrict on update restrict;
497
498alter table group_type add constraint fk_group_type_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
499create index ix_group_type_platform_user_id on group_type (platform_user_id);
500
501alter table group_type add constraint fk_group_type_group_id foreign key (group_id) references groups (id) on delete restrict on update restrict;
502
503alter table groups add constraint fk_groups_parent_group_id foreign key (parent_group_id) references groups (id) on delete restrict on update restrict;
504create index ix_groups_parent_group_id on groups (parent_group_id);
505
506alter table groups add constraint fk_groups_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
507create index ix_groups_platform_user_id on groups (platform_user_id);
508
509alter table groups_group_permissions add constraint fk_groups_group_permissions_groups foreign key (groups_id) references groups (id) on delete restrict on update restrict;
510create index ix_groups_group_permissions_groups on groups_group_permissions (groups_id);
511
512alter table groups_group_permissions add constraint fk_groups_group_permissions_group_permissions foreign key (group_permissions_id) references group_permissions (id) on delete restrict on update restrict;
513create index ix_groups_group_permissions_group_permissions on groups_group_permissions (group_permissions_id);
514
515alter table groups_roles add constraint fk_groups_roles_groups foreign key (groups_id) references groups (id) on delete restrict on update restrict;
516create index ix_groups_roles_groups on groups_roles (groups_id);
517
518alter table groups_roles add constraint fk_groups_roles_roles foreign key (roles_id) references roles (id) on delete restrict on update restrict;
519create index ix_groups_roles_roles on groups_roles (roles_id);
520
521alter table permissions add constraint fk_permissions_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
522create index ix_permissions_platform_user_id on permissions (platform_user_id);
523
524alter table permissions_roles add constraint fk_permissions_roles_permissions foreign key (permissions_id) references permissions (id) on delete restrict on update restrict;
525create index ix_permissions_roles_permissions on permissions_roles (permissions_id);
526
527alter table permissions_roles add constraint fk_permissions_roles_roles foreign key (roles_id) references roles (id) on delete restrict on update restrict;
528create index ix_permissions_roles_roles on permissions_roles (roles_id);
529
530alter table platform_user add constraint fk_platform_user_status_id foreign key (status_id) references user_status (id) on delete restrict on update restrict;
531
532alter table platform_user add constraint fk_platform_user_type_id foreign key (type_id) references user_type (id) on delete restrict on update restrict;
533
534alter table platform_user add constraint fk_platform_user_parent_user_id foreign key (parent_user_id) references platform_user (id) on delete restrict on update restrict;
535create index ix_platform_user_parent_user_id on platform_user (parent_user_id);
536
537alter table platform_user add constraint fk_platform_user_role_status_id foreign key (role_status_id) references role_status (id) on delete restrict on update restrict;
538
539alter table platform_user_roles add constraint fk_platform_user_roles_platform_user foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
540create index ix_platform_user_roles_platform_user on platform_user_roles (platform_user_id);
541
542alter table platform_user_roles add constraint fk_platform_user_roles_roles foreign key (roles_id) references roles (id) on delete restrict on update restrict;
543create index ix_platform_user_roles_roles on platform_user_roles (roles_id);
544
545alter table region add constraint fk_region_country_id foreign key (country_id) references country (id) on delete restrict on update restrict;
546create index ix_region_country_id on region (country_id);
547
548alter table region add constraint fk_region_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
549create index ix_region_platform_user_id on region (platform_user_id);
550
551alter table role_status add constraint fk_role_status_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
552
553alter table role_status add constraint fk_role_status_role_id foreign key (role_id) references roles (id) on delete restrict on update restrict;
554
555alter table role_type add constraint fk_role_type_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
556create index ix_role_type_platform_user_id on role_type (platform_user_id);
557
558alter table role_type add constraint fk_role_type_role_type_id foreign key (role_type_id) references role_type (id) on delete restrict on update restrict;
559
560alter table roles add constraint fk_roles_role_type_id foreign key (role_type_id) references role_type (id) on delete restrict on update restrict;
561
562alter table roles add constraint fk_roles_role_status_id foreign key (role_status_id) references role_status (id) on delete restrict on update restrict;
563
564alter table roles add constraint fk_roles_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
565create index ix_roles_platform_user_id on roles (platform_user_id);
566
567alter table roles_groups add constraint fk_roles_groups_roles foreign key (roles_id) references roles (id) on delete restrict on update restrict;
568create index ix_roles_groups_roles on roles_groups (roles_id);
569
570alter table roles_groups add constraint fk_roles_groups_groups foreign key (groups_id) references groups (id) on delete restrict on update restrict;
571create index ix_roles_groups_groups on roles_groups (groups_id);
572
573alter table roles_permissions add constraint fk_roles_permissions_roles foreign key (roles_id) references roles (id) on delete restrict on update restrict;
574create index ix_roles_permissions_roles on roles_permissions (roles_id);
575
576alter table roles_permissions add constraint fk_roles_permissions_permissions foreign key (permissions_id) references permissions (id) on delete restrict on update restrict;
577create index ix_roles_permissions_permissions on roles_permissions (permissions_id);
578
579alter table user_status add constraint fk_user_status_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
580
581alter table user_type add constraint fk_user_type_platform_user_id foreign key (platform_user_id) references platform_user (id) on delete restrict on update restrict;
582
583
584# --- !Downs
585
586alter table if exists account_status drop constraint if exists fk_account_status_platform_user_id;
587drop index if exists ix_account_status_platform_user_id;
588
589alter table if exists account_status drop constraint if exists fk_account_status_account_id;
590
591alter table if exists account_type drop constraint if exists fk_account_type_platform_user_id;
592drop index if exists ix_account_type_platform_user_id;
593
594alter table if exists account_type drop constraint if exists fk_account_type_account_id;
595
596alter table if exists accounts drop constraint if exists fk_accounts_platform_user_id;
597drop index if exists ix_accounts_platform_user_id;
598
599alter table if exists accounts drop constraint if exists fk_accounts_account_type_id;
600
601alter table if exists accounts drop constraint if exists fk_accounts_account_status_id;
602
603alter table if exists city drop constraint if exists fk_city_region_id;
604drop index if exists ix_city_region_id;
605
606alter table if exists city drop constraint if exists fk_city_platform_user_id;
607drop index if exists ix_city_platform_user_id;
608
609alter table if exists contract_status drop constraint if exists fk_contract_status_platform_user_id;
610drop index if exists ix_contract_status_platform_user_id;
611
612alter table if exists contract_status drop constraint if exists fk_contract_status_contract_id;
613
614alter table if exists contract_type drop constraint if exists fk_contract_type_platform_user_id;
615drop index if exists ix_contract_type_platform_user_id;
616
617alter table if exists contract_type drop constraint if exists fk_contract_type_contract_id;
618
619alter table if exists contracts drop constraint if exists fk_contracts_contract_type_id;
620
621alter table if exists contracts drop constraint if exists fk_contracts_contract_status_id;
622
623alter table if exists contracts drop constraint if exists fk_contracts_contract_currency_id;
624drop index if exists ix_contracts_contract_currency_id;
625
626alter table if exists contracts drop constraint if exists fk_contracts_platform_user_id;
627drop index if exists ix_contracts_platform_user_id;
628
629alter table if exists country drop constraint if exists fk_country_platform_user_id;
630drop index if exists ix_country_platform_user_id;
631
632alter table if exists currency drop constraint if exists fk_currency_platform_user_id;
633drop index if exists ix_currency_platform_user_id;
634
635alter table if exists currency drop constraint if exists fk_currency_currency_type_id;
636
637alter table if exists currency_type drop constraint if exists fk_currency_type_currency_id;
638
639alter table if exists gallery drop constraint if exists fk_gallery_status_id;
640
641alter table if exists gallery drop constraint if exists fk_gallery_type_id;
642
643alter table if exists gallery drop constraint if exists fk_gallery_platform_user_id;
644drop index if exists ix_gallery_platform_user_id;
645
646alter table if exists gallery_photo drop constraint if exists fk_gallery_photo_gallery_status_id;
647drop index if exists ix_gallery_photo_gallery_status_id;
648
649alter table if exists gallery_photo drop constraint if exists fk_gallery_photo_gallery_type_id;
650drop index if exists ix_gallery_photo_gallery_type_id;
651
652alter table if exists gallery_photo drop constraint if exists fk_gallery_photo_gallery_id;
653drop index if exists ix_gallery_photo_gallery_id;
654
655alter table if exists gallery_photo drop constraint if exists fk_gallery_photo_platform_user_id;
656drop index if exists ix_gallery_photo_platform_user_id;
657
658alter table if exists gallery_status drop constraint if exists fk_gallery_status_platform_user_id;
659drop index if exists ix_gallery_status_platform_user_id;
660
661alter table if exists gallery_status drop constraint if exists fk_gallery_status_gallery_id;
662
663alter table if exists gallery_type drop constraint if exists fk_gallery_type_platform_user_id;
664drop index if exists ix_gallery_type_platform_user_id;
665
666alter table if exists gallery_type drop constraint if exists fk_gallery_type_gallery_id;
667
668alter table if exists group_permissions drop constraint if exists fk_group_permissions_platform_user_id;
669drop index if exists ix_group_permissions_platform_user_id;
670
671alter table if exists group_status drop constraint if exists fk_group_status_platform_user_id;
672drop index if exists ix_group_status_platform_user_id;
673
674alter table if exists group_status drop constraint if exists fk_group_status_group_id;
675
676alter table if exists group_type drop constraint if exists fk_group_type_platform_user_id;
677drop index if exists ix_group_type_platform_user_id;
678
679alter table if exists group_type drop constraint if exists fk_group_type_group_id;
680
681alter table if exists groups drop constraint if exists fk_groups_parent_group_id;
682drop index if exists ix_groups_parent_group_id;
683
684alter table if exists groups drop constraint if exists fk_groups_platform_user_id;
685drop index if exists ix_groups_platform_user_id;
686
687alter table if exists groups_group_permissions drop constraint if exists fk_groups_group_permissions_groups;
688drop index if exists ix_groups_group_permissions_groups;
689
690alter table if exists groups_group_permissions drop constraint if exists fk_groups_group_permissions_group_permissions;
691drop index if exists ix_groups_group_permissions_group_permissions;
692
693alter table if exists groups_roles drop constraint if exists fk_groups_roles_groups;
694drop index if exists ix_groups_roles_groups;
695
696alter table if exists groups_roles drop constraint if exists fk_groups_roles_roles;
697drop index if exists ix_groups_roles_roles;
698
699alter table if exists permissions drop constraint if exists fk_permissions_platform_user_id;
700drop index if exists ix_permissions_platform_user_id;
701
702alter table if exists permissions_roles drop constraint if exists fk_permissions_roles_permissions;
703drop index if exists ix_permissions_roles_permissions;
704
705alter table if exists permissions_roles drop constraint if exists fk_permissions_roles_roles;
706drop index if exists ix_permissions_roles_roles;
707
708alter table if exists platform_user drop constraint if exists fk_platform_user_status_id;
709
710alter table if exists platform_user drop constraint if exists fk_platform_user_type_id;
711
712alter table if exists platform_user drop constraint if exists fk_platform_user_parent_user_id;
713drop index if exists ix_platform_user_parent_user_id;
714
715alter table if exists platform_user drop constraint if exists fk_platform_user_role_status_id;
716
717alter table if exists platform_user_roles drop constraint if exists fk_platform_user_roles_platform_user;
718drop index if exists ix_platform_user_roles_platform_user;
719
720alter table if exists platform_user_roles drop constraint if exists fk_platform_user_roles_roles;
721drop index if exists ix_platform_user_roles_roles;
722
723alter table if exists region drop constraint if exists fk_region_country_id;
724drop index if exists ix_region_country_id;
725
726alter table if exists region drop constraint if exists fk_region_platform_user_id;
727drop index if exists ix_region_platform_user_id;
728
729alter table if exists role_status drop constraint if exists fk_role_status_platform_user_id;
730
731alter table if exists role_status drop constraint if exists fk_role_status_role_id;
732
733alter table if exists role_type drop constraint if exists fk_role_type_platform_user_id;
734drop index if exists ix_role_type_platform_user_id;
735
736alter table if exists role_type drop constraint if exists fk_role_type_role_type_id;
737
738alter table if exists roles drop constraint if exists fk_roles_role_type_id;
739
740alter table if exists roles drop constraint if exists fk_roles_role_status_id;
741
742alter table if exists roles drop constraint if exists fk_roles_platform_user_id;
743drop index if exists ix_roles_platform_user_id;
744
745alter table if exists roles_groups drop constraint if exists fk_roles_groups_roles;
746drop index if exists ix_roles_groups_roles;
747
748alter table if exists roles_groups drop constraint if exists fk_roles_groups_groups;
749drop index if exists ix_roles_groups_groups;
750
751alter table if exists roles_permissions drop constraint if exists fk_roles_permissions_roles;
752drop index if exists ix_roles_permissions_roles;
753
754alter table if exists roles_permissions drop constraint if exists fk_roles_permissions_permissions;
755drop index if exists ix_roles_permissions_permissions;
756
757alter table if exists user_status drop constraint if exists fk_user_status_platform_user_id;
758
759alter table if exists user_type drop constraint if exists fk_user_type_platform_user_id;
760
761drop table if exists account_status cascade;
762
763drop table if exists account_type cascade;
764
765drop table if exists accounts cascade;
766
767drop table if exists city cascade;
768
769drop table if exists contract_status cascade;
770
771drop table if exists contract_type cascade;
772
773drop table if exists contracts cascade;
774
775drop table if exists country cascade;
776
777drop table if exists currency cascade;
778
779drop table if exists currency_type cascade;
780
781drop table if exists gallery cascade;
782
783drop table if exists gallery_photo cascade;
784
785drop table if exists gallery_status cascade;
786
787drop table if exists gallery_type cascade;
788
789drop table if exists group_permissions cascade;
790
791drop table if exists group_status cascade;
792
793drop table if exists group_type cascade;
794
795drop table if exists groups cascade;
796
797drop table if exists groups_group_permissions cascade;
798
799drop table if exists groups_roles cascade;
800
801drop table if exists permissions cascade;
802
803drop table if exists permissions_roles cascade;
804
805drop table if exists platform_user cascade;
806
807drop table if exists platform_user_roles cascade;
808
809drop table if exists region cascade;
810
811drop table if exists role_status cascade;
812
813drop table if exists role_type cascade;
814
815drop table if exists roles cascade;
816
817drop table if exists roles_groups cascade;
818
819drop table if exists roles_permissions cascade;
820
821drop table if exists user_status cascade;
822
823drop table if exists user_type cascade;
824
825drop index if exists ix_account_status_id;
826drop index if exists ix_account_type_id;
827drop index if exists ix_accounts_id;
828drop index if exists ix_city_id;
829drop index if exists ix_contract_status_id;
830drop index if exists ix_contract_type_id;
831drop index if exists ix_contracts_id;
832drop index if exists ix_country_id;
833drop index if exists ix_currency_id;
834drop index if exists ix_currency_type_id;
835drop index if exists ix_gallery_id;
836drop index if exists ix_gallery_photo_id;
837drop index if exists ix_gallery_status_id;
838drop index if exists ix_gallery_type_id;
839drop index if exists ix_group_permissions_id;
840drop index if exists ix_group_status_id;
841drop index if exists ix_group_type_id;
842drop index if exists ix_groups_id;
843drop index if exists ix_permissions_id;
844drop index if exists ix_platform_user_id;
845drop index if exists ix_region_id;
846drop index if exists ix_role_status_id;
847drop index if exists ix_role_type_id;
848drop index if exists ix_roles_id;
849drop index if exists ix_user_status_id;
850drop index if exists ix_user_type_id;