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