Deliver centralized role management feature
[portal.git] / ecomp-portal-DB-common / EcompPortalDDLMySql_1710_Common.sql
1 -- ---------------------------------------------------------------------------------------------------------------
2 -- This is the 1710 Open Source Version of Ecomp Portal database called portal
3 -- based on 1707 Open Source Version and  Ecomp Portal database called portal 
4
5 -- note to : database admin,  set the mysql system variable called lower_case_table_names
6 --              it can be set 3 different ways: 
7 --                      command-line options (cmd-line), 
8 --                      options valid in configuration files (option file), or 
9 --                      server system variables (system var). 
10
11 -- it needs to be set to 1, then table names are stored in lowercase on disk and comparisons are not case sensitive. 
12 --                          MySql/MariaDB Version compatibility information
13 -- bash-4.2$ mysql --version  – cluster version
14 -- mysql  Ver 15.1 Distrib 10.1.17-MariaDB, for Linux (x86_64) using readline 5.1
15
16 -- All versions newer or older than these DO NOT necessarily mean they are compatible.
17 -- -----------------------------------------------------------------------------------------------------------------
18 set foreign_key_checks=1; 
19
20 create database portal;
21
22 use portal;
23
24 -- ------------------ create table section
25 --
26 -- name: cr_favorite_reports; type: table
27 --
28 create table cr_favorite_reports (
29     user_id integer not null,
30     rep_id integer not null
31 );
32 --
33 -- name: cr_filehist_log; type: table
34 --
35 create table cr_filehist_log (
36     schedule_id numeric(11,0) not null,
37     url character varying(4000),
38     notes character varying(3500),
39     run_time timestamp
40 );
41 --
42 -- name: cr_folder; type: table
43 --
44 create table cr_folder (
45     folder_id integer not null,
46     folder_name character varying(50) not null,
47     descr character varying(500),
48     create_id integer not null,
49     create_date timestamp not null,
50     parent_folder_id integer,
51     public_yn character varying(1) default 'n' not null
52 );
53 --
54 -- name: cr_folder_access; type: table
55 --
56 create table cr_folder_access (
57     folder_access_id numeric(11,0) not null,
58     folder_id numeric(11,0) not null,
59     order_no numeric(11,0) not null,
60     role_id numeric(11,0),
61     user_id numeric(11,0),
62     read_only_yn character varying(1) default 'n' not null
63 );
64 --
65 -- name: cr_hist_user_map; type: table
66 --
67 create table cr_hist_user_map (
68     hist_id int(11) not null,
69     user_id int(11) not null
70 );
71 --
72 -- name: cr_lu_file_type; type: table
73 --
74 create table cr_lu_file_type (
75     lookup_id numeric(2,0) not null,
76     lookup_descr character varying(255) not null,
77     active_yn character(1) default 'y',
78     error_code numeric(11,0)
79 );
80 --
81 -- name: cr_raptor_action_img; type: table
82 --
83 create table cr_raptor_action_img (
84     image_id character varying(100) not null,
85     image_loc character varying(400)
86 );
87 --
88 -- name: cr_raptor_pdf_img; type: table
89 --
90 create table cr_raptor_pdf_img (
91     image_id character varying(100) not null,
92     image_loc character varying(400)
93 );
94 --
95 -- name: cr_remote_schema_info; type: table
96 --
97 create table cr_remote_schema_info (
98     schema_prefix character varying(5) not null,
99     schema_desc character varying(75) not null,
100     datasource_type character varying(100)
101 );
102 --
103 -- name: cr_report; type: table
104 --
105 create table cr_report (
106     rep_id numeric(11,0) not null,
107     title character varying(100) not null,
108     descr character varying(255),
109     public_yn character varying(1) default 'n' not null,
110     report_xml text,
111     create_id numeric(11,0),
112     create_date timestamp default now(),
113     maint_id numeric(11,0),
114     maint_date timestamp default now(), 
115     menu_id character varying(500),
116     menu_approved_yn character varying(1) default 'n' not null,
117     owner_id numeric(11,0),
118     folder_id integer default 0,
119     dashboard_type_yn character varying(1) default 'n',
120     dashboard_yn character varying(1) default 'n'
121 );
122 --
123 -- name: cr_report_access; type: table
124 --
125 create table cr_report_access (
126     rep_id numeric(11,0) not null,
127     order_no numeric(11,0) not null,
128     role_id numeric(11,0),
129     user_id numeric(11,0),
130     read_only_yn character varying(1) default 'n' not null
131 );
132 --
133 -- name: cr_report_dwnld_log; type: table
134 --
135 create table cr_report_dwnld_log (
136     user_id numeric(11,0) not null,
137     rep_id integer not null,
138     file_name character varying(100) not null,
139     dwnld_start_time timestamp default now() not null,
140     record_ready_time timestamp default now(),
141     filter_params character varying(2000)
142 );
143 --
144 -- name: cr_report_email_sent_log; type: table
145 --
146 create table cr_report_email_sent_log (
147     log_id integer not null,
148     schedule_id numeric(11,0),
149     gen_key character varying(25) not null,
150     rep_id numeric(11,0) not null,
151     user_id numeric(11,0),
152     sent_date timestamp default now(),
153     access_flag character varying(1) default 'y' not null,
154     touch_date timestamp default now()
155 );
156 --
157 -- name: cr_report_file_history; type: table
158 --
159 create table cr_report_file_history (
160     hist_id int(11) not null,
161     sched_user_id numeric(11,0) not null,
162     schedule_id numeric(11,0) not null,
163     user_id numeric(11,0) not null,
164     rep_id numeric(11,0),
165     run_date timestamp,
166     recurrence character varying(50),
167     file_type_id numeric(2,0),
168     file_name character varying(80),
169     file_blob blob,
170     file_size numeric(11,0),
171     raptor_url character varying(4000),
172     error_yn character(1) default 'n',
173     error_code numeric(11,0),
174     deleted_yn character(1) default 'n',
175     deleted_by numeric(38,0)
176 );
177 --
178 -- name: cr_report_log; type: table
179 --
180 create table cr_report_log (
181     rep_id numeric(11,0) not null,
182     log_time timestamp not null,
183     user_id numeric(11,0) not null,
184     action character varying(2000) not null,
185     action_value character varying(50),
186     form_fields character varying(4000)
187 );
188 --
189 -- name: cr_report_schedule; type: table
190 --
191 create table cr_report_schedule (
192     schedule_id numeric(11,0) not null,
193     sched_user_id numeric(11,0) not null,
194     rep_id numeric(11,0) not null,
195     enabled_yn character varying(1) not null,
196     start_date timestamp default now(),
197     end_date timestamp default now(),
198     run_date timestamp default now(),
199     recurrence character varying(50),
200     conditional_yn character varying(1) not null,
201     condition_sql character varying(4000),
202     notify_type integer default 0,
203     max_row integer default 1000,
204     initial_formfields character varying(3500),
205     processed_formfields character varying(3500),
206     formfields character varying(3500),
207     condition_large_sql text,
208     encrypt_yn character(1) default 'n',
209     attachment_yn character(1) default 'y'
210 );
211 --
212 -- name: cr_report_schedule_users; type: table
213 --
214 create table cr_report_schedule_users (
215     schedule_id numeric(11,0) not null,
216     rep_id numeric(11,0) not null,
217     user_id numeric(11,0) not null,
218     role_id numeric(11,0),
219     order_no numeric(11,0) not null
220 );
221 --
222 -- name: cr_report_template_map; type: table
223 --
224 create table cr_report_template_map (
225     report_id integer not null,
226     template_file character varying(200)
227 );
228 --
229 -- name: cr_schedule_activity_log; type: table
230 --
231 create table cr_schedule_activity_log (
232     schedule_id numeric(11,0) not null,
233     url character varying(4000),
234     notes character varying(2000),
235     run_time timestamp
236 );
237 --
238 -- name: cr_table_join; type: table
239 --
240 create table cr_table_join (
241     src_table_name character varying(30) not null,
242     dest_table_name character varying(30) not null,
243     join_expr character varying(500) not null
244 );
245 --
246 -- name: cr_table_role; type: table
247 --
248 create table cr_table_role (
249     table_name character varying(30) not null,
250     role_id numeric(11,0) not null
251 );
252 --
253 -- name: cr_table_source; type: table
254 --
255 create table cr_table_source (
256     table_name character varying(30) not null,
257     display_name character varying(30) not null,
258     pk_fields character varying(200),
259     web_view_action character varying(50),
260     large_data_source_yn character varying(1) default 'n' not null,
261     filter_sql character varying(4000),
262     source_db character varying(50)
263 );
264 --
265 -- name: fn_lu_timezone; type: table
266 --
267 create table fn_lu_timezone (
268     timezone_id int(11) not null,
269     timezone_name character varying(100) not null,
270     timezone_value character varying(100) not null
271 );
272
273 create table fn_user (
274     user_id int(11) not null primary key  auto_increment,
275     org_id int(11),
276     manager_id int(11),
277     first_name character varying(50),
278     middle_name character varying(50),
279     last_name character varying(50),
280     phone character varying(25),
281     fax character varying(25),
282     cellular character varying(25),
283     email character varying(50),
284     address_id numeric(11,0),
285     alert_method_cd character varying(10),
286     hrid character varying(20),
287     org_user_id CHARACTER VARYING(20),
288     org_code character varying(30),
289     login_id character varying(25),
290     login_pwd character varying(100),
291     last_login_date timestamp,
292     active_yn character varying(1) default 'y' not null,
293     created_id int(11),
294     created_date timestamp default now(),
295     modified_id int(11),
296     modified_date timestamp default now(),
297     is_internal_yn character(1) default 'n' not null,
298     address_line_1 character varying(100),
299     address_line_2 character varying(100),
300     city character varying(50),
301     state_cd character varying(3),
302     zip_code character varying(11),
303     country_cd character varying(3),
304     location_clli character varying(8),
305     org_manager_userid CHARACTER VARYING(20),
306     company character varying(100),
307     department_name character varying(100),
308     job_title character varying(100),
309     timezone int(11),
310     department character varying(25),
311     business_unit character varying(25),
312     business_unit_name character varying(100),
313     cost_center character varying(25),
314     fin_loc_code character varying(10),
315     silo_status character varying(10)
316 );
317 --
318 -- name: fn_role; type: table
319 --
320 create table fn_role (
321     role_id int(11) not null primary key auto_increment,
322     role_name character varying(300) not null,
323     active_yn character varying(1) default 'y' not null,
324     priority numeric(4,0),
325     app_id int(11) default null,
326     app_role_id int(11) default null
327
328 );
329 --
330 -- name: fn_audit_action; type: table
331 --
332 create table fn_audit_action (
333     audit_action_id integer not null,
334     class_name character varying(500) not null,
335     method_name character varying(50) not null,
336     audit_action_cd character varying(20) not null,
337     audit_action_desc character varying(200),
338     active_yn character varying(1)
339 );
340 --
341 -- name: fn_audit_action_log; type: table
342 --
343 create table fn_audit_action_log (
344     audit_log_id integer not null primary key  auto_increment,
345     audit_action_cd character varying(200),
346     action_time timestamp,
347     user_id numeric(11,0),
348     class_name character varying(100),
349     method_name character varying(50),
350     success_msg character varying(20),
351     error_msg character varying(500)
352 );
353 --
354 -- name: fn_lu_activity; type: table
355 --
356 create table fn_lu_activity (
357     activity_cd character varying(50) not null primary key,
358     activity character varying(50) not null
359 );
360 --
361 -- name: fn_audit_log; type: table
362 --
363 create table fn_audit_log (
364     log_id int(11) not null primary key auto_increment,
365     user_id int(11) not null,
366     activity_cd character varying(50) not null,
367     audit_date timestamp default now() not null,
368     comments character varying(1000),
369     affected_record_id_bk character varying(500),
370     affected_record_id character varying(4000),
371     constraint fk_fn_audit_ref_209_fn_user foreign key (user_id) references fn_user(user_id)
372 );
373 --
374 -- name: fn_broadcast_message; type: table
375 --
376 create table fn_broadcast_message (
377     message_id int(11) not null primary key auto_increment,
378     message_text character varying(1000) not null,
379     message_location_id numeric(11,0) not null,
380     broadcast_start_date timestamp not null  default now(),
381     broadcast_end_date timestamp not null default now(),
382     active_yn character(1) default 'y' not null,
383     sort_order numeric(4,0) not null,
384     broadcast_site_cd character varying(50)
385 );
386 --
387 -- name: fn_chat_logs; type: table
388 --
389 create table fn_chat_logs (
390     chat_log_id integer not null,
391     chat_room_id integer,
392     user_id integer,
393     message character varying(1000),
394     message_date_time timestamp
395 );
396 --
397 -- name: fn_chat_room; type: table
398 --
399 create table fn_chat_room (
400     chat_room_id integer not null,
401     name character varying(50) not null,
402     description character varying(500),
403     owner_id integer,
404     created_date timestamp default now(),
405     updated_date timestamp default now()
406 );
407 --
408 -- name: fn_chat_users; type: table
409 --
410 create table fn_chat_users (
411     chat_room_id integer,
412     user_id integer,
413     last_activity_date_time timestamp,
414     chat_status character varying(20),
415     id integer not null
416 );
417 --
418 -- name: fn_datasource; type: table
419 --
420 create table fn_datasource (
421     id integer not null primary key auto_increment,
422     name character varying(50),
423     driver_name character varying(256),
424     server character varying(256),
425     port integer,
426     user_name character varying(256),
427     password character varying(256),
428     url character varying(256),
429     min_pool_size integer,
430     max_pool_size integer,
431     adapter_id integer,
432     ds_type character varying(20)
433 );
434 --
435 -- name: fn_function; type: table
436 --
437 create table fn_function (
438     function_cd character varying(30) not null primary key,
439     function_name character varying(50) not null
440 );
441 --
442 -- name: fn_lu_alert_method; type: table
443 --
444 create table fn_lu_alert_method (
445     alert_method_cd character varying(10) not null,
446     alert_method character varying(50) not null
447 );
448 --
449 -- name: fn_lu_broadcast_site; type: table
450 --
451 create table fn_lu_broadcast_site (
452     broadcast_site_cd character varying(50) not null,
453     broadcast_site_descr character varying(100)
454 );
455 --
456 -- name: fn_lu_menu_set; type: table
457 --
458 create table fn_lu_menu_set (
459     menu_set_cd character varying(10) not null primary key,
460     menu_set_name character varying(50) not null
461 );
462 --
463 -- name: fn_lu_priority; type: table
464 --
465 create table fn_lu_priority (
466     priority_id numeric(11,0) not null,
467     priority character varying(50) not null,
468     active_yn character(1) not null,
469     sort_order numeric(5,0)
470 );
471 --
472 -- name: fn_lu_role_type; type: table
473 --
474 create table fn_lu_role_type (
475     role_type_id numeric(11,0) not null,
476     role_type character varying(50) not null
477 );
478 --
479 -- name: fn_lu_tab_set; type: table
480 --
481 create table fn_lu_tab_set (
482     tab_set_cd character varying(30) not null,
483     tab_set_name character varying(50) not null
484 );
485 --
486 -- name: fn_menu; type: table
487 --
488 create table fn_menu (
489     menu_id int(11) not null primary key auto_increment,
490     label character varying(100),
491     parent_id int(11),
492     sort_order numeric(4,0),
493     action character varying(200),
494     function_cd character varying(30),
495     active_yn character varying(1) default 'y' not null,
496     servlet character varying(50),
497     query_string character varying(200),
498     external_url character varying(200),
499     target character varying(25),
500     menu_set_cd character varying(10) default 'app',
501     separator_yn character(1) default 'n',
502     image_src character varying(100),
503     constraint fk_fn_menu_ref_196_fn_menu foreign key (parent_id) references fn_menu(menu_id),
504     constraint fk_fn_menu_menu_set_cd foreign key (menu_set_cd) references fn_lu_menu_set(menu_set_cd),
505     constraint fk_fn_menu_ref_223_fn_funct foreign key (function_cd) references fn_function(function_cd)
506 );
507 --
508 -- name: fn_org; type: table
509 --
510 create table fn_org (
511     org_id int(11) not null,
512     org_name character varying(50) not null,
513     access_cd character varying(10)
514 );
515 --
516 -- name: fn_restricted_url; type: table
517 --
518 create table fn_restricted_url (
519     restricted_url character varying(250) not null,
520     function_cd character varying(30) not null
521 );
522 --
523 -- name: fn_role_composite; type: table
524 --
525 create table fn_role_composite (
526     parent_role_id int(11) not null,
527     child_role_id int(11) not null,
528     constraint fk_fn_role_composite_child foreign key (child_role_id) references fn_role(role_id),
529     constraint fk_fn_role_composite_parent foreign key (parent_role_id) references fn_role(role_id)
530 );
531 --
532 -- name: fn_role_function; type: table
533 --
534 create table fn_role_function (
535     role_id int(11) not null,
536     function_cd character varying(30) not null,
537     constraint fk_fn_role__ref_198_fn_role foreign key (role_id) references fn_role(role_id)
538 );
539 --
540 -- name: fn_tab; type: table
541 --
542 create table fn_tab (
543     tab_cd character varying(30) not null,
544     tab_name character varying(50) not null,
545     tab_descr character varying(100),
546     action character varying(100) not null,
547     function_cd character varying(30) not null,
548     active_yn character(1) not null,
549     sort_order numeric(11,0) not null,
550     parent_tab_cd character varying(30),
551     tab_set_cd character varying(30)
552 );
553 --
554 -- name: fn_tab_selected; type: table
555 --
556 create table fn_tab_selected (
557     selected_tab_cd character varying(30) not null,
558     tab_uri character varying(40) not null
559 );
560 --
561 -- name: fn_user_pseudo_role; type: table
562 --
563 create table fn_user_pseudo_role (
564     pseudo_role_id int(11) not null,
565     user_id int(11) not null
566 );
567 --
568 -- name: fn_user_role; type: table
569 --
570 create table fn_user_role (
571     user_id int(10) not null,
572     role_id int(10) not null,
573     priority numeric(4,0),
574     app_id int(11) default 2,
575     constraint fk_fn_user__ref_172_fn_user foreign key (user_id) references fn_user(user_id),
576     constraint fk_fn_user__ref_175_fn_role foreign key (role_id) references fn_role(role_id)
577 );
578 --
579 -- name: schema_info; type: table
580 --
581 create table schema_info (
582     SCHEMA_ID CHARACTER VARYING(25) not null,
583     SCHEMA_DESC CHARACTER VARYING(75) not null,
584     DATASOURCE_TYPE CHARACTER VARYING(100),
585     CONNECTION_URL VARCHAR(200) not null,
586     USER_NAME VARCHAR(45) not null,
587     PASSWORD VARCHAR(45) null default null,
588     DRIVER_CLASS VARCHAR(100) not null,
589     MIN_POOL_SIZE INT not null,
590     MAX_POOL_SIZE INT not null,
591     IDLE_CONNECTION_TEST_PERIOD INT not null
592
593 );
594 -- ----------------------------------------------------------
595 -- name: fn_app; type: table
596 -- ----------------------------------------------------------
597 create table fn_app (
598   app_id int(11) primary key not null auto_increment,
599   app_name varchar(100) not null default '?',
600   app_image_url varchar(256) default null,
601   app_description varchar(512) default null,
602   app_notes varchar(4096) default null,
603   app_url varchar(256) default null,
604   app_alternate_url varchar(256) default null,
605   app_rest_endpoint varchar(2000) default null,
606   ml_app_name varchar(50) not null default '?',
607   ml_app_admin_id varchar(7) not null default '?',
608   mots_id int(11) default null,
609   app_password varchar(256) not null default '?',
610   open char(1) default 'N',
611   enabled char(1) default 'Y',
612   thumbnail mediumblob null default null,
613   app_username varchar(50),
614   ueb_key varchar(256) default null,
615   ueb_secret varchar(256) default null,
616   ueb_topic_name varchar(256) default null,
617   app_type int(11) not null default 1,
618   auth_central char(1) not null default 'N',
619   auth_namespace varchar(100) null default null
620 );
621
622 -- ------------------ functional menu tables -------------------
623 --
624 -- table structure for table fn_menu_functional
625 --
626 create table fn_menu_functional (
627   menu_id int(11) not null auto_increment,
628   column_num int(2) not null,
629   text varchar(100) not null,
630   parent_menu_id int(11) default null,
631   url varchar(128) not null default '',
632   active_yn varchar(1) not null default 'y',
633   image_src varchar(100) default null,
634   primary key (menu_id),
635   key fk_fn_menu_func_parent_menu_id_idx (parent_menu_id),
636   constraint fk_fn_menu_func_parent_menu_id foreign key (parent_menu_id) references fn_menu_functional (menu_id) on delete no action on update no action
637 );
638 --
639 -- table structure for table fn_menu_functional_ancestors
640 --
641
642 create table fn_menu_functional_ancestors (
643   id int(11) not null auto_increment,
644   menu_id int(11) not null,
645   ancestor_menu_id int(11) not null,
646   depth int(2) not null,
647   primary key (id),
648   key fk_fn_menu_func_anc_menu_id_idx (menu_id),
649   key fk_fn_menu_func_anc_anc_menu_id_idx (ancestor_menu_id),
650   constraint fk_fn_menu_func_anc_anc_menu_id foreign key (ancestor_menu_id) references fn_menu_functional (menu_id) on delete no action on update no action,
651   constraint fk_fn_menu_func_anc_menu_id foreign key (menu_id) references fn_menu_functional (menu_id) on delete no action on update no action
652 );
653 --
654 -- table structure for table fn_menu_functional_roles
655 --
656 create table fn_menu_functional_roles (
657   id int(11) not null auto_increment,
658   menu_id int(11) not null,
659   app_id int(11) not null,
660   role_id int(10) not null,
661   primary key (id),
662   key fk_fn_menu_func_roles_menu_id_idx (menu_id),
663   key fk_fn_menu_func_roles_app_id_idx (app_id),
664   key fk_fn_menu_func_roles_role_id_idx (role_id),
665   constraint fk_fn_menu_func_roles_app_id foreign key (app_id) references fn_app (app_id) on delete no action on update no action,
666   constraint fk_fn_menu_func_roles_menu_id foreign key (menu_id) references fn_menu_functional (menu_id) on delete no action on update no action,
667   constraint fk_fn_menu_func_roles_role_id foreign key (role_id) references fn_role (role_id) on delete no action on update no action
668 );
669 -- ----------------------------------------------------------
670 -- NAME: FN_WORKFLOW; TYPE: TABLE
671 -- ----------------------------------------------------------
672 create table fn_workflow (
673   id mediumint(9) not null auto_increment,
674   name varchar(20) not null,
675   description varchar(500) default null,
676   run_link varchar(300) default null,
677   suspend_link varchar(300) default null,
678   modified_link varchar(300) default null,
679   active_yn varchar(300) default null,
680   created varchar(300) default null,
681   created_by int(11) default null,
682   modified varchar(300) default null,
683   modified_by int(11) default null,
684   workflow_key varchar(50) default null,
685   primary key (id),
686   UNIQUE KEY name (name)
687 );
688
689
690 -- ----------------------------------------------------------
691 -- NAME: FN_SCHEDULE_WORKFLOWS; TYPE: TABLE
692 -- ----------------------------------------------------------
693 create table fn_schedule_workflows (
694   id_schedule_workflows bigint(25) primary key not null auto_increment, 
695   workflow_server_url varchar(45) default null,
696   workflow_key varchar(45) not null,
697   workflow_arguments varchar(45) default null,
698   startDateTimeCron varchar(45) default null,
699   endDateTime TIMESTAMP default NOW(),
700   start_date_time TIMESTAMP default NOW(),
701   recurrence varchar(45) default null
702   );
703
704
705 -- ----------------------------------------------------------
706 -- NAME: FN_SHARED_CONTEXT; TYPE: TABLE
707 -- ----------------------------------------------------------  
708 create table fn_shared_context (
709     id int(11) not null auto_increment,
710     create_time timestamp not null,
711     context_id character varying(64) not null,
712     ckey character varying(128) not null,
713         cvalue character varying(1024),
714         primary key (id),
715         UNIQUE KEY session_key (context_id, ckey) );
716
717         
718 -- ----------------------------------------------------------
719 -- NAME: FN_QZ_JOB_DETAILS; TYPE: TABLE
720 -- ----------------------------------------------------------
721 create table fn_qz_job_details (
722 SCHED_NAME VARCHAR(120) not null,
723 JOB_NAME VARCHAR(200) not null,
724 JOB_GROUP VARCHAR(200) not null,
725 DESCRIPTION VARCHAR(250) null,
726 JOB_CLASS_NAME VARCHAR(250) not null,
727 IS_DURABLE VARCHAR(1) not null,
728 IS_NONCONCURRENT VARCHAR(1) not null,
729 IS_UPDATE_DATA VARCHAR(1) not null,
730 REQUESTS_RECOVERY VARCHAR(1) not null,
731 JOB_DATA BLOB null,
732 primary key (SCHED_NAME,JOB_NAME,JOB_GROUP)
733 );
734   
735 -- ----------------------------------------------------------
736 -- NAME: FN_QZ_TRIGGERS; TYPE: TABLE
737 -- ----------------------------------------------------------
738 create table fn_qz_triggers (
739 SCHED_NAME VARCHAR(120) not null,
740 TRIGGER_NAME VARCHAR(200) not null,
741 TRIGGER_GROUP VARCHAR(200) not null,
742 JOB_NAME VARCHAR(200) not null,
743 JOB_GROUP VARCHAR(200) not null,
744 DESCRIPTION VARCHAR(250) null,
745 NEXT_FIRE_TIME BIGINT(13) null,
746 PREV_FIRE_TIME BIGINT(13) null,
747 PRIORITY INTEGER null,
748 TRIGGER_STATE VARCHAR(16) not null,
749 TRIGGER_TYPE VARCHAR(8) not null,
750 START_TIME BIGINT(13) not null,
751 END_TIME BIGINT(13) null,
752 CALENDAR_NAME VARCHAR(200) null,
753 MISFIRE_INSTR SMALLINT(2) null,
754 JOB_DATA BLOB null,
755 primary key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
756 FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
757 REFERENCES FN_QZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP)
758 );
759   
760 -- ----------------------------------------------------------
761 -- NAME: FN_QZ_SIMPLE_TRIGGERS; TYPE: TABLE
762 -- ----------------------------------------------------------
763 create table fn_qz_simple_triggers (
764 SCHED_NAME VARCHAR(120) not null,
765 TRIGGER_NAME VARCHAR(200) not null,
766 TRIGGER_GROUP VARCHAR(200) not null,
767 REPEAT_COUNT BIGINT(7) not null,
768 REPEAT_INTERVAL BIGINT(12) not null,
769 TIMES_TRIGGERED BIGINT(10) not null,
770 primary key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
771 FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
772 REFERENCES FN_QZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
773 );
774   
775 -- ----------------------------------------------------------
776 -- NAME: FN_QZ_CRON_TRIGGERS; TYPE: TABLE
777 -- ----------------------------------------------------------
778 create table fn_qz_cron_triggers (
779 SCHED_NAME VARCHAR(120) not null,
780 TRIGGER_NAME VARCHAR(200) not null,
781 TRIGGER_GROUP VARCHAR(200) not null,
782 CRON_EXPRESSION VARCHAR(120) not null,
783 TIME_ZONE_ID VARCHAR(80),
784 primary key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
785 FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
786 REFERENCES FN_QZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
787 );
788   
789 -- ----------------------------------------------------------
790 -- NAME: FN_QZ_SIMPROP_TRIGGERS; TYPE: TABLE
791 -- ----------------------------------------------------------
792 create table fn_qz_simprop_triggers (          
793     SCHED_NAME VARCHAR(120) not null,
794     TRIGGER_NAME VARCHAR(200) not null,
795     TRIGGER_GROUP VARCHAR(200) not null,
796     STR_PROP_1 VARCHAR(512) null,
797     STR_PROP_2 VARCHAR(512) null,
798     STR_PROP_3 VARCHAR(512) null,
799     INT_PROP_1 INT null,
800     INT_PROP_2 INT null,
801     LONG_PROP_1 BIGINT null,
802     LONG_PROP_2 BIGINT null,
803     DEC_PROP_1 NUMERIC(13,4) null,
804     DEC_PROP_2 NUMERIC(13,4) null,
805     BOOL_PROP_1 VARCHAR(1) null,
806     BOOL_PROP_2 VARCHAR(1) null,
807     primary key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
808     FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) 
809     REFERENCES FN_QZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
810 );
811   
812 -- ----------------------------------------------------------
813 -- NAME: FN_QZ_BLOB_TRIGGERS; TYPE: TABLE
814 -- ----------------------------------------------------------
815 create table fn_qz_blob_triggers (
816 SCHED_NAME VARCHAR(120) not null,
817 TRIGGER_NAME VARCHAR(200) not null,
818 TRIGGER_GROUP VARCHAR(200) not null,
819 BLOB_DATA BLOB null,
820 primary key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
821 INDEX (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP),
822 FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
823 REFERENCES FN_QZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
824 );
825   
826 -- ----------------------------------------------------------
827 -- NAME: FN_QZ_CALENDARS; TYPE: TABLE
828 -- ----------------------------------------------------------
829 create table fn_qz_calendars (
830 SCHED_NAME VARCHAR(120) not null,
831 CALENDAR_NAME VARCHAR(200) not null,
832 CALENDAR BLOB not null,
833 primary key (SCHED_NAME,CALENDAR_NAME)
834 );
835
836
837 -- ----------------------------------------------------------
838 -- NAME: FN_QZ_PAUSED_TRIGGER_GRPS; TYPE: TABLE
839 -- ----------------------------------------------------------
840 create table fn_qz_paused_trigger_grps (
841 SCHED_NAME VARCHAR(120) not null,
842 TRIGGER_GROUP VARCHAR(200) not null,
843 primary key (SCHED_NAME,TRIGGER_GROUP)
844 );
845
846 -- ----------------------------------------------------------
847 -- NAME: FN_QZ_FIRED_TRIGGERS; TYPE: TABLE
848 -- ----------------------------------------------------------
849 create table fn_qz_fired_triggers (
850 SCHED_NAME VARCHAR(120) not null,
851 ENTRY_ID VARCHAR(95) not null,
852 TRIGGER_NAME VARCHAR(200) not null,
853 TRIGGER_GROUP VARCHAR(200) not null,
854 INSTANCE_NAME VARCHAR(200) not null,
855 FIRED_TIME BIGINT(13) not null,
856 SCHED_TIME BIGINT(13) not null,
857 PRIORITY INTEGER not null,
858 STATE VARCHAR(16) not null,
859 JOB_NAME VARCHAR(200) null,
860 JOB_GROUP VARCHAR(200) null,
861 IS_NONCONCURRENT VARCHAR(1) null,
862 REQUESTS_RECOVERY VARCHAR(1) null,
863 primary key (SCHED_NAME,ENTRY_ID)
864 );
865
866 -- ----------------------------------------------------------
867 -- NAME: FN_QZ_SCHEDULER_STATE; TYPE: TABLE
868 -- ----------------------------------------------------------
869 create table fn_qz_scheduler_state (
870 SCHED_NAME VARCHAR(120) not null,
871 INSTANCE_NAME VARCHAR(200) not null,
872 LAST_CHECKIN_TIME BIGINT(13) not null,
873 CHECKIN_INTERVAL BIGINT(13) not null,
874 primary key (SCHED_NAME,INSTANCE_NAME)
875 );
876
877 -- ----------------------------------------------------------
878 -- NAME: FN_QZ_LOCKS; TYPE: TABLE
879 -- ----------------------------------------------------------
880 create table fn_qz_locks (
881 SCHED_NAME VARCHAR(120) not null,
882 LOCK_NAME VARCHAR(40) not null,
883 primary key (SCHED_NAME,LOCK_NAME)
884 );
885
886 -- ----------------------------------------------------------
887 -- NAME: FN_MENU_FAVORITES; TYPE: TABLE
888 -- ----------------------------------------------------------
889
890 create table fn_menu_favorites (
891   user_id int(11) not null,
892   menu_id int(11) not null,
893   primary key (user_id,menu_id)
894 );
895
896 -- FACELIFT - Table for Events, News and Resources
897
898 create table fn_common_widget_data(
899         id int auto_increment, 
900         category varchar(32), 
901         href varchar(512), 
902         title varchar(256), 
903         content varchar(4096), 
904         event_date varchar(10), -- YYYY-MM-DD 
905         sort_order int, 
906         primary key (id)
907 );
908
909 create table fn_app_contact_us (
910   app_id int(11) not null,
911   contact_name varchar(128) default null,
912   contact_email varchar(128) default null,
913   url varchar(256) default null,
914   active_yn varchar(2) default null,
915   description varchar(1024) default null,
916   primary key (app_id),
917   constraint fk_fn_a_con__ref_202_fn_app foreign key (app_id) references fn_app (app_id)
918 );
919
920 -- new 1610.2
921 create table fn_pers_user_app_sel (
922   id   int(11) not null auto_increment,
923   user_id   int(11) not null,
924   app_id    int(11) not null,
925   status_cd char(1) not null,
926   primary key(id),
927   constraint fk_1_fn_pers_user_app_sel_fn_user foreign key (user_id) references fn_user (user_id),
928   constraint fk_2_fn_pers_user_app_sel_fn_app  foreign key (app_id)  references fn_app (app_id)
929 );
930
931 -- end new 1610.2
932
933 -- new 1702 tables/views
934  -- 1702 Additions for User Notifications
935  -- ----------------------------------------------------------
936  -- NAME: ep_notification; TYPE: TABLE
937  -- ----------------------------------------------------------
938  create table ep_notification (
939     notification_ID     int(11) primary key not null auto_increment,
940     is_for_online_users char(1) default 'N',
941     is_for_all_roles    char(1) default 'N',
942     active_YN           char(1) default 'Y',
943     msg_header          varchar(100),
944     msg_description     varchar(2000),
945     msg_source          varchar(50) default 'EP',
946     start_time          timestamp default now(),
947     end_time            timestamp null,
948     priority            int(11),
949     creator_ID          int(11) null default null,
950     created_date        timestamp null default null,
951     notification_hyperlink varchar(512) null default null  -- new column for 1710
952    );
953
954  -- ----------------------------------------------------------
955  -- NAME: ep_role_notification; TYPE: TABLE
956  -- ----------------------------------------------------------
957  create table ep_role_notification (
958    ID                  int(11) primary key not null auto_increment,
959    notification_ID     int(11),
960    role_ID             int(11),
961    recv_user_id        int(11) null,
962    constraint fk_ep_role_notif_fn_role foreign key (role_ID) references fn_role(role_id),
963    constraint fk_ep_role_notif_fn_notif foreign key (notification_ID) references ep_notification(notification_ID)
964    );
965    
966  -- ----------------------------------------------------------
967  -- NAME: ep_user_notification; TYPE: TABLE
968  -- ----------------------------------------------------------
969  create table ep_user_notification (
970     ID                  int(11) primary key not null auto_increment,
971     User_ID             int(11),
972     notification_ID     int(11),
973     is_viewed           char(1) default 'N',
974     updated_time        timestamp default now(),
975     constraint fk_ep_urole_notif_fn_user foreign key (User_ID) references fn_user(user_id),
976     constraint fk_ep_urole_notif_fn_notif foreign key (notification_ID) references ep_notification(notification_ID)
977    );
978
979  -- ----------------------------------------------------------
980  -- NAME: ep_pers_user_app_sort; TYPE: Table
981  -- ----------------------------------------------------------
982
983  CREATE TABLE ep_pers_user_app_sort (
984    id        int(11) not null primary key auto_increment,
985    user_id   int(11) not null,
986    sort_pref char(1) not null,
987    unique key uk_1_ep_pers_user_app_sort (user_id),
988    constraint fk_ep_pers_user_app_sort_fn_user foreign key (user_id) references fn_user(user_id)
989  );
990  -- ----------------------------------------------------------
991  -- NAME: ep_pers_user_app_man_sort; TYPE: Table
992  -- ----------------------------------------------------------
993
994  CREATE TABLE ep_pers_user_app_man_sort (
995    id         int(11) not null primary key auto_increment,
996    user_id    int(11) not null,
997    app_id     int(11) not null,
998    sort_order int(11) not null,
999    unique key uk_1_ep_pers_user_app_man_sort (user_id, app_id),
1000    constraint fk_ep_pers_app_man_sort_fn_user foreign key (user_id) references fn_user(user_id),
1001    constraint fk_ep_pers_app_man_sort_fn_app foreign key (app_id) references fn_app(app_id)
1002  );
1003
1004  -- ----------------------------------------------------------
1005  -- NAME: ep_widget_catalog; TYPE: Table
1006  -- ----------------------------------------------------------
1007
1008  CREATE TABLE ep_widget_catalog (
1009    widget_id int(11) not null auto_increment,
1010    wdg_name varchar(100) not null default '?',
1011    service_id int(11) default null,
1012    wdg_desc varchar(200) default null,
1013    wdg_file_loc varchar(256) not null default '?',
1014    all_user_flag char(1) not null default 'N',
1015    primary key (widget_id)
1016  );
1017  
1018  -- ----------------------------------------------------------
1019  -- NAME: ep_widget_catalog_role; TYPE: Table
1020  -- ----------------------------------------------------------
1021  create table ep_widget_catalog_role (
1022    widget_id    int(10) not null,
1023    app_id               int(11) default '1',
1024    role_id              int(10) not null,
1025    key fk_ep_widget_catalog_role_fn_widget (widget_id),
1026    key fk_ep_widget_catalog_role_ref_fn_role (role_id),
1027    key fk_ep_widget_catalog_role_app_id  (app_id),
1028    constraint fk_ep_widget_catalog_role_fn_widget foreign key (widget_id) references ep_widget_catalog (widget_id),
1029    constraint fk_ep_widget_catalog_role_ref_fn_role foreign key (role_id) references fn_role (role_id),
1030    constraint fk_ep_widget_catalog_role_app_id foreign key (app_id) references fn_app (app_id)
1031  );
1032
1033  -- ----------------------------------------------------------
1034  -- NAME: ep_pers_user_widget_placement; TYPE: Table
1035  -- ----------------------------------------------------------
1036  CREATE TABLE ep_pers_user_widget_placement (
1037    id        int(11) not null primary key auto_increment,
1038    user_id   int(11) not null,
1039    widget_id int(11) not null,
1040    x         int(11) not null,
1041    y         int(11),
1042    height    int(11),
1043    width     int(11),
1044    unique key uk_1_ep_pers_user_widg_place (user_id, widget_id),
1045    constraint fk_ep_pers_user_widg_place_fn_user foreign key (user_id) references fn_user(user_id),
1046    constraint fk_ep_pers_user_widg_place_ep_widg foreign key (widget_id) references ep_widget_catalog(widget_id)
1047  );
1048
1049  -- ----------------------------------------------------------
1050  -- NAME: ep_pers_user_widget_sel; TYPE: TABLE
1051  -- ----------------------------------------------------------
1052  CREATE TABLE ep_pers_user_widget_sel (
1053    id        int(11) not null primary key auto_increment,
1054    user_id   int(11) not null,
1055    widget_id int(11) not null,
1056    status_cd char(1) not null,
1057    unique key uk_1_ep_pers_user_widg_sel_user_widg (user_id, widget_id),
1058    CONSTRAINT fk_1_ep_pers_user_wid_sel_fn_user FOREIGN KEY (user_id) REFERENCES fn_user (user_id),
1059    CONSTRAINT fk_2_ep_pers_user_wid_sel_ep_wid FOREIGN KEY (widget_id) REFERENCES ep_widget_catalog (widget_id)
1060  );
1061
1062  -- ----------------------------------------------------------
1063  -- NAME: ep_widget_catalog_files; TYPE: TABLE
1064  -- ----------------------------------------------------------
1065  CREATE TABLE ep_widget_catalog_files (
1066         file_id                 int(11) not null primary key auto_increment,
1067         widget_id               int(11),
1068                 widget_name             VARCHAR(100) NOT NULL,
1069                 framework_js            LONGBLOB NULL,
1070                 controller_js           LONGBLOB NULL,
1071                 markup_html             LONGBLOB NULL,
1072                 widget_css                      LONGBLOB NULL
1073  );
1074
1075  -- ----------------------------------------------------------
1076  -- NAME: fn_role_v; TYPE: VIEW
1077  -- All roles without an APP_ID are Portal only.
1078  -- ----------------------------------------------------------
1079  create view fn_role_v as
1080   select fn_role.role_id as role_id,
1081          fn_role.role_name as role_name,
1082                 fn_role.active_yn as active_yn,
1083          fn_role.priority as priority,
1084          fn_role.app_id as app_id,
1085          fn_role.app_role_id as app_role_id
1086  from fn_role where isnull(fn_role.app_id);
1087
1088 -- end new 1702 tables/views
1089
1090 -- new 1707 tables/views
1091
1092  -- ----------------------------------------------------------
1093  -- NAME: ep_user_roles_request; TYPE: TABLE
1094  -- ----------------------------------------------------------
1095
1096 create table ep_user_roles_request (
1097     req_id int(11) not null primary key auto_increment,
1098     user_id int(11) not null,
1099     app_id int(11) not null,
1100         created_date timestamp default now(),
1101         updated_date timestamp default now(),
1102     request_status character varying(50) not null,
1103         constraint fk_user_roles_req_fn_user foreign key (user_id) references fn_user(user_id),
1104         constraint fk_user_roles_req_fn_app foreign key (app_id) references fn_app(app_id)
1105     );
1106   
1107   
1108  -- ----------------------------------------------------------
1109  -- NAME: ep_user_roles_request_det; TYPE: TABLE
1110  -- ----------------------------------------------------------
1111 create table ep_user_roles_request_det (
1112     id int(11) not null primary key auto_increment,
1113     req_id int(11) default null,
1114         requested_role_id int(10) not null,
1115     request_type character varying(10) not null,
1116     constraint fk_user_roles_req_fn_req_id foreign key (req_id) references ep_user_roles_request(req_id),
1117     constraint fk_user_roles_req_fn_role_id foreign key (requested_role_id) references fn_role(role_id)
1118     );
1119         
1120  -- ----------------------------------------------------------
1121  -- NAME: ep_microservice; TYPE: TABLE
1122  -- ----------------------------------------------------------
1123
1124 CREATE TABLE ep_microservice (
1125         id INT(11) NOT NULL AUTO_INCREMENT,
1126         name VARCHAR(50) NULL DEFAULT NULL,
1127         description VARCHAR(50) NULL DEFAULT NULL,
1128         appId INT(11) NULL DEFAULT NULL,
1129         endpoint_url VARCHAR(200) NULL DEFAULT NULL,
1130         security_type VARCHAR(50) NULL DEFAULT NULL,
1131         username VARCHAR(50) NULL DEFAULT NULL,
1132         password VARCHAR(50) NULL DEFAULT NULL,
1133         active CHAR(1) NOT NULL DEFAULT 'Y',
1134         PRIMARY KEY (id),
1135         CONSTRAINT FK_FN_APP_EP_MICROSERVICE FOREIGN KEY (appId) REFERENCES fn_app (app_id)
1136 );
1137
1138  -- ----------------------------------------------------------
1139  -- NAME: ep_microservice_parameter; TYPE: TABLE
1140  -- ----------------------------------------------------------
1141  
1142 CREATE TABLE ep_microservice_parameter (
1143         id INT(11) NOT NULL AUTO_INCREMENT,
1144         service_id INT(11) NULL DEFAULT NULL,
1145         para_key VARCHAR(50) NULL DEFAULT NULL,
1146         para_value VARCHAR(50) NULL DEFAULT NULL,
1147         PRIMARY KEY (id),
1148         CONSTRAINT FK_EP_MICROSERIVCE_EP_MICROSERVICE_PARAMETER FOREIGN KEY (service_id) REFERENCES ep_microservice (id)
1149 );
1150
1151
1152  -- ----------------------------------------------------------
1153  -- NAME: ep_widget_preview_files; TYPE: TABLE
1154  -- ----------------------------------------------------------
1155  
1156 CREATE TABLE ep_widget_preview_files (
1157         preview_id INT(11) NOT NULL AUTO_INCREMENT,
1158         html_file LONGBLOB NULL,
1159         css_file LONGBLOB NULL,
1160         javascript_file LONGBLOB NULL,
1161         framework_file LONGBLOB NULL,
1162         PRIMARY KEY (preview_id)
1163 );
1164
1165  -- ----------------------------------------------------------
1166  -- NAME: ep_widget_microservice; TYPE: TABLE
1167  -- ----------------------------------------------------------
1168
1169 CREATE TABLE ep_widget_microservice (
1170         id INT(11) NOT NULL AUTO_INCREMENT,
1171         widget_id INT(11) NOT NULL DEFAULT '0',
1172         microservice_id INT(11) NOT NULL DEFAULT '0',
1173         PRIMARY KEY (id),
1174         CONSTRAINT FK_EP_WIDGET_MICROSERVICE_EP_MICROSERVICE FOREIGN KEY (microservice_id) REFERENCES ep_microservice (id),
1175         CONSTRAINT FK_EP_WIDGET_MICROSERVICE_EP_WIDGET FOREIGN KEY (widget_id) REFERENCES ep_widget_catalog (widget_id)
1176 );
1177
1178  -- ----------------------------------------------------------
1179  -- NAME: ep_basic_auth_account; TYPE: TABLE
1180  -- ----------------------------------------------------------
1181  
1182 create table ep_basic_auth_account (
1183         id INT(11) NOT NULL AUTO_INCREMENT,
1184         ext_app_name VARCHAR(50) NOT NULL,
1185         username VARCHAR(50) NOT NULL,
1186         password VARCHAR(50) NOT NULL,
1187     active_yn char(1) NOT NULL default 'Y',
1188         PRIMARY KEY (id)
1189 );
1190
1191  -- ----------------------------------------------------------
1192  -- NAME: ep_widget_catalog_parameter; TYPE: TABLE
1193  -- ----------------------------------------------------------
1194  
1195 create table  ep_widget_catalog_parameter (
1196         id INT(11) NOT NULL AUTO_INCREMENT,
1197         widget_id INT(11) NOT NULL,
1198         user_id INT(11) NOT NULL,
1199         param_id INT(11) NOT NULL,
1200     user_value VARCHAR(50) NULL,
1201         PRIMARY KEY (id),
1202         CONSTRAINT EP_FN_USER_WIDGET_PARAMETER_FK FOREIGN KEY (user_id) REFERENCES fn_user (user_id),
1203         CONSTRAINT EP_WIDGET_CATALOG_WIDGET_PARAMETER_FK FOREIGN KEY (widget_id) REFERENCES ep_widget_catalog (widget_id),
1204         CONSTRAINT EP_PARAMETER_ID_WIDGET_PARAMETER_FK FOREIGN KEY (param_id) REFERENCES ep_microservice_parameter (id)
1205 );
1206
1207  -- ----------------------------------------------------------
1208  -- NAME: ep_web_analytics_source; TYPE: TABLE
1209  -- ----------------------------------------------------------
1210  
1211 create table ep_web_analytics_source(
1212         resource_id int(11) NOT NULL auto_increment,
1213         app_id int(11) NOT NULL,
1214     report_source varchar(500),
1215     report_name  varchar(500),
1216     PRIMARY KEY (resource_id),
1217         FOREIGN KEY (app_id) REFERENCES fn_app(app_id)
1218 ); 
1219
1220  -- Machine Learning Tables
1221  -- ----------------------------------------------------------
1222  -- NAME: ep_ml_model; TYPE: TABLE
1223  -- ----------------------------------------------------------
1224  
1225 create table ep_ml_model(
1226   time_stamp timestamp default now(),
1227   group_id int(11) NOT NULL,
1228   model longblob,
1229   PRIMARY KEY (time_stamp,group_id)
1230 );
1231  -- ----------------------------------------------------------
1232  -- NAME: ep_ml_rec; TYPE: TABLE
1233  -- ----------------------------------------------------------
1234  
1235 create table ep_ml_rec(
1236   time_stamp timestamp default now(),
1237   org_user_id varchar(20) NOT NULL,
1238   rec varchar(4000) DEFAULT NULL,
1239   PRIMARY KEY (time_stamp,org_user_id)
1240 );
1241
1242  -- ----------------------------------------------------------
1243  -- NAME: ep_ml_user; TYPE: TABLE
1244  -- ----------------------------------------------------------
1245  
1246 create table ep_ml_user(
1247   time_stamp timestamp default now(),
1248   org_user_id varchar(20) NOT NULL,
1249   group_id int(11) NOT NULL,
1250   PRIMARY KEY (time_stamp,org_user_id)
1251 );
1252
1253  -- ----------------------------------------------------------
1254  -- NAME: ep_endpoints; TYPE: TABLE
1255  -- ----------------------------------------------------------
1256  
1257 create table  ep_endpoints (
1258         id INT(11) NOT NULL AUTO_INCREMENT,
1259     url VARCHAR(50) NOT NULL,
1260         PRIMARY KEY (id)
1261 );
1262
1263  -- ----------------------------------------------------------
1264  -- NAME: ep_endpoints_basic_auth_account; TYPE: TABLE
1265  -- ----------------------------------------------------------
1266
1267 create table  ep_endpoints_basic_auth_account (
1268         id INT(11) NOT NULL AUTO_INCREMENT,
1269         ep_id INT(11) DEFAULT NULL,
1270         account_id INT(11) DEFAULT NULL,
1271         PRIMARY KEY (id),
1272         CONSTRAINT ep_endpoints_basic_auth_account_account_id_fk FOREIGN KEY (account_id) REFERENCES ep_basic_auth_account (id),
1273         CONSTRAINT ep_endpoints_basic_auth_account_ep_id_fk FOREIGN KEY (ep_id) REFERENCES ep_endpoints (id)
1274
1275 );
1276
1277 -- end new 1707 tables/views
1278
1279 -- new 1710 tables/views
1280
1281  -- ----------------------------------------------------------
1282  -- NAME: ep_app_function; TYPE: TABLE
1283  -- ----------------------------------------------------------
1284
1285 CREATE TABLE ep_app_function (
1286 app_id INT(11) NOT NULL,
1287 function_cd VARCHAR(50) NOT NULL,
1288 function_name VARCHAR(50) NOT NULL,
1289 PRIMARY KEY (function_cd, app_id),
1290 INDEX fk_ep_app_function_app_id (app_id),
1291 CONSTRAINT fk_ep_app_function_app_id FOREIGN KEY (app_id) REFERENCES fn_app (app_id)
1292 );
1293
1294  -- ----------------------------------------------------------
1295  -- NAME: ep_app_role_function; TYPE: TABLE
1296  -- ----------------------------------------------------------
1297
1298 CREATE TABLE `ep_app_role_function` (
1299 `id` INT(11) NOT NULL AUTO_INCREMENT,
1300 `app_id` INT(11) NOT NULL,
1301 `role_id` INT(11) NOT NULL,
1302 `function_cd` VARCHAR(50) NOT NULL,
1303 PRIMARY KEY (`id`),
1304 UNIQUE INDEX `UNIQUE KEY` (`app_id`, `role_id`, `function_cd`),
1305 INDEX `fk_ep_app_role_function_role_id` (`role_id`),
1306 INDEX `fk_ep_app_role_function_app_id` (`app_id`),
1307 INDEX `fk_ep_app_role_function_ep_app_func` (`function_cd`,`app_id`),
1308 CONSTRAINT `fk_ep_app_role_function_app_id` FOREIGN KEY (`app_id`) REFERENCES `fn_app` (`app_id`),
1309 CONSTRAINT `fk_ep_app_role_function_ep_app_func` FOREIGN KEY (`app_id`, `function_cd`) REFERENCES `ep_app_function` (`app_id`, `function_cd`),
1310 CONSTRAINT `fk_ep_app_role_function_role_id` FOREIGN KEY (`role_id`) REFERENCES `fn_role` (`role_id`)
1311 );
1312
1313 -- end new 1710 tables/views
1314
1315 -- ----------------------------------------------------------
1316 -- NAME: QUARTZ TYPE: INDEXES
1317 -- ----------------------------------------------------------
1318 create index idx_fn_qz_j_req_recovery on fn_qz_job_details(sched_name,requests_recovery);
1319 create index idx_fn_qz_j_grp on fn_qz_job_details(sched_name,job_group);
1320 create index idx_fn_qz_t_j on fn_qz_triggers(sched_name,job_name,job_group);
1321 create index idx_fn_qz_t_jg on fn_qz_triggers(sched_name,job_group);
1322 create index idx_fn_qz_t_c on fn_qz_triggers(sched_name,calendar_name);
1323 create index idx_fn_qz_t_g on fn_qz_triggers(sched_name,trigger_group);
1324 create index idx_fn_qz_t_state on fn_qz_triggers(sched_name,trigger_state);
1325 create index idx_fn_qz_t_n_state on fn_qz_triggers(sched_name,trigger_name,trigger_group,trigger_state);
1326 create index idx_fn_qz_t_n_g_state on fn_qz_triggers(sched_name,trigger_group,trigger_state);
1327 create index idx_fn_qz_t_next_fire_time on fn_qz_triggers(sched_name,next_fire_time);
1328 create index idx_fn_qz_t_nft_st on fn_qz_triggers(sched_name,trigger_state,next_fire_time);
1329 create index idx_fn_qz_t_nft_misfire on fn_qz_triggers(sched_name,misfire_instr,next_fire_time);
1330 create index idx_fn_qz_t_nft_st_misfire on fn_qz_triggers(sched_name,misfire_instr,next_fire_time,trigger_state);
1331 create index idx_fn_qz_t_nft_st_misfire_grp on fn_qz_triggers(sched_name,misfire_instr,next_fire_time,trigger_group,trigger_state);
1332 create index idx_fn_qz_ft_trig_inst_name on fn_qz_fired_triggers(sched_name,instance_name);
1333 create index idx_fn_qz_ft_inst_job_req_rcvry on fn_qz_fired_triggers(sched_name,instance_name,requests_recovery);
1334 create index idx_fn_qz_ft_j_g on fn_qz_fired_triggers(sched_name,job_name,job_group);
1335 create index idx_fn_qz_ft_jg on fn_qz_fired_triggers(sched_name,job_group);
1336 create index idx_fn_qz_ft_t_g on fn_qz_fired_triggers(sched_name,trigger_name,trigger_group);
1337 create index idx_fn_qz_ft_tg on fn_qz_fired_triggers(sched_name,trigger_group);
1338
1339
1340 -- ------------------ create view section
1341 --
1342 -- name: v_url_access; type: view
1343 --
1344 create view v_url_access as
1345  select distinct m.action as url,
1346     m.function_cd
1347    from fn_menu m
1348   where (m.action is not null)
1349 union
1350  select distinct t.action as url,
1351     t.function_cd
1352    from fn_tab t
1353   where (t.action is not null)
1354 union
1355  select r.restricted_url as url,
1356     r.function_cd
1357    from fn_restricted_url r;
1358    
1359 -- ------------------ alter table add constraint primary key section
1360 --
1361 -- name: cr_favorite_reports_user_idrep_id; type: constraint
1362 --
1363 alter table cr_favorite_reports 
1364     add constraint cr_favorite_reports_user_idrep_id primary key (user_id, rep_id);
1365 --
1366 -- name: cr_folder_folder_id; type: constraint
1367 --
1368 alter table cr_folder
1369     add constraint cr_folder_folder_id primary key (folder_id);
1370 --
1371 -- name: cr_folder_access_folder_access_id; type: constraint
1372 --
1373 alter table cr_folder_access
1374     add constraint cr_folder_access_folder_access_id primary key (folder_access_id);
1375 --
1376 -- name: cr_hist_user_map_hist_iduser_id; type: constraint
1377 --
1378 alter table cr_hist_user_map
1379     add constraint cr_hist_user_map_hist_iduser_id primary key (hist_id, user_id);
1380 --
1381 -- name: cr_lu_file_type_lookup_id; type: constraint
1382 --
1383 alter table cr_lu_file_type
1384     add constraint cr_lu_file_type_lookup_id primary key (lookup_id);
1385 --
1386 -- name: cr_raptor_action_img_image_id; type: constraint
1387 --
1388 alter table cr_raptor_action_img
1389     add constraint cr_raptor_action_img_image_id primary key (image_id);
1390 --
1391 -- name: cr_raptor_pdf_img_image_id; type: constraint
1392 --
1393 alter table cr_raptor_pdf_img
1394     add constraint cr_raptor_pdf_img_image_id primary key (image_id);
1395 --
1396 -- name: cr_remote_schema_info_schema_prefix; type: constraint
1397 --
1398 alter table cr_remote_schema_info
1399     add constraint cr_remote_schema_info_schema_prefix primary key (schema_prefix);
1400 --
1401 -- name: cr_report_rep_id; type: constraint
1402 --
1403 alter table cr_report
1404     add constraint cr_report_rep_id primary key (rep_id);
1405 --
1406 -- name: cr_report_access_rep_idorder_no; type: constraint
1407 --
1408 alter table cr_report_access
1409     add constraint cr_report_access_rep_idorder_no primary key (rep_id, order_no);
1410 --
1411 -- name: cr_report_email_sent_log_log_id; type: constraint
1412 --
1413 alter table cr_report_email_sent_log
1414     add constraint cr_report_email_sent_log_log_id primary key (log_id);
1415 --
1416 -- name: cr_report_file_history_hist_id; type: constraint
1417 --
1418 alter table cr_report_file_history
1419     add constraint cr_report_file_history_hist_id primary key (hist_id);
1420 --
1421 -- name: cr_report_schedule_schedule_id; type: constraint
1422 --
1423 alter table cr_report_schedule
1424     add constraint cr_report_schedule_schedule_id primary key (schedule_id);
1425 --
1426 -- name: cr_report_schedule_users_schedule_idrep_iduser_idorder_no; type: constraint
1427 --
1428 alter table cr_report_schedule_users
1429     add constraint cr_report_schedule_users_schedule_idrep_iduser_idorder_no primary key (schedule_id, rep_id, user_id, order_no);
1430 --
1431 -- name: cr_report_template_map_report_id; type: constraint
1432 --
1433 alter table cr_report_template_map
1434     add constraint cr_report_template_map_report_id primary key (report_id);
1435 --
1436 -- name: cr_table_role_table_namerole_id; type: constraint
1437 --
1438 alter table cr_table_role
1439     add constraint cr_table_role_table_namerole_id primary key (table_name, role_id);
1440 --
1441 -- name: cr_table_source_table_name; type: constraint
1442 --
1443 alter table cr_table_source
1444     add constraint cr_table_source_table_name primary key (table_name);
1445 --
1446 -- name: fn_audit_action_audit_action_id; type: constraint
1447 --
1448 alter table fn_audit_action
1449     add constraint fn_audit_action_audit_action_id primary key (audit_action_id);  
1450 --
1451 --
1452 -- name: fk_fn_audit_ref_205_fn_lu_ac; type: constraint
1453 --
1454 alter table fn_audit_log
1455         add constraint fk_fn_audit_ref_205_fn_lu_ac foreign key (activity_cd) references fn_lu_activity(activity_cd);
1456 --
1457 -- name: fk_fn_role__ref_201_fn_funct; type: constraint
1458 --    
1459 alter table fn_role_function
1460         add constraint fk_fn_role__ref_201_fn_funct foreign key (function_cd) references fn_function(function_cd);
1461 --
1462 -- name: fn_chat_logs_chat_log_id; type: constraint
1463 --
1464 alter table fn_chat_logs
1465     add constraint fn_chat_logs_chat_log_id primary key (chat_log_id);
1466 --
1467 -- name: fn_chat_room_chat_room_id; type: constraint
1468 --
1469 alter table fn_chat_room
1470     add constraint fn_chat_room_chat_room_id primary key (chat_room_id);
1471 --
1472 -- name: fn_chat_users_id; type: constraint
1473 --
1474 alter table fn_chat_users  
1475     add constraint fn_chat_users_id primary key (id);
1476 --
1477 -- name: fn_lu_alert_method_alert_method_cd; type: constraint
1478 --
1479 alter table fn_lu_alert_method
1480     add constraint fn_lu_alert_method_alert_method_cd primary key (alert_method_cd);
1481 --
1482 -- name: fn_lu_broadcast_site_broadcast_site_cd; type: constraint
1483 --
1484 alter table fn_lu_broadcast_site
1485     add constraint fn_lu_broadcast_site_broadcast_site_cd primary key (broadcast_site_cd);
1486 --
1487 -- name: fn_lu_priority_priority_id; type: constraint
1488 --
1489 alter table fn_lu_priority
1490     add constraint fn_lu_priority_priority_id primary key (priority_id);
1491 --
1492 -- name: fn_lu_role_type_role_type_id; type: constraint
1493 --
1494 alter table fn_lu_role_type
1495     add constraint fn_lu_role_type_role_type_id primary key (role_type_id);
1496 --
1497 -- name: fn_lu_tab_set_tab_set_cd; type: constraint
1498 --
1499 alter table fn_lu_tab_set
1500     add constraint fn_lu_tab_set_tab_set_cd primary key (tab_set_cd);
1501 --
1502 -- name: fn_lu_timezone_timezone_id; type: constraint
1503 --
1504 alter table fn_lu_timezone
1505     add constraint fn_lu_timezone_timezone_id primary key (timezone_id);
1506 --
1507 -- name: fn_org_org_id; type: constraint
1508 --
1509 alter table fn_org
1510     add constraint fn_org_org_id primary key (org_id);
1511 --
1512 -- name: fn_restricted_url_restricted_urlfunction_cd; type: constraint
1513 --
1514 alter table fn_restricted_url
1515     add constraint fn_restricted_url_restricted_urlfunction_cd primary key (restricted_url, function_cd);
1516 --
1517 -- name: fn_role_composite_parent_role_idchild_role_id; type: constraint
1518 --
1519 alter table fn_role_composite
1520     add constraint fn_role_composite_parent_role_idchild_role_id primary key (parent_role_id, child_role_id);
1521 --
1522 -- name: fn_role_function_role_idfunction_cd; type: constraint
1523 --
1524 alter table fn_role_function
1525     add constraint fn_role_function_role_idfunction_cd primary key (role_id, function_cd);
1526 --
1527 -- name: fn_tab_tab_cd; type: constraint
1528 --
1529 alter table fn_tab
1530     add constraint fn_tab_tab_cd primary key (tab_cd);
1531 --
1532 -- name: fn_tab_selected_selected_tab_cdtab_uri; type: constraint
1533 --
1534 alter table fn_tab_selected
1535     add constraint fn_tab_selected_selected_tab_cdtab_uri primary key (selected_tab_cd, tab_uri);
1536 --
1537 -- name: fn_user_pseudo_role_pseudo_role_iduser_id; type: constraint
1538 --
1539 alter table fn_user_pseudo_role
1540     add constraint fn_user_pseudo_role_pseudo_role_iduser_id primary key (pseudo_role_id, user_id);
1541 --
1542 -- name: fn_user_role_user_idrole_id; type: constraint
1543 --
1544 alter table fn_user_role
1545     add constraint fn_user_role_user_idrole_id primary key (user_id, role_id, app_id);
1546 -- ------------------ create index section
1547 --
1548 -- name: cr_report_create_idpublic_yntitle; type: index
1549 --
1550 create index cr_report_create_idpublic_yntitle using btree on cr_report (create_id, public_yn, title);
1551 --
1552 -- name: cr_table_join_dest_table_name; type: index
1553 --
1554 create index cr_table_join_dest_table_name using btree on cr_table_join (dest_table_name);
1555 --
1556 -- name: cr_table_join_src_table_name; type: index
1557 --
1558 create index cr_table_join_src_table_name using btree on cr_table_join (src_table_name);
1559 --
1560 -- name: fn_audit_log_activity_cd; type: index
1561 --
1562 create index fn_audit_log_activity_cd using btree on fn_audit_log (activity_cd);
1563 --
1564 -- name: fn_audit_log_user_id; type: index
1565 --
1566 create index fn_audit_log_user_id using btree on fn_audit_log (user_id);
1567 --
1568 -- name: fn_menu_function_cd; type: index
1569 --
1570 create index fn_menu_function_cd using btree on fn_menu (function_cd);
1571 --
1572 -- name: fn_org_access_cd; type: index
1573 --
1574 create index fn_org_access_cd using btree on fn_org (access_cd);
1575 --
1576 -- name: fn_role_function_function_cd; type: index
1577 --
1578 create index fn_role_function_function_cd using btree on fn_role_function (function_cd);
1579 --
1580 -- name: fn_role_function_role_id; type: index
1581 --
1582 create index fn_role_function_role_id using btree on fn_role_function (role_id);
1583 --
1584 -- name: fn_user_address_id; type: index
1585 --
1586 create index fn_user_address_id using btree on fn_user (address_id); 
1587 --
1588 -- name: fn_user_alert_method_cd; type: index
1589 --
1590 create index fn_user_alert_method_cd using btree on fn_user (alert_method_cd); 
1591 --
1592 -- name: fn_user_hrid; type: index
1593 --
1594 create unique index fn_user_hrid using btree on fn_user (hrid); 
1595 --
1596 -- name: fn_user_login_id; type: index
1597 --
1598 create unique index fn_user_login_id using btree on fn_user (login_id); 
1599 --
1600 -- name: fn_user_org_id; type: index
1601 --
1602 create index fn_user_org_id using btree on fn_user (org_id); 
1603 --
1604 -- name: fn_user_role_role_id; type: index
1605 --
1606 create index fn_user_role_role_id using btree on fn_user_role (role_id);
1607 --
1608 -- name: fn_user_role_user_id; type: index
1609 --
1610 create index fn_user_role_user_id using btree on fn_user_role (user_id);
1611 --
1612 -- name: fk_fn_user__ref_178_fn_app_idx; type: index
1613 --
1614 create index fk_fn_user__ref_178_fn_app_idx on fn_user_role (app_id);
1615  --
1616  -- name: fn_role_name_app_id_idx; type: index
1617  --
1618  create unique index fn_role_name_app_id_idx using btree on fn_role (role_name,app_id);
1619  
1620 -- new for 1707
1621  
1622 create index ep_notif_recv_user_id_idx using btree on ep_role_notification (recv_user_id);
1623   
1624 -- end new for 1707
1625
1626 -- ------------------ alter table add constraint foreign key section
1627 --
1628 -- name: fk_fn_user__ref_178_fn_app; type: fk constraint
1629 --
1630 alter table fn_user_role
1631         add constraint fk_fn_user__ref_178_fn_app foreign key (app_id) references fn_app(app_id);
1632 --
1633 -- name: fk_cr_repor_ref_14707_cr_repor; type: fk constraint
1634 --
1635 alter table cr_report_schedule
1636     add constraint fk_cr_repor_ref_14707_cr_repor foreign key (rep_id) references cr_report(rep_id);
1637 --
1638 -- name: fk_cr_repor_ref_14716_cr_repor; type: fk constraint
1639 --
1640 alter table cr_report_schedule_users
1641     add constraint fk_cr_repor_ref_14716_cr_repor foreign key (schedule_id) references cr_report_schedule(schedule_id);
1642 --
1643 -- name: fk_cr_repor_ref_17645_cr_repor; type: fk constraint
1644 --
1645 alter table cr_report_log
1646     add constraint fk_cr_repor_ref_17645_cr_repor foreign key (rep_id) references cr_report(rep_id);
1647 --
1648 -- name: fk_cr_repor_ref_8550_cr_repor; type: fk constraint
1649 --
1650 alter table cr_report_access
1651     add constraint fk_cr_repor_ref_8550_cr_repor foreign key (rep_id) references cr_report(rep_id);
1652 --
1653 -- name: fk_cr_report_rep_id; type: fk constraint
1654 --
1655 alter table cr_report_email_sent_log
1656     add constraint fk_cr_report_rep_id foreign key (rep_id) references cr_report(rep_id);
1657 --
1658 -- name: fk_cr_table_ref_311_cr_tab; type: fk constraint
1659 --
1660 alter table cr_table_join
1661     add constraint fk_cr_table_ref_311_cr_tab foreign key (src_table_name) references cr_table_source(table_name);
1662 --
1663 -- name: fk_cr_table_ref_315_cr_tab; type: fk constraint
1664 --
1665 alter table cr_table_join
1666     add constraint fk_cr_table_ref_315_cr_tab foreign key (dest_table_name) references cr_table_source(table_name);
1667 --
1668 -- name: fk_cr_table_ref_32384_cr_table; type: fk constraint
1669 --
1670 alter table cr_table_role
1671     add constraint fk_cr_table_ref_32384_cr_table foreign key (table_name) references cr_table_source(table_name);
1672 --
1673 -- name: fk_fn_tab_function_cd; type: fk constraint
1674 --
1675 alter table fn_tab
1676     add constraint fk_fn_tab_function_cd foreign key (function_cd) references fn_function(function_cd);
1677 --
1678 -- name: fk_fn_tab_selected_tab_cd; type: fk constraint
1679 --
1680 alter table fn_tab_selected
1681     add constraint fk_fn_tab_selected_tab_cd foreign key (selected_tab_cd) references fn_tab(tab_cd);
1682 --
1683 -- name: fk_fn_tab_set_cd; type: fk constraint
1684 --
1685 alter table fn_tab
1686     add constraint fk_fn_tab_set_cd foreign key (tab_set_cd) references fn_lu_tab_set(tab_set_cd);
1687 --
1688 -- name: fk_fn_user_ref_110_fn_org; type: fk constraint
1689 -- 
1690 alter table fn_user
1691     add constraint fk_fn_user_ref_110_fn_org foreign key (org_id) references fn_org(org_id); 
1692 --
1693 -- name: fk_fn_user_ref_123_fn_lu_al; type: fk constraint
1694 --
1695 alter table fn_user
1696     add constraint fk_fn_user_ref_123_fn_lu_al foreign key (alert_method_cd) references fn_lu_alert_method(alert_method_cd); 
1697 --
1698 -- name: fk_fn_user_ref_197_fn_user; type: fk constraint
1699 --
1700  alter table fn_user
1701     add constraint fk_fn_user_ref_197_fn_user foreign key (manager_id) references fn_user(user_id); 
1702 --
1703 -- name: fk_fn_user_ref_198_fn_user; type: fk constraint
1704 --
1705 alter table fn_user  
1706     add constraint fk_fn_user_ref_198_fn_user foreign key (created_id) references fn_user(user_id); 
1707 --
1708 -- name: fk_fn_user_ref_199_fn_user; type: fk constraint
1709 --
1710 alter table fn_user  
1711     add constraint fk_fn_user_ref_199_fn_user foreign key (modified_id) references fn_user(user_id); 
1712 --
1713 -- name: fk_parent_key_cr_folder; type: fk constraint
1714 --
1715 alter table cr_folder
1716     add constraint fk_parent_key_cr_folder foreign key (parent_folder_id) references cr_folder(folder_id);
1717 --
1718 -- name: fk_pseudo_role_pseudo_role_id; type: fk constraint
1719 --
1720 alter table fn_user_pseudo_role 
1721     add constraint fk_pseudo_role_pseudo_role_id foreign key (pseudo_role_id) references fn_role(role_id);
1722 --
1723 -- name: fk_pseudo_role_user_id; type: fk constraint
1724 --
1725 alter table fn_user_pseudo_role 
1726     add constraint fk_pseudo_role_user_id foreign key (user_id) references fn_user(user_id);
1727 --
1728 -- name: fk_restricted_url_function_cd; type: fk constraint
1729 --
1730 alter table fn_restricted_url
1731     add constraint fk_restricted_url_function_cd foreign key (function_cd) references fn_function(function_cd);
1732 --
1733 -- name: fk_timezone; type: fk constraint
1734 --
1735 alter table fn_user
1736     add constraint fk_timezone foreign key (timezone) references fn_lu_timezone(timezone_id); 
1737 --
1738 -- name: sys_c0014614; type: fk constraint
1739 --
1740 alter table cr_report_file_history
1741     add constraint sys_c0014614 foreign key (file_type_id) references cr_lu_file_type(lookup_id);
1742 --
1743 -- name: sys_c0014615; type: fk constraint
1744 --
1745 alter table cr_report_file_history
1746     add constraint sys_c0014615 foreign key (rep_id) references cr_report(rep_id);
1747 --
1748 -- name: sys_c0014616; type: fk constraint
1749 --
1750 alter table cr_hist_user_map  
1751     add constraint sys_c0014616 foreign key (hist_id) references cr_report_file_history(hist_id);
1752 --
1753 -- name: sys_c0014617; type: fk constraint
1754 --
1755 alter table cr_hist_user_map  
1756     add constraint sys_c0014617 foreign key (user_id) references fn_user(user_id);
1757 --
1758 -- name: sys_c0014618; type: fk constraint
1759 --
1760 alter table fn_menu_favorites
1761 add constraint sys_c0014618 foreign key (user_id) references fn_user(user_id);  
1762     
1763 --
1764 -- name: sys_c0014619; type: fk constraint
1765 --
1766 alter table fn_menu_favorites
1767 add constraint sys_c0014619 foreign key (menu_id) references fn_menu_functional(menu_id);
1768
1769 commit;