From 3c3b6ee22669774b24854e8e3f795cb56e5b0847 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 25 Jul 2019 21:35:30 +1200 Subject: [PATCH] #69 - Extra tests for regression introduced by the prior commit --- .gitignore | 2 - .../io/ebean/migration/ddl/DdlParserTest.java | 50 + .../dbmig_mysql/mysql-create-all.sql | 4730 ++++++++++++++++ .../resources/dbmig_mysql/mysql-drop-all.sql | 1730 ++++++ src/test/resources/dbmig_postgres/ex1.sql | 14 + .../dbmig_postgres/pg-create-all.sql | 4745 +++++++++++++++++ 6 files changed, 11269 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/dbmig_mysql/mysql-create-all.sql create mode 100644 src/test/resources/dbmig_mysql/mysql-drop-all.sql create mode 100644 src/test/resources/dbmig_postgres/ex1.sql create mode 100644 src/test/resources/dbmig_postgres/pg-create-all.sql diff --git a/.gitignore b/.gitignore index 1bd192a..926a454 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ *.autofetch -*create-all.sql -*drop-all.sql *.orig .classpath .project diff --git a/src/test/java/io/ebean/migration/ddl/DdlParserTest.java b/src/test/java/io/ebean/migration/ddl/DdlParserTest.java index 717422f..d67663f 100644 --- a/src/test/java/io/ebean/migration/ddl/DdlParserTest.java +++ b/src/test/java/io/ebean/migration/ddl/DdlParserTest.java @@ -58,6 +58,56 @@ public void parse_sqlserver_create_procs() throws FileNotFoundException { "END"); } + + @Test + public void parse_postgres_procs() throws FileNotFoundException { + + FileReader fr = new FileReader("src/test/resources/dbmig_postgres/ex1.sql"); + final List statements = parser.parse(fr); + + assertThat(statements).hasSize(3); + assertThat(statements.get(0)).isEqualTo("create or replace function hx_link_history_version() returns trigger as $$\n" + + "begin\n" + + "\n" + + "end;\n" + + "$$ LANGUAGE plpgsql;"); + + assertThat(statements.get(1)).isEqualTo("create trigger hx_link_history_upd\n" + + " before update or delete on hx_link\n" + + " for each row execute procedure hx_link_history_version();"); + + assertThat(statements.get(2)).isEqualTo("create or replace function hi_link_history_version() returns trigger as $$\n" + + "begin\n" + + "end;\n" + + "$$ LANGUAGE plpgsql;"); + } + + + @Test + public void parse_postgres_createAll() throws FileNotFoundException { + + FileReader fr = new FileReader("src/test/resources/dbmig_postgres/pg-create-all.sql"); + final List statements = parser.parse(fr); + + assertThat(statements).hasSize(1013); + } + + @Test + public void parse_mysql_createAll() throws FileNotFoundException { + + FileReader fr = new FileReader("src/test/resources/dbmig_mysql/mysql-create-all.sql"); + final List statements = parser.parse(fr); + assertThat(statements).hasSize(1010); + } + + @Test + public void parse_mysql_dropAll() throws FileNotFoundException { + + FileReader fr = new FileReader("src/test/resources/dbmig_mysql/mysql-drop-all.sql"); + final List statements = parser.parse(fr); + assertThat(statements).hasSize(997); + } + @Test public void parse_ignoresEmptyLines() { diff --git a/src/test/resources/dbmig_mysql/mysql-create-all.sql b/src/test/resources/dbmig_mysql/mysql-create-all.sql new file mode 100644 index 0000000..8686f99 --- /dev/null +++ b/src/test/resources/dbmig_mysql/mysql-create-all.sql @@ -0,0 +1,4730 @@ +-- Generated by ebean unknown at 2019-07-25T07:02:24.426Z +-- init script create procs +-- Inital script to create stored procedures etc for mysql platform +DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys; + +delimiter $$ +-- +-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN +-- deletes all constraints and foreign keys referring to TABLE.COLUMN +-- +CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255)) +BEGIN + DECLARE done INT DEFAULT FALSE; + DECLARE c_fk_name CHAR(255); + DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE + WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name + AND REFERENCED_TABLE_NAME IS NOT NULL; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + OPEN curs; + + read_loop: LOOP + FETCH curs INTO c_fk_name; + IF done THEN + LEAVE read_loop; + END IF; + SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name); + PREPARE stmt FROM @sql; + EXECUTE stmt; + END LOOP; + + CLOSE curs; +END +$$ + +DROP PROCEDURE IF EXISTS usp_ebean_drop_column; + +delimiter $$ +-- +-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN +-- deletes the column and ensures that all indices and constraints are dropped first +-- +CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255)) +BEGIN + CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name); + SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name); + PREPARE stmt FROM @sql; + EXECUTE stmt; +END +$$ +create table asimple_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id integer auto_increment not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer(31) not null, + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigint auto_increment not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigint auto_increment not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigint auto_increment not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id smallint auto_increment not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime datetime(6), + country_code varchar(2), + updtime datetime(6) not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigint auto_increment not null, + name varchar(255), + cover_id bigint, + deleted tinyint(1) default 0 not null, + created_at datetime(6) not null, + last_update datetime(6) not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigint auto_increment not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id integer auto_increment not null, + name varchar(255), + author varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer(31) not null, + id integer auto_increment not null, + attribute_holder_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id integer auto_increment not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigint auto_increment not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id integer auto_increment not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id integer auto_increment not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id varchar(40) not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null, + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site varchar(40) not null, + usr varchar(40) not null, + access_level integer, + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid varchar(40) not null, + user_uid varchar(40) not null, + access_level integer, + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null +); + +create table bsite_user_e ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer +); + +create table buser ( + id varchar(40) not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer auto_increment not null, + `Name` varchar(191), + `CODE` varchar(255), + last_updated datetime(6) not null, + constraint uq_bwith_qident_name unique (`Name`), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigint auto_increment not null, + name varchar(255), + period varchar(50), + local_date date, + created datetime(6) not null, + updated datetime(6) not null, + version datetime(6) not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigint auto_increment not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint auto_increment not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); + +create table bw_bean ( + id bigint auto_increment not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table cinh_ref ( + id integer auto_increment not null, + ref_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id integer auto_increment not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id integer auto_increment not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table calculation_result ( + id integer auto_increment not null, + charge double not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint auto_increment not null, + version integer not null, + constraint pk_sa_car primary key (id) +); + +create table car_accessory ( + id integer auto_increment not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigint auto_increment not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigint auto_increment not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigint auto_increment not null, + parent_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigint auto_increment not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id integer auto_increment not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id integer auto_increment not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id integer auto_increment not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + customer_id integer not null, + group_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id integer auto_increment not null, + contact_id integer, + title varchar(255), + note longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigint auto_increment not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigint auto_increment not null, + title varchar(255), + isopen tinyint(1) default 0 not null, + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigint auto_increment not null, + s3_url varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id integer auto_increment not null, + status varchar(1) comment 'status of the customer', + name varchar(40) not null, + smallnote varchar(100) comment 'Short notes regarding the customer', + anniversary date comment 'Join date of the customer', + billing_address_id smallint, + shipping_address_id smallint, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_o_customer primary key (id) +) comment='Holds external customers'; + +create table dcredit ( + id bigint auto_increment not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigint auto_increment not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated datetime(6) not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dmachine ( + id bigint auto_increment not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigint auto_increment not null, + machine_id bigint not null, + name varchar(255), + date date, + use_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigint auto_increment not null, + machine_id bigint not null, + date date, + total_kms bigint not null, + hours bigint not null, + rate decimal(38), + cost decimal(38), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigint auto_increment not null, + machine_id bigint not null, + date date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigint auto_increment not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(38), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigint auto_increment not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id varchar(40) not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigint auto_increment not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table dfk_cascade ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + when_publish datetime(6), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); + +create table earray_bean ( + id bigint auto_increment not null, + foo integer, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + statuses varchar(1000), + vc_enums varchar(1000), + int_enums varchar(1000), + status2 varchar(1000), + version bigint not null, + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigint auto_increment not null, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id integer auto_increment not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigint auto_increment not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigint auto_increment not null, + name varchar(255), + description longtext, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id integer auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + last_update datetime(6), + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + data longblob, + some_time varbinary(255), + last_update datetime(6) not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigint auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer auto_increment not null, + status integer, + name varchar(255), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigint auto_increment not null, + name varchar(255), + map varchar(800), + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigint auto_increment not null, + name varchar(255), + value_set varchar(700), + value_list longtext, + value_map varchar(700), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigint auto_increment not null, + name varchar(255), + value_set varchar(700), + value_list longtext, + value_map varchar(700), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigint auto_increment not null, + name varchar(255), + bean_set varchar(700), + bean_list longtext, + bean_map varchar(700), + plain_bean varchar(500), + flags varchar(50), + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigint auto_increment not null, + owner_id bigint, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id integer auto_increment not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigint auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update datetime(6) not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigint auto_increment not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id integer auto_increment not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update datetime(6) not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id varchar(40) not null, + name varchar(100), + root_id varchar(40) not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id varchar(40) not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigint auto_increment not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer auto_increment not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id integer auto_increment not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id integer auto_increment not null, + nome_outer varchar(255), + date1 datetime(6), + date2 datetime(6), + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + ts_created datetime(6) not null, + ts_updated datetime(6) not null, + ldt_created datetime(6) not null, + ldt_updated datetime(6) not null, + odt_created datetime(6) not null, + odt_updated datetime(6) not null, + zdt_created datetime(6) not null, + zdt_updated datetime(6) not null, + instant_created datetime(6) not null, + instant_updated datetime(6) not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table einvoice ( + id bigint auto_increment not null, + invoice_date datetime(6), + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id integer auto_increment not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id integer auto_increment not null, + name_for_a varchar(255), + b_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id integer auto_increment not null, + name_for_b varchar(255), + c_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id integer auto_increment not null, + name_for_c varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigint auto_increment not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigint auto_increment not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigint auto_increment not null, + email varchar(127), + online_status tinyint(1) default 0 not null, + when_updated datetime(6) not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid integer auto_increment not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigint auto_increment not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigint auto_increment not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigint auto_increment not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigint auto_increment not null, + name varchar(255), + oneb_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigint auto_increment not null, + role_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigint auto_increment not null, + up varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigint auto_increment not null, + user_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigint auto_increment not null, + name varchar(255), + money decimal(38), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id integer auto_increment not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id integer auto_increment not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id integer auto_increment not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id integer auto_increment not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigint auto_increment not null, + name varchar(255), + inet_address varchar(50), + inet2 varchar(255), + cdir varchar(50), + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null +); + +create table ec_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ecbl_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecbm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + number varchar(10) not null +); + +create table ecmc_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value longtext not null +); + +create table ecs_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table td_child ( + child_id integer auto_increment not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer auto_increment not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table empl ( + id bigint auto_increment not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id integer auto_increment not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); + +create table gen_key_table ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_table primary key (id) +); + +create table grand_parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigint auto_increment not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigint auto_increment not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigint auto_increment not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigint auto_increment not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigint auto_increment not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigint auto_increment not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigint auto_increment not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + when_title datetime(6), + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id varchar(40) not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigint auto_increment not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint auto_increment not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified datetime(6), + date_created datetime(6), + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigint auto_increment not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigint auto_increment not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + dirty tinyint(1) default 0 not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigint auto_increment not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id varchar(40) not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id varchar(40), + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id varchar(40) not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id varchar(40) not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + shipping_address_id varchar(40), + billing_address_id varchar(40), + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint auto_increment not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id integer auto_increment not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigint auto_increment not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigint auto_increment not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigint auto_increment not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid integer auto_increment not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid integer auto_increment not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id integer auto_increment not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id varchar(40) not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigint auto_increment not null, + name varchar(255), + when_created datetime(6) not null, + when_updated datetime(6) not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigint auto_increment not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id varchar(40) not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id varchar(40) not null, + special_needs_client_id varchar(40) not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id varchar(40) not null, + name varchar(255), + primary_id varchar(40), + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id varchar(40) not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id varchar(40) not null, + address_data_id varchar(40), + contract_data_id varchar(40) not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id integer auto_increment not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id integer auto_increment not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigint auto_increment not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigint auto_increment not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigint auto_increment not null, + name varchar(255), + ms_many_a_many_b tinyint(1) default 0 not null, + ms_many_b tinyint(1) default 0 not null, + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigint auto_increment not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer auto_increment not null, + name varchar(255), + my_count integer not null, + my_lob longtext, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id integer auto_increment not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created datetime(6) not null +); + +create table o_cached_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint auto_increment not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigint auto_increment not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigint auto_increment not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocar ( + id integer auto_increment not null, + vin varchar(255), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id integer auto_increment not null, + corp_id varchar(50), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id varchar(40) not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id varchar(40) not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table oroad_show_msg ( + id integer auto_increment not null, + company_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_ordered_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id bigint auto_increment not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id integer auto_increment not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id integer auto_increment not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price double, + product_id integer, + cretime datetime(6), + updtime datetime(6) not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(38), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id integer auto_increment not null, + order_id integer, + ship_time datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table organisation ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigint auto_increment not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id integer auto_increment not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigint auto_increment not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigint auto_increment not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigint auto_increment not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigint auto_increment not null, + child varchar(255), + master_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigint auto_increment not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigint auto_increment not null, + one tinyint(1) default 0 not null, + many_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigint auto_increment not null, + topp varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigint auto_increment not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigint auto_increment not null, + optional varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id integer auto_increment not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id integer auto_increment not null, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id varchar(40), + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id integer auto_increment not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigint auto_increment not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigint auto_increment not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint auto_increment not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigint auto_increment not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigint auto_increment not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 longtext, + enc4 varbinary(30), + enc5 varbinary(40), + enc6 longblob, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_password_store_model primary key (id) +); + +create table mt_permission ( + id varchar(40) not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id integer auto_increment not null, + persistent_file_id integer, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigint auto_increment not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigint auto_increment not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigint auto_increment not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigint auto_increment not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer auto_increment not null, + sku varchar(20), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id varchar(40) not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id varchar(40) not null, + ww_id varchar(40) not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigint auto_increment not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigint auto_increment not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id varchar(40) not null, + name varchar(50), + tenant_id varchar(40), + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id varchar(40) not null, + mt_permission_id varchar(40) not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table f_second ( + id bigint auto_increment not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id integer auto_increment not null, + article_id integer, + type integer, + content longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigint auto_increment not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigint auto_increment not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigint auto_increment not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigint auto_increment not null, + sibling_a_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id varchar(40) not null, + name varchar(255), + parent_id varchar(40), + data_container_id varchar(40), + site_address_id varchar(40), + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigint auto_increment not null, + some_enum integer, + name varchar(255), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigint auto_increment not null, + dow integer(1), + mth integer(1), + yr integer, + yr_mth date, + month_day date, + local_date date, + local_date_time datetime(6), + offset_date_time datetime(6), + zoned_date_time datetime(6), + local_time time, + instant datetime(6), + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigint auto_increment not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigint auto_increment not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id integer auto_increment not null, + section_id integer, + title varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id integer auto_increment not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id integer auto_increment not null, + content longblob, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigint auto_increment not null, + description varchar(255), + event_id bigint, + units integer not null, + amount double not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigint auto_increment not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer(3) not null, + id integer auto_increment not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id integer auto_increment not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id integer auto_increment not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active tinyint(1) default 0 not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); + +create table ts_detail_two ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + master_id integer, + constraint pk_ts_detail_two primary key (id) +); + +create table t_atable_thatisrelatively ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); + +create table ts_master_two ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_ts_master_two primary key (id) +); + +create table tuuid_entity ( + id varchar(40) not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint auto_increment not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id integer auto_increment not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table mt_tenant ( + id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint auto_increment not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); + +create table sa_tire ( + id bigint auto_increment not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); + +create table trip ( + id integer auto_increment not null, + vehicle_driver_id integer, + destination varchar(255), + address_id smallint, + star_date datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id integer auto_increment not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table `type` ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigint auto_increment not null, + moda varchar(255), + ts datetime(6), + tstz datetime(6), + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id varchar(40) not null, + parent_id bigint, + deleted tinyint(1) default 0 not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigint auto_increment not null, + child_id varchar(40), + deleted tinyint(1) default 0 not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id integer auto_increment not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount double, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id varchar(40) not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + master_id varchar(40), + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigint auto_increment not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigint auto_increment not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + registration_date datetime(6), + lease_id bigint, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity double, + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id integer auto_increment not null, + name varchar(255), + vehicle_id integer, + address_id smallint, + license_issued_on datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(38), + min_duration integer not null, + day_rate decimal(38), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table warehouses ( + id integer auto_increment not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint auto_increment not null, + version integer not null, + constraint pk_wheel primary key (id) +); + +create table sa_wheel ( + id bigint auto_increment not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); + +create table sp_car_wheel ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); + +create table g_who_props_otm ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigint auto_increment not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id integer auto_increment not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id varchar(40) not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id integer auto_increment not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_organization_node_kind on organization_node (kind); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references `type` (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ts_detail_two_master_id on ts_detail_two (master_id); +alter table ts_detail_two add constraint fk_ts_detail_two_master_id foreign key (master_id) references ts_master_two (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on `type` (sub_type_id); +alter table `type` add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add column sys_period_start datetime(6) default now(6); +alter table hx_link add column sys_period_end datetime(6); +update hx_link set sys_period_start = when_created; +create table hx_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period_start datetime(6) default now(6); +alter table hi_link add column sys_period_end datetime(6); +update hi_link set sys_period_start = when_created; +create table hi_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period_start datetime(6) default now(6); +alter table hi_link_doc add column sys_period_end datetime(6); +create table hi_link_doc_history( + hi_link_id bigint, + hi_doc_id bigint, + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period_start datetime(6) default now(6); +alter table hi_tone add column sys_period_end datetime(6); +update hi_tone set sys_period_start = when_created; +create table hi_tone_history( + id bigint, + name varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period_start datetime(6) default now(6); +alter table hi_tthree add column sys_period_end datetime(6); +update hi_tthree set sys_period_start = when_created; +create table hi_tthree_history( + id bigint, + hi_ttwo_id bigint, + three varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period_start datetime(6) default now(6); +alter table hi_ttwo add column sys_period_end datetime(6); +update hi_ttwo set sys_period_start = when_created; +create table hi_ttwo_history( + id bigint, + hi_tone_id bigint, + two varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period_start datetime(6) default now(6); +alter table hsd_setting add column sys_period_end datetime(6); +update hsd_setting set sys_period_start = when_created; +create table hsd_setting_history( + id bigint, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period_start datetime(6) default now(6); +alter table hsd_user add column sys_period_end datetime(6); +update hsd_user set sys_period_start = when_created; +create table hsd_user_history( + id bigint, + name varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period_start datetime(6) default now(6); +alter table link add column sys_period_end datetime(6); +update link set sys_period_start = when_created; +create table link_history( + id bigint, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period_start datetime(6) default now(6); +alter table c_user add column sys_period_end datetime(6); +update c_user set sys_period_start = when_created; +create table c_user_history( + id bigint, + inactive tinyint(1), + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +delimiter $$ +create trigger hx_link_history_upd before update on hx_link for each row begin + insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hx_link_history_del before delete on hx_link for each row begin + insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger hi_link_history_upd before update on hi_link for each row begin + insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_link_history_del before delete on hi_link for each row begin + insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_link_doc_history_upd before update on hi_link_doc for each row begin + insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_link_doc_history_del before delete on hi_link_doc for each row begin + insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); +end$$ +delimiter $$ +create trigger hi_tone_history_upd before update on hi_tone for each row begin + insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_tone_history_del before delete on hi_tone for each row begin + insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_tthree_history_upd before update on hi_tthree for each row begin + insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_tthree_history_del before delete on hi_tthree for each row begin + insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_ttwo_history_upd before update on hi_ttwo for each row begin + insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_ttwo_history_del before delete on hi_ttwo for each row begin + insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hsd_setting_history_upd before update on hsd_setting for each row begin + insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hsd_setting_history_del before delete on hsd_setting for each row begin + insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger hsd_user_history_upd before update on hsd_user for each row begin + insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hsd_user_history_del before delete on hsd_user for each row begin + insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger link_history_upd before update on link for each row begin + insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger link_history_del before delete on link for each row begin + insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger c_user_history_upd before update on c_user for each row begin + insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger c_user_history_del before delete on c_user for each row begin + insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); +end$$ diff --git a/src/test/resources/dbmig_mysql/mysql-drop-all.sql b/src/test/resources/dbmig_mysql/mysql-drop-all.sql new file mode 100644 index 0000000..c3bcf7d --- /dev/null +++ b/src/test/resources/dbmig_mysql/mysql-drop-all.sql @@ -0,0 +1,1730 @@ +-- Generated by ebean unknown at 2019-07-25T07:02:24.426Z +alter table bar drop foreign key fk_bar_foo_id; +drop index ix_bar_foo_id on bar; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_container_id; +drop index ix_acl_container_relation_container_id on acl_container_relation; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_acl_entry_id; +drop index ix_acl_container_relation_acl_entry_id on acl_container_relation; + +alter table addr drop foreign key fk_addr_employee_id; +drop index ix_addr_employee_id on addr; + +alter table o_address drop foreign key fk_o_address_country_code; +drop index ix_o_address_country_code on o_address; + +alter table album drop foreign key fk_album_cover_id; + +alter table animal drop foreign key fk_animal_shelter_id; +drop index ix_animal_shelter_id on animal; + +alter table attribute drop foreign key fk_attribute_attribute_holder_id; +drop index ix_attribute_attribute_holder_id on attribute; + +alter table bbookmark drop foreign key fk_bbookmark_user_id; +drop index ix_bbookmark_user_id on bbookmark; + +alter table bbookmark_user drop foreign key fk_bbookmark_user_org_id; +drop index ix_bbookmark_user_org_id on bbookmark_user; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_site_id; +drop index ix_bsite_user_a_site_id on bsite_user_a; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_user_id; +drop index ix_bsite_user_a_user_id on bsite_user_a; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_site; +drop index ix_bsite_user_b_site on bsite_user_b; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_usr; +drop index ix_bsite_user_b_usr on bsite_user_b; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_site_uid; +drop index ix_bsite_user_c_site_uid on bsite_user_c; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_user_uid; +drop index ix_bsite_user_c_user_uid on bsite_user_c; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_site_id; +drop index ix_bsite_user_e_site_id on bsite_user_e; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_user_id; +drop index ix_bsite_user_e_user_id on bsite_user_e; + +alter table basic_draftable_bean drop foreign key fk_basic_draftable_bean_id; + +alter table drel_booking drop foreign key fk_drel_booking_agent_invoice; + +alter table drel_booking drop foreign key fk_drel_booking_client_invoice; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_category_id; +drop index ix_cepproduct_category_category_id on cepproduct_category; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_product_id; +drop index ix_cepproduct_category_product_id on cepproduct_category; + +alter table cinh_ref drop foreign key fk_cinh_ref_ref_id; +drop index ix_cinh_ref_ref_id on cinh_ref; + +alter table ckey_detail drop foreign key fk_ckey_detail_parent; +drop index ix_ckey_detail_parent on ckey_detail; + +alter table ckey_parent drop foreign key fk_ckey_parent_assoc_id; +drop index ix_ckey_parent_assoc_id on ckey_parent; + +alter table calculation_result drop foreign key fk_calculation_result_product_configuration_id; +drop index ix_calculation_result_product_configuration_id on calculation_result; + +alter table calculation_result drop foreign key fk_calculation_result_group_configuration_id; +drop index ix_calculation_result_group_configuration_id on calculation_result; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_car; +drop index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_wheel; +drop index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_car; +drop index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_door; +drop index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors; + +alter table car_accessory drop foreign key fk_car_accessory_fuse_id; +drop index ix_car_accessory_fuse_id on car_accessory; + +alter table car_accessory drop foreign key fk_car_accessory_car_id; +drop index ix_car_accessory_car_id on car_accessory; + +alter table category drop foreign key fk_category_surveyobjectid; +drop index ix_category_surveyobjectid on category; + +alter table e_save_test_d drop foreign key fk_e_save_test_d_parent_id; + +alter table child_person drop foreign key fk_child_person_some_bean_id; +drop index ix_child_person_some_bean_id on child_person; + +alter table child_person drop foreign key fk_child_person_parent_identifier; +drop index ix_child_person_parent_identifier on child_person; + +alter table cke_client drop foreign key fk_cke_client_user; +drop index ix_cke_client_user on cke_client; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_class_super; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_monkey; + +alter table configuration drop foreign key fk_configuration_configurations_id; +drop index ix_configuration_configurations_id on configuration; + +alter table contact drop foreign key fk_contact_customer_id; +drop index ix_contact_customer_id on contact; + +alter table contact drop foreign key fk_contact_group_id; +drop index ix_contact_group_id on contact; + +alter table contact_note drop foreign key fk_contact_note_contact_id; +drop index ix_contact_note_contact_id on contact_note; + +alter table contract_costs drop foreign key fk_contract_costs_position_id; +drop index ix_contract_costs_position_id on contract_costs; + +alter table c_conversation drop foreign key fk_c_conversation_group_id; +drop index ix_c_conversation_group_id on c_conversation; + +alter table o_customer drop foreign key fk_o_customer_billing_address_id; +drop index ix_o_customer_billing_address_id on o_customer; + +alter table o_customer drop foreign key fk_o_customer_shipping_address_id; +drop index ix_o_customer_shipping_address_id on o_customer; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_dcredit; +drop index ix_dcredit_drol_dcredit on dcredit_drol; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_drol; +drop index ix_dcredit_drol_drol on dcredit_drol; + +alter table dmachine drop foreign key fk_dmachine_organisation_id; +drop index ix_dmachine_organisation_id on dmachine; + +alter table d_machine_aux_use drop foreign key fk_d_machine_aux_use_machine_id; +drop index ix_d_machine_aux_use_machine_id on d_machine_aux_use; + +alter table d_machine_stats drop foreign key fk_d_machine_stats_machine_id; +drop index ix_d_machine_stats_machine_id on d_machine_stats; + +alter table d_machine_use drop foreign key fk_d_machine_use_machine_id; +drop index ix_d_machine_use_machine_id on d_machine_use; + +alter table drot_drol drop foreign key fk_drot_drol_drot; +drop index ix_drot_drol_drot on drot_drol; + +alter table drot_drol drop foreign key fk_drot_drol_drol; +drop index ix_drot_drol_drol on drot_drol; + +alter table dc_detail drop foreign key fk_dc_detail_master_id; +drop index ix_dc_detail_master_id on dc_detail; + +alter table dfk_cascade drop foreign key fk_dfk_cascade_one_id; +drop index ix_dfk_cascade_one_id on dfk_cascade; + +alter table dfk_set_null drop foreign key fk_dfk_set_null_one_id; +drop index ix_dfk_set_null_one_id on dfk_set_null; + +alter table doc drop foreign key fk_doc_id; + +alter table doc_link drop foreign key fk_doc_link_doc; +drop index ix_doc_link_doc on doc_link; + +alter table doc_link drop foreign key fk_doc_link_link; +drop index ix_doc_link_link on doc_link; + +alter table document drop foreign key fk_document_id; + +alter table document drop foreign key fk_document_organisation_id; +drop index ix_document_organisation_id on document; + +alter table document_draft drop foreign key fk_document_draft_organisation_id; +drop index ix_document_draft_organisation_id on document_draft; + +alter table document_media drop foreign key fk_document_media_document_id; +drop index ix_document_media_document_id on document_media; + +alter table document_media_draft drop foreign key fk_document_media_draft_document_id; +drop index ix_document_media_draft_document_id on document_media_draft; + +alter table ebasic_json_map_detail drop foreign key fk_ebasic_json_map_detail_owner_id; +drop index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail; + +alter table ebasic_no_sdchild drop foreign key fk_ebasic_no_sdchild_owner_id; +drop index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild; + +alter table ebasic_sdchild drop foreign key fk_ebasic_sdchild_owner_id; +drop index ix_ebasic_sdchild_owner_id on ebasic_sdchild; + +alter table ecache_child drop foreign key fk_ecache_child_root_id; +drop index ix_ecache_child_root_id on ecache_child; + +alter table edefault_prop drop foreign key fk_edefault_prop_e_simple_usertypeid; + +alter table eemb_inner drop foreign key fk_eemb_inner_outer_id; +drop index ix_eemb_inner_outer_id on eemb_inner; + +alter table einvoice drop foreign key fk_einvoice_person_id; +drop index ix_einvoice_person_id on einvoice; + +alter table enull_collection_detail drop foreign key fk_enull_collection_detail_enull_collection_id; +drop index ix_enull_collection_detail_enull_collection_id on enull_collection_detail; + +alter table eopt_one_a drop foreign key fk_eopt_one_a_b_id; +drop index ix_eopt_one_a_b_id on eopt_one_a; + +alter table eopt_one_b drop foreign key fk_eopt_one_b_c_id; +drop index ix_eopt_one_b_c_id on eopt_one_b; + +alter table eper_addr drop foreign key fk_eper_addr_ma_country_code; +drop index ix_eper_addr_ma_country_code on eper_addr; + +alter table esoft_del_book drop foreign key fk_esoft_del_book_lend_by_id; +drop index ix_esoft_del_book_lend_by_id on esoft_del_book; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_book; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user; + +alter table esoft_del_down drop foreign key fk_esoft_del_down_esoft_del_mid_id; +drop index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_top_id; +drop index ix_esoft_del_mid_top_id on esoft_del_mid; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_up_id; +drop index ix_esoft_del_mid_up_id on esoft_del_mid; + +alter table esoft_del_one_a drop foreign key fk_esoft_del_one_a_oneb_id; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_role; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_user; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_role; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role; + +alter table rawinherit_uncle drop foreign key fk_rawinherit_uncle_parent_id; +drop index ix_rawinherit_uncle_parent_id on rawinherit_uncle; + +alter table evanilla_collection_detail drop foreign key fk_evanilla_collection_detail_evanilla_collection_id; +drop index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail; + +alter table ec_enum_person_tags drop foreign key fk_ec_enum_person_tags_ec_enum_person_id; +drop index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags; + +alter table ec_person_phone drop foreign key fk_ec_person_phone_owner_id; +drop index ix_ec_person_phone_owner_id on ec_person_phone; + +alter table ecbl_person_phone_numbers drop foreign key fk_ecbl_person_phone_numbers_person_id; +drop index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers; + +alter table ecbm_person_phone_numbers drop foreign key fk_ecbm_person_phone_numbers_person_id; +drop index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers; + +alter table ecm_person_phone_numbers drop foreign key fk_ecm_person_phone_numbers_ecm_person_id; +drop index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers; + +alter table ecmc_person_phone_numbers drop foreign key fk_ecmc_person_phone_numbers_ecmc_person_id; +drop index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers; + +alter table ecs_person_phone drop foreign key fk_ecs_person_phone_ecs_person_id; +drop index ix_ecs_person_phone_ecs_person_id on ecs_person_phone; + +alter table td_child drop foreign key fk_td_child_parent_id; +drop index ix_td_child_parent_id on td_child; + +alter table empl drop foreign key fk_empl_default_address_id; +drop index ix_empl_default_address_id on empl; + +alter table esd_detail drop foreign key fk_esd_detail_master_id; +drop index ix_esd_detail_master_id on esd_detail; + +alter table grand_parent_person drop foreign key fk_grand_parent_person_some_bean_id; +drop index ix_grand_parent_person_some_bean_id on grand_parent_person; + +alter table survey_group drop foreign key fk_survey_group_categoryobjectid; +drop index ix_survey_group_categoryobjectid on survey_group; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_hx_link; +drop index ix_hx_link_doc_hx_link on hx_link_doc; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_he_doc; +drop index ix_hx_link_doc_he_doc on hx_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_link; +drop index ix_hi_link_doc_hi_link on hi_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_doc; +drop index ix_hi_link_doc_hi_doc on hi_link_doc; + +alter table hi_tthree drop foreign key fk_hi_tthree_hi_ttwo_id; +drop index ix_hi_tthree_hi_ttwo_id on hi_tthree; + +alter table hi_ttwo drop foreign key fk_hi_ttwo_hi_tone_id; +drop index ix_hi_ttwo_hi_tone_id on hi_ttwo; + +alter table hsd_setting drop foreign key fk_hsd_setting_user_id; + +alter table iaf_segment drop foreign key fk_iaf_segment_status_id; +drop index ix_iaf_segment_status_id on iaf_segment; + +alter table imrelated drop foreign key fk_imrelated_owner_id; +drop index ix_imrelated_owner_id on imrelated; + +alter table info_contact drop foreign key fk_info_contact_company_id; +drop index ix_info_contact_company_id on info_contact; + +alter table info_customer drop foreign key fk_info_customer_company_id; + +alter table inner_report drop foreign key fk_inner_report_forecast_id; + +alter table drel_invoice drop foreign key fk_drel_invoice_booking; +drop index ix_drel_invoice_booking on drel_invoice; + +alter table item drop foreign key fk_item_etype; +drop index ix_item_etype on item; + +alter table item drop foreign key fk_item_eregion; +drop index ix_item_eregion on item; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_mkeygroup; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_monkey; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_trainer; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_monkey; + +alter table troop_monkey drop foreign key fk_troop_monkey_troop; + +alter table troop_monkey drop foreign key fk_troop_monkey_monkey; + +alter table l2_cldf_reset_bean_child drop foreign key fk_l2_cldf_reset_bean_child_parent_id; +drop index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child; + +alter table level1_level4 drop foreign key fk_level1_level4_level1; +drop index ix_level1_level4_level1 on level1_level4; + +alter table level1_level4 drop foreign key fk_level1_level4_level4; +drop index ix_level1_level4_level4 on level1_level4; + +alter table level1_level2 drop foreign key fk_level1_level2_level1; +drop index ix_level1_level2_level1 on level1_level2; + +alter table level1_level2 drop foreign key fk_level1_level2_level2; +drop index ix_level1_level2_level2 on level1_level2; + +alter table level2_level3 drop foreign key fk_level2_level3_level2; +drop index ix_level2_level3_level2 on level2_level3; + +alter table level2_level3 drop foreign key fk_level2_level3_level3; +drop index ix_level2_level3_level3 on level2_level3; + +alter table link drop foreign key fk_link_id; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_la_attr_value; +drop index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_attribute; +drop index ix_la_attr_value_attribute_attribute on la_attr_value_attribute; + +alter table looney drop foreign key fk_looney_tune_id; +drop index ix_looney_tune_id on looney; + +alter table mcontact drop foreign key fk_mcontact_customer_id; +drop index ix_mcontact_customer_id on mcontact; + +alter table mcontact_message drop foreign key fk_mcontact_message_contact_id; +drop index ix_mcontact_message_contact_id on mcontact_message; + +alter table mcustomer drop foreign key fk_mcustomer_shipping_address_id; +drop index ix_mcustomer_shipping_address_id on mcustomer; + +alter table mcustomer drop foreign key fk_mcustomer_billing_address_id; +drop index ix_mcustomer_billing_address_id on mcustomer; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mmachine; +drop index ix_mmachine_mgroup_mmachine on mmachine_mgroup; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mgroup; +drop index ix_mmachine_mgroup_mgroup on mmachine_mgroup; + +alter table mprinter drop foreign key fk_mprinter_current_state_id; +drop index ix_mprinter_current_state_id on mprinter; + +alter table mprinter drop foreign key fk_mprinter_last_swap_cyan_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_magenta_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_yellow_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_black_id; + +alter table mprinter_state drop foreign key fk_mprinter_state_printer_id; +drop index ix_mprinter_state_printer_id on mprinter_state; + +alter table mprofile drop foreign key fk_mprofile_picture_id; +drop index ix_mprofile_picture_id on mprofile; + +alter table mrole_muser drop foreign key fk_mrole_muser_mrole; +drop index ix_mrole_muser_mrole on mrole_muser; + +alter table mrole_muser drop foreign key fk_mrole_muser_muser; +drop index ix_mrole_muser_muser on mrole_muser; + +alter table muser drop foreign key fk_muser_user_type_id; +drop index ix_muser_user_type_id on muser; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_user; +drop index ix_mail_user_inbox_mail_user on mail_user_inbox; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_box; +drop index ix_mail_user_inbox_mail_box on mail_user_inbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_user; +drop index ix_mail_user_outbox_mail_user on mail_user_outbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_box; +drop index ix_mail_user_outbox_mail_box on mail_user_outbox; + +alter table c_message drop foreign key fk_c_message_conversation_id; +drop index ix_c_message_conversation_id on c_message; + +alter table c_message drop foreign key fk_c_message_user_id; +drop index ix_c_message_user_id on c_message; + +alter table meter_contract_data drop foreign key fk_meter_contract_data_special_needs_client_id; + +alter table meter_special_needs_client drop foreign key fk_meter_special_needs_client_primary_id; + +alter table meter_version drop foreign key fk_meter_version_address_data_id; + +alter table meter_version drop foreign key fk_meter_version_contract_data_id; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_user; +drop index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_role; +drop index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role; + +alter table mny_b drop foreign key fk_mny_b_a_id; +drop index ix_mny_b_a_id on mny_b; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_b; +drop index ix_mny_b_mny_c_mny_b on mny_b_mny_c; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_c; +drop index ix_mny_b_mny_c_mny_c on mny_b_mny_c; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_1; +drop index ix_subtopics_mny_topic_1 on subtopics; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_2; +drop index ix_subtopics_mny_topic_2 on subtopics; + +alter table mp_role drop foreign key fk_mp_role_mp_user_id; +drop index ix_mp_role_mp_user_id on mp_role; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_a; +drop index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_b; +drop index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_b; +drop index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_a; +drop index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a; + +alter table my_lob_size_join_many drop foreign key fk_my_lob_size_join_many_parent_id; +drop index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_cached_bean; +drop index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_country; +drop index ix_o_cached_bean_country_o_country on o_cached_bean_country; + +alter table o_cached_bean_child drop foreign key fk_o_cached_bean_child_cached_bean_id; +drop index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child; + +alter table oengine drop foreign key fk_oengine_car_id; + +alter table ogear_box drop foreign key fk_ogear_box_car_id; + +alter table oroad_show_msg drop foreign key fk_oroad_show_msg_company_id; + +alter table om_ordered_detail drop foreign key fk_om_ordered_detail_master_id; +drop index ix_om_ordered_detail_master_id on om_ordered_detail; + +alter table o_order drop foreign key fk_o_order_kcustomer_id; +drop index ix_o_order_kcustomer_id on o_order; + +alter table o_order_detail drop foreign key fk_o_order_detail_order_id; +drop index ix_o_order_detail_order_id on o_order_detail; + +alter table o_order_detail drop foreign key fk_o_order_detail_product_id; +drop index ix_o_order_detail_product_id on o_order_detail; + +alter table s_order_items drop foreign key fk_s_order_items_order_uuid; +drop index ix_s_order_items_order_uuid on s_order_items; + +alter table or_order_ship drop foreign key fk_or_order_ship_order_id; +drop index ix_or_order_ship_order_id on or_order_ship; + +alter table organization_node drop foreign key fk_organization_node_parent_tree_node_id; + +alter table orp_detail drop foreign key fk_orp_detail_master_id; +drop index ix_orp_detail_master_id on orp_detail; + +alter table orp_detail2 drop foreign key fk_orp_detail2_orp_master2_id; +drop index ix_orp_detail2_orp_master2_id on orp_detail2; + +alter table oto_atwo drop foreign key fk_oto_atwo_aone_id; + +alter table oto_bchild drop foreign key fk_oto_bchild_master_id; + +alter table oto_child drop foreign key fk_oto_child_master_id; + +alter table oto_cust_address drop foreign key fk_oto_cust_address_customer_cid; + +alter table oto_level_a drop foreign key fk_oto_level_a_b_id; + +alter table oto_level_b drop foreign key fk_oto_level_b_c_id; + +alter table oto_prime_extra drop foreign key fk_oto_prime_extra_eid; + +alter table oto_sd_child drop foreign key fk_oto_sd_child_master_id; + +alter table oto_th_many drop foreign key fk_oto_th_many_oto_th_top_id; +drop index ix_oto_th_many_oto_th_top_id on oto_th_many; + +alter table oto_th_one drop foreign key fk_oto_th_one_many_id; + +alter table oto_ubprime_extra drop foreign key fk_oto_ubprime_extra_eid; + +alter table oto_user_model drop foreign key fk_oto_user_model_user_optional_id; + +alter table pfile drop foreign key fk_pfile_file_content_id; + +alter table pfile drop foreign key fk_pfile_file_content2_id; + +alter table paggview drop foreign key fk_paggview_pview_id; + +alter table pallet_location drop foreign key fk_pallet_location_zone_sid; +drop index ix_pallet_location_zone_sid on pallet_location; + +alter table parcel_location drop foreign key fk_parcel_location_parcelid; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_data; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data; + +alter table parent_person drop foreign key fk_parent_person_some_bean_id; +drop index ix_parent_person_some_bean_id on parent_person; + +alter table parent_person drop foreign key fk_parent_person_parent_identifier; +drop index ix_parent_person_parent_identifier on parent_person; + +alter table c_participation drop foreign key fk_c_participation_conversation_id; +drop index ix_c_participation_conversation_id on c_participation; + +alter table c_participation drop foreign key fk_c_participation_user_id; +drop index ix_c_participation_user_id on c_participation; + +alter table persistent_file_content drop foreign key fk_persistent_file_content_persistent_file_id; + +alter table person drop foreign key fk_person_default_address_oid; +drop index ix_person_default_address_oid on person; + +alter table person_cache_email drop foreign key fk_person_cache_email_person_info_person_id; +drop index ix_person_cache_email_person_info_person_id on person_cache_email; + +alter table phones drop foreign key fk_phones_person_id; +drop index ix_phones_person_id on phones; + +alter table e_position drop foreign key fk_e_position_contract_id; +drop index ix_e_position_contract_id on e_position; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_pp; +drop index ix_pp_to_ww_pp on pp_to_ww; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_wview; +drop index ix_pp_to_ww_wview on pp_to_ww; + +alter table question drop foreign key fk_question_groupobjectid; +drop index ix_question_groupobjectid on question; + +alter table r_orders drop foreign key fk_r_orders_customer; +drop index ix_r_orders_customer on r_orders; + +alter table rel_master drop foreign key fk_rel_master_detail_id; +drop index ix_rel_master_detail_id on rel_master; + +alter table resourcefile drop foreign key fk_resourcefile_parentresourcefileid; +drop index ix_resourcefile_parentresourcefileid on resourcefile; + +alter table mt_role drop foreign key fk_mt_role_tenant_id; +drop index ix_mt_role_tenant_id on mt_role; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_role; +drop index ix_mt_role_permission_mt_role on mt_role_permission; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_permission; +drop index ix_mt_role_permission_mt_permission on mt_role_permission; + +alter table f_second drop foreign key fk_f_second_first; + +alter table section drop foreign key fk_section_article_id; +drop index ix_section_article_id on section; + +alter table self_parent drop foreign key fk_self_parent_parent_id; +drop index ix_self_parent_parent_id on self_parent; + +alter table self_ref_customer drop foreign key fk_self_ref_customer_referred_by_id; +drop index ix_self_ref_customer_referred_by_id on self_ref_customer; + +alter table self_ref_example drop foreign key fk_self_ref_example_parent_id; +drop index ix_self_ref_example_parent_id on self_ref_example; + +alter table e_save_test_b drop foreign key fk_e_save_test_b_sibling_a_id; + +alter table site drop foreign key fk_site_parent_id; +drop index ix_site_parent_id on site; + +alter table site drop foreign key fk_site_data_container_id; + +alter table site drop foreign key fk_site_site_address_id; + +alter table stockforecast drop foreign key fk_stockforecast_inner_report_id; +drop index ix_stockforecast_inner_report_id on stockforecast; + +alter table sub_section drop foreign key fk_sub_section_section_id; +drop index ix_sub_section_section_id on sub_section; + +alter table tevent_many drop foreign key fk_tevent_many_event_id; +drop index ix_tevent_many_event_id on tevent_many; + +alter table tevent_one drop foreign key fk_tevent_one_event_id; + +alter table t_detail_with_other_namexxxyy drop foreign key fk_t_detail_with_other_namexxxyy_master_id; +drop index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy; + +alter table ts_detail_two drop foreign key fk_ts_detail_two_master_id; +drop index ix_ts_detail_two_master_id on ts_detail_two; + +alter table twheel drop foreign key fk_twheel_owner_plate_no; +drop index ix_twheel_owner_plate_no on twheel; + +alter table tire drop foreign key fk_tire_wheel; + +alter table trip drop foreign key fk_trip_vehicle_driver_id; +drop index ix_trip_vehicle_driver_id on trip; + +alter table trip drop foreign key fk_trip_address_id; +drop index ix_trip_address_id on trip; + +alter table `type` drop foreign key fk_type_sub_type_id; +drop index ix_type_sub_type_id on `type`; + +alter table usib_child drop foreign key fk_usib_child_parent_id; +drop index ix_usib_child_parent_id on usib_child; + +alter table usib_child_sibling drop foreign key fk_usib_child_sibling_child_id; + +alter table ut_detail drop foreign key fk_ut_detail_utmaster_id; +drop index ix_ut_detail_utmaster_id on ut_detail; + +alter table uutwo drop foreign key fk_uutwo_master_id; +drop index ix_uutwo_master_id on uutwo; + +alter table oto_user drop foreign key fk_oto_user_account_id; + +alter table c_user drop foreign key fk_c_user_group_id; +drop index ix_c_user_group_id on c_user; + +alter table em_user_role drop foreign key fk_em_user_role_user_id; +drop index ix_em_user_role_user_id on em_user_role; + +alter table em_user_role drop foreign key fk_em_user_role_role_id; +drop index ix_em_user_role_role_id on em_user_role; + +alter table vehicle drop foreign key fk_vehicle_lease_id; +drop index ix_vehicle_lease_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_car_ref_id; +drop index ix_vehicle_car_ref_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_truck_ref_id; +drop index ix_vehicle_truck_ref_id on vehicle; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_vehicle_id; +drop index ix_vehicle_driver_vehicle_id on vehicle_driver; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_address_id; +drop index ix_vehicle_driver_address_id on vehicle_driver; + +alter table warehouses drop foreign key fk_warehouses_officezoneid; +drop index ix_warehouses_officezoneid on warehouses; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_warehouses; +drop index ix_warehousesshippingzones_warehouses on warehousesshippingzones; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_zones; +drop index ix_warehousesshippingzones_zones on warehousesshippingzones; + +alter table sa_wheel drop foreign key fk_sa_wheel_tire; +drop index ix_sa_wheel_tire on sa_wheel; + +alter table sa_wheel drop foreign key fk_sa_wheel_car; +drop index ix_sa_wheel_car on sa_wheel; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_created_id; +drop index ix_g_who_props_otm_who_created_id on g_who_props_otm; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_modified_id; +drop index ix_g_who_props_otm_who_modified_id on g_who_props_otm; + +alter table with_zero drop foreign key fk_with_zero_parent_id; +drop index ix_with_zero_parent_id on with_zero; + +drop table if exists asimple_bean; + +drop table if exists bar; + +drop table if exists block; + +drop table if exists oto_account; + +drop table if exists acl; + +drop table if exists acl_container_relation; + +drop table if exists addr; + +drop table if exists address; + +drop table if exists o_address; + +drop table if exists album; + +drop table if exists animal; + +drop table if exists animal_shelter; + +drop table if exists article; + +drop table if exists attribute; + +drop table if exists attribute_holder; + +drop table if exists audit_log; + +drop table if exists bbookmark; + +drop table if exists bbookmark_org; + +drop table if exists bbookmark_user; + +drop table if exists bsimple_with_gen; + +drop table if exists bsite; + +drop table if exists bsite_user_a; + +drop table if exists bsite_user_b; + +drop table if exists bsite_user_c; + +drop table if exists bsite_user_d; + +drop table if exists bsite_user_e; + +drop table if exists buser; + +drop table if exists bwith_qident; + +drop table if exists basic_draftable_bean; + +drop table if exists basic_draftable_bean_draft; + +drop table if exists basic_joda_entity; + +drop table if exists bean_with_time_zone; + +drop table if exists drel_booking; + +drop table if exists bw_bean; + +drop table if exists cepcategory; + +drop table if exists cepproduct; + +drop table if exists cepproduct_category; + +drop table if exists cinh_ref; + +drop table if exists cinh_root; + +drop table if exists ckey_assoc; + +drop table if exists ckey_detail; + +drop table if exists ckey_parent; + +drop table if exists calculation_result; + +drop table if exists cao_bean; + +drop table if exists sp_car_car; + +drop table if exists sp_car_car_wheels; + +drop table if exists sp_car_car_doors; + +drop table if exists sa_car; + +drop table if exists car_accessory; + +drop table if exists car_fuse; + +drop table if exists category; + +drop table if exists e_save_test_d; + +drop table if exists child_person; + +drop table if exists cke_client; + +drop table if exists cke_user; + +drop table if exists class_super; + +drop table if exists class_super_monkey; + +drop table if exists configuration; + +drop table if exists configurations; + +drop table if exists contact; + +drop table if exists contact_group; + +drop table if exists contact_note; + +drop table if exists contract; + +drop table if exists contract_costs; + +drop table if exists c_conversation; + +drop table if exists o_country; + +drop table if exists cover; + +drop table if exists o_customer; + +drop table if exists dcredit; + +drop table if exists dcredit_drol; + +drop table if exists dexh_entity; + +drop table if exists dmachine; + +drop table if exists d_machine_aux_use; + +drop table if exists d_machine_stats; + +drop table if exists d_machine_use; + +drop table if exists dorg; + +drop table if exists dperson; + +drop table if exists drol; + +drop table if exists drot; + +drop table if exists drot_drol; + +drop table if exists rawinherit_data; + +drop table if exists data_container; + +drop table if exists dc_detail; + +drop table if exists dc_master; + +drop table if exists dfk_cascade; + +drop table if exists dfk_cascade_one; + +drop table if exists dfk_none; + +drop table if exists dfk_none_via_join; + +drop table if exists dfk_none_via_mto_m; + +drop table if exists dfk_none_via_mto_m_dfk_one; + +drop table if exists dfk_one; + +drop table if exists dfk_set_null; + +drop table if exists doc; + +drop table if exists doc_link; + +drop table if exists doc_link_draft; + +drop table if exists doc_draft; + +drop table if exists document; + +drop table if exists document_draft; + +drop table if exists document_media; + +drop table if exists document_media_draft; + +drop table if exists sp_car_door; + +drop table if exists earray_bean; + +drop table if exists earray_set_bean; + +drop table if exists e_basic; + +drop table if exists ebasic_change_log; + +drop table if exists ebasic_clob; + +drop table if exists ebasic_clob_fetch_eager; + +drop table if exists ebasic_clob_no_ver; + +drop table if exists e_basicenc; + +drop table if exists e_basicenc_bin; + +drop table if exists e_basicenc_client; + +drop table if exists e_basic_enum_id; + +drop table if exists e_basic_eni; + +drop table if exists ebasic_hstore; + +drop table if exists ebasic_json_jackson; + +drop table if exists ebasic_json_jackson2; + +drop table if exists ebasic_json_list; + +drop table if exists ebasic_json_map; + +drop table if exists ebasic_json_map_blob; + +drop table if exists ebasic_json_map_clob; + +drop table if exists ebasic_json_map_detail; + +drop table if exists ebasic_json_map_json_b; + +drop table if exists ebasic_json_map_varchar; + +drop table if exists ebasic_json_node; + +drop table if exists ebasic_json_node_blob; + +drop table if exists ebasic_json_node_json_b; + +drop table if exists ebasic_json_node_varchar; + +drop table if exists ebasic_json_unmapped; + +drop table if exists e_basic_ndc; + +drop table if exists ebasic_no_sdchild; + +drop table if exists ebasic_sdchild; + +drop table if exists ebasic_soft_delete; + +drop table if exists e_basicver; + +drop table if exists e_basic_withlife; + +drop table if exists e_basic_with_ex; + +drop table if exists e_basicverucon; + +drop table if exists ecache_child; + +drop table if exists ecache_root; + +drop table if exists e_col_ab; + +drop table if exists ecustom_id; + +drop table if exists edefault_prop; + +drop table if exists eemb_inner; + +drop table if exists eemb_outer; + +drop table if exists efile2_no_fk; + +drop table if exists efile_no_fk; + +drop table if exists efile_no_fk_euser_no_fk; + +drop table if exists efile_no_fk_euser_no_fk_soft_del; + +drop table if exists egen_props; + +drop table if exists einvoice; + +drop table if exists e_main; + +drop table if exists enull_collection; + +drop table if exists enull_collection_detail; + +drop table if exists eopt_one_a; + +drop table if exists eopt_one_b; + +drop table if exists eopt_one_c; + +drop table if exists eper_addr; + +drop table if exists eperson; + +drop table if exists e_person_online; + +drop table if exists esimple; + +drop table if exists esoft_del_book; + +drop table if exists esoft_del_book_esoft_del_user; + +drop table if exists esoft_del_down; + +drop table if exists esoft_del_mid; + +drop table if exists esoft_del_one_a; + +drop table if exists esoft_del_one_b; + +drop table if exists esoft_del_role; + +drop table if exists esoft_del_role_esoft_del_user; + +drop table if exists esoft_del_top; + +drop table if exists esoft_del_up; + +drop table if exists esoft_del_user; + +drop table if exists esoft_del_user_esoft_del_role; + +drop table if exists esome_convert_type; + +drop table if exists esome_type; + +drop table if exists etrans_many; + +drop table if exists rawinherit_uncle; + +drop table if exists euser_no_fk; + +drop table if exists euser_no_fk_soft_del; + +drop table if exists evanilla_collection; + +drop table if exists evanilla_collection_detail; + +drop table if exists ewho_props; + +drop table if exists e_withinet; + +drop table if exists ec_enum_person; + +drop table if exists ec_enum_person_tags; + +drop table if exists ec_person; + +drop table if exists ec_person_phone; + +drop table if exists ecbl_person; + +drop table if exists ecbl_person_phone_numbers; + +drop table if exists ecbm_person; + +drop table if exists ecbm_person_phone_numbers; + +drop table if exists ecm_person; + +drop table if exists ecm_person_phone_numbers; + +drop table if exists ecmc_person; + +drop table if exists ecmc_person_phone_numbers; + +drop table if exists ecs_person; + +drop table if exists ecs_person_phone; + +drop table if exists td_child; + +drop table if exists td_parent; + +drop table if exists empl; + +drop table if exists esd_detail; + +drop table if exists esd_master; + +drop table if exists feature_desc; + +drop table if exists f_first; + +drop table if exists foo; + +drop table if exists gen_key_identity; + +drop table if exists gen_key_sequence; + +drop table if exists gen_key_table; + +drop table if exists grand_parent_person; + +drop table if exists survey_group; + +drop table if exists c_group; + +drop table if exists he_doc; + +drop trigger hx_link_history_upd; +drop trigger hx_link_history_del; +drop view hx_link_with_history; +CALL usp_ebean_drop_column('hx_link', 'sys_period_start'); +CALL usp_ebean_drop_column('hx_link', 'sys_period_end'); +drop table hx_link_history; + +drop table if exists hx_link; + +drop table if exists hx_link_doc; + +drop table if exists hi_doc; + +drop trigger hi_link_history_upd; +drop trigger hi_link_history_del; +drop view hi_link_with_history; +CALL usp_ebean_drop_column('hi_link', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_link', 'sys_period_end'); +drop table hi_link_history; + +drop table if exists hi_link; + +drop trigger hi_link_doc_history_upd; +drop trigger hi_link_doc_history_del; +drop view hi_link_doc_with_history; +CALL usp_ebean_drop_column('hi_link_doc', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_link_doc', 'sys_period_end'); +drop table hi_link_doc_history; + +drop table if exists hi_link_doc; + +drop trigger hi_tone_history_upd; +drop trigger hi_tone_history_del; +drop view hi_tone_with_history; +CALL usp_ebean_drop_column('hi_tone', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_tone', 'sys_period_end'); +drop table hi_tone_history; + +drop table if exists hi_tone; + +drop trigger hi_tthree_history_upd; +drop trigger hi_tthree_history_del; +drop view hi_tthree_with_history; +CALL usp_ebean_drop_column('hi_tthree', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_tthree', 'sys_period_end'); +drop table hi_tthree_history; + +drop table if exists hi_tthree; + +drop trigger hi_ttwo_history_upd; +drop trigger hi_ttwo_history_del; +drop view hi_ttwo_with_history; +CALL usp_ebean_drop_column('hi_ttwo', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_ttwo', 'sys_period_end'); +drop table hi_ttwo_history; + +drop table if exists hi_ttwo; + +drop trigger hsd_setting_history_upd; +drop trigger hsd_setting_history_del; +drop view hsd_setting_with_history; +CALL usp_ebean_drop_column('hsd_setting', 'sys_period_start'); +CALL usp_ebean_drop_column('hsd_setting', 'sys_period_end'); +drop table hsd_setting_history; + +drop table if exists hsd_setting; + +drop trigger hsd_user_history_upd; +drop trigger hsd_user_history_del; +drop view hsd_user_with_history; +CALL usp_ebean_drop_column('hsd_user', 'sys_period_start'); +CALL usp_ebean_drop_column('hsd_user', 'sys_period_end'); +drop table hsd_user_history; + +drop table if exists hsd_user; + +drop table if exists iaf_segment; + +drop table if exists iaf_segment_status; + +drop table if exists imrelated; + +drop table if exists imroot; + +drop table if exists ixresource; + +drop table if exists info_company; + +drop table if exists info_contact; + +drop table if exists info_customer; + +drop table if exists inner_report; + +drop table if exists drel_invoice; + +drop table if exists item; + +drop table if exists monkey; + +drop table if exists mkeygroup; + +drop table if exists mkeygroup_monkey; + +drop table if exists trainer; + +drop table if exists trainer_monkey; + +drop table if exists troop; + +drop table if exists troop_monkey; + +drop table if exists l2_cldf_reset_bean; + +drop table if exists l2_cldf_reset_bean_child; + +drop table if exists level1; + +drop table if exists level1_level4; + +drop table if exists level1_level2; + +drop table if exists level2; + +drop table if exists level2_level3; + +drop table if exists level3; + +drop table if exists level4; + +drop trigger link_history_upd; +drop trigger link_history_del; +drop view link_with_history; +CALL usp_ebean_drop_column('link', 'sys_period_start'); +CALL usp_ebean_drop_column('link', 'sys_period_end'); +drop table link_history; + +drop table if exists link; + +drop table if exists link_draft; + +drop table if exists la_attr_value; + +drop table if exists la_attr_value_attribute; + +drop table if exists looney; + +drop table if exists maddress; + +drop table if exists mcontact; + +drop table if exists mcontact_message; + +drop table if exists mcustomer; + +drop table if exists mgroup; + +drop table if exists mmachine; + +drop table if exists mmachine_mgroup; + +drop table if exists mmedia; + +drop table if exists non_updateprop; + +drop table if exists mprinter; + +drop table if exists mprinter_state; + +drop table if exists mprofile; + +drop table if exists mprotected_construct_bean; + +drop table if exists mrole; + +drop table if exists mrole_muser; + +drop table if exists msome_other; + +drop table if exists muser; + +drop table if exists muser_type; + +drop table if exists mail_box; + +drop table if exists mail_user; + +drop table if exists mail_user_inbox; + +drop table if exists mail_user_outbox; + +drop table if exists main_entity; + +drop table if exists main_entity_relation; + +drop table if exists map_super_actual; + +drop table if exists c_message; + +drop table if exists meter_address_data; + +drop table if exists meter_contract_data; + +drop table if exists meter_special_needs_client; + +drop table if exists meter_special_needs_contact; + +drop table if exists meter_version; + +drop table if exists mnoc_role; + +drop table if exists mnoc_user; + +drop table if exists mnoc_user_mnoc_role; + +drop table if exists mny_a; + +drop table if exists mny_b; + +drop table if exists mny_b_mny_c; + +drop table if exists mny_c; + +drop table if exists mny_topic; + +drop table if exists subtopics; + +drop table if exists mp_role; + +drop table if exists mp_user; + +drop table if exists ms_many_a; + +drop table if exists ms_many_a_many_b; + +drop table if exists ms_many_b; + +drop table if exists ms_many_b_many_a; + +drop table if exists my_lob_size; + +drop table if exists my_lob_size_join_many; + +drop table if exists noidbean; + +drop table if exists o_cached_bean; + +drop table if exists o_cached_bean_country; + +drop table if exists o_cached_bean_child; + +drop table if exists o_cached_inherit; + +drop table if exists o_cached_natkey; + +drop table if exists o_cached_natkey3; + +drop table if exists ocar; + +drop table if exists ocompany; + +drop table if exists oengine; + +drop table if exists ogear_box; + +drop table if exists oroad_show_msg; + +drop table if exists om_ordered_detail; + +drop table if exists om_ordered_master; + +drop table if exists only_id_entity; + +drop table if exists o_order; + +drop table if exists o_order_detail; + +drop table if exists s_orders; + +drop table if exists s_order_items; + +drop table if exists or_order_ship; + +drop table if exists organisation; + +drop table if exists organization_node; + +drop table if exists organization_tree_node; + +drop table if exists orp_detail; + +drop table if exists orp_detail2; + +drop table if exists orp_master; + +drop table if exists orp_master2; + +drop table if exists oto_aone; + +drop table if exists oto_atwo; + +drop table if exists oto_bchild; + +drop table if exists oto_bmaster; + +drop table if exists oto_child; + +drop table if exists oto_cust; + +drop table if exists oto_cust_address; + +drop table if exists oto_level_a; + +drop table if exists oto_level_b; + +drop table if exists oto_level_c; + +drop table if exists oto_master; + +drop table if exists oto_prime; + +drop table if exists oto_prime_extra; + +drop table if exists oto_sd_child; + +drop table if exists oto_sd_master; + +drop table if exists oto_th_many; + +drop table if exists oto_th_one; + +drop table if exists oto_th_top; + +drop table if exists oto_ubprime; + +drop table if exists oto_ubprime_extra; + +drop table if exists oto_uprime; + +drop table if exists oto_uprime_extra; + +drop table if exists oto_user_model; + +drop table if exists oto_user_model_optional; + +drop table if exists pfile; + +drop table if exists pfile_content; + +drop table if exists paggview; + +drop table if exists pallet_location; + +drop table if exists parcel; + +drop table if exists parcel_location; + +drop table if exists rawinherit_parent; + +drop table if exists rawinherit_parent_rawinherit_data; + +drop table if exists e_save_test_c; + +drop table if exists parent_person; + +drop table if exists c_participation; + +drop table if exists password_store_model; + +drop table if exists mt_permission; + +drop table if exists persistent_file; + +drop table if exists persistent_file_content; + +drop table if exists person; + +drop table if exists persons; + +drop table if exists person_cache_email; + +drop table if exists person_cache_info; + +drop table if exists phones; + +drop table if exists e_position; + +drop table if exists primary_revision; + +drop table if exists o_product; + +drop table if exists pp; + +drop table if exists pp_to_ww; + +drop table if exists question; + +drop table if exists rcustomer; + +drop table if exists r_orders; + +drop table if exists region; + +drop table if exists rel_detail; + +drop table if exists rel_master; + +drop table if exists resourcefile; + +drop table if exists mt_role; + +drop table if exists mt_role_permission; + +drop table if exists em_role; + +drop table if exists f_second; + +drop table if exists section; + +drop table if exists self_parent; + +drop table if exists self_ref_customer; + +drop table if exists self_ref_example; + +drop table if exists e_save_test_a; + +drop table if exists e_save_test_b; + +drop table if exists site; + +drop table if exists site_address; + +drop table if exists some_enum_bean; + +drop table if exists some_file_bean; + +drop table if exists some_new_types_bean; + +drop table if exists some_period_bean; + +drop table if exists stockforecast; + +drop table if exists sub_section; + +drop table if exists sub_type; + +drop table if exists survey; + +drop table if exists tbytes_only; + +drop table if exists tcar; + +drop table if exists tevent; + +drop table if exists tevent_many; + +drop table if exists tevent_one; + +drop table if exists tint_root; + +drop table if exists tjoda_entity; + +drop table if exists t_mapsuper1; + +drop table if exists t_oneb; + +drop table if exists t_detail_with_other_namexxxyy; + +drop table if exists ts_detail_two; + +drop table if exists t_atable_thatisrelatively; + +drop table if exists ts_master_two; + +drop table if exists tuuid_entity; + +drop table if exists twheel; + +drop table if exists twith_pre_insert; + +drop table if exists mt_tenant; + +drop table if exists test_annotation_base_entity; + +drop table if exists tire; + +drop table if exists sa_tire; + +drop table if exists trip; + +drop table if exists truck_ref; + +drop table if exists tune; + +drop table if exists `type`; + +drop table if exists tz_bean; + +drop table if exists usib_child; + +drop table if exists usib_child_sibling; + +drop table if exists usib_parent; + +drop table if exists ut_detail; + +drop table if exists ut_master; + +drop table if exists uuone; + +drop table if exists uutwo; + +drop table if exists oto_user; + +drop trigger c_user_history_upd; +drop trigger c_user_history_del; +drop view c_user_with_history; +CALL usp_ebean_drop_column('c_user', 'sys_period_start'); +CALL usp_ebean_drop_column('c_user', 'sys_period_end'); +drop table c_user_history; + +drop table if exists c_user; + +drop table if exists tx_user; + +drop table if exists g_user; + +drop table if exists em_user; + +drop table if exists em_user_role; + +drop table if exists vehicle; + +drop table if exists vehicle_driver; + +drop table if exists vehicle_lease; + +drop table if exists warehouses; + +drop table if exists warehousesshippingzones; + +drop table if exists wheel; + +drop table if exists sa_wheel; + +drop table if exists sp_car_wheel; + +drop table if exists g_who_props_otm; + +drop table if exists with_zero; + +drop table if exists parent; + +drop table if exists wview; + +drop table if exists zones; + +drop index ix_contact_last_name_first_name on contact; +drop index ix_e_basic_name on e_basic; +drop index ix_efile2_no_fk_owner_id on efile2_no_fk; +drop index ix_organization_node_kind on organization_node; diff --git a/src/test/resources/dbmig_postgres/ex1.sql b/src/test/resources/dbmig_postgres/ex1.sql new file mode 100644 index 0000000..7bd7082 --- /dev/null +++ b/src/test/resources/dbmig_postgres/ex1.sql @@ -0,0 +1,14 @@ +create or replace function hx_link_history_version() returns trigger as $$ +begin + +end; +$$ LANGUAGE plpgsql; + +create trigger hx_link_history_upd + before update or delete on hx_link + for each row execute procedure hx_link_history_version(); + +create or replace function hi_link_history_version() returns trigger as $$ +begin +end; +$$ LANGUAGE plpgsql; diff --git a/src/test/resources/dbmig_postgres/pg-create-all.sql b/src/test/resources/dbmig_postgres/pg-create-all.sql new file mode 100644 index 0000000..30e9b2e --- /dev/null +++ b/src/test/resources/dbmig_postgres/pg-create-all.sql @@ -0,0 +1,4745 @@ +-- Generated by ebean unknown at 2019-07-24T11:42:58.489Z +create table asimple_bean ( + id bigserial not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id serial not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer not null, + id bigserial not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigserial not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigserial not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigserial not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigserial not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id smallserial not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime timestamptz, + country_code varchar(2), + updtime timestamptz not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigserial not null, + name varchar(255), + cover_id bigint, + deleted boolean default false not null, + created_at timestamptz not null, + last_update timestamptz not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigserial not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id serial not null, + name varchar(255), + author varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer not null, + id serial not null, + attribute_holder_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id serial not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigserial not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id serial not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id serial not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id serial not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id serial not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id uuid not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site uuid not null, + usr uuid not null, + access_level integer, + constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid uuid not null, + user_uid uuid not null, + access_level integer, + constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) +); + +create table bsite_user_e ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) +); + +create table buser ( + id uuid not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id serial not null, + "Name" varchar(191), + "CODE" varchar(255), + last_updated timestamptz not null, + constraint uq_bwith_qident_name unique ("Name"), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigserial not null, + name varchar(255), + period varchar(50), + local_date date, + created timestamptz not null, + updated timestamptz not null, + version timestamptz not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigserial not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); +create sequence drel_booking_seq; + +create table bw_bean ( + id bigserial not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table cinh_ref ( + id serial not null, + ref_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id serial not null, + license_number varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id serial not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id serial not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table calculation_result ( + id serial not null, + charge float not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq; + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint not null, + version integer not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq; + +create table car_accessory ( + id serial not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigserial not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigserial not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigserial not null, + parent_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier serial not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigserial not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id serial not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id serial not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id serial not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + customer_id integer not null, + group_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id serial not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id serial not null, + contact_id integer, + title varchar(255), + note text, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigserial not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigserial not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigserial not null, + title varchar(255), + isopen boolean default false not null, + group_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigserial not null, + s3_url varchar(255), + deleted boolean default false not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id serial not null, + status varchar(1), + name varchar(40) not null, + smallnote varchar(100), + anniversary date, + billing_address_id smallint, + shipping_address_id smallint, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint ck_o_customer_status check ( status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +comment on table o_customer is 'Holds external customers'; +comment on column o_customer.status is 'status of the customer'; +comment on column o_customer.smallnote is 'Short notes regarding the customer'; +comment on column o_customer.anniversary is 'Join date of the customer'; + +create table dcredit ( + id bigserial not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigserial not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated timestamptz not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dmachine ( + id bigserial not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigserial not null, + machine_id bigint not null, + name varchar(255), + date date, + use_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigserial not null, + machine_id bigint not null, + date date, + total_kms bigint not null, + hours bigint not null, + rate decimal(38), + cost decimal(38), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigserial not null, + machine_id bigint not null, + date date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigserial not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(38), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigserial not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigserial not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigserial not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id uuid not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigserial not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table dfk_cascade ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigserial not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigserial not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigserial not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigserial not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigserial not null, + title varchar(127), + body varchar(255), + when_publish timestamptz, + organisation_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigserial not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigserial not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); +create sequence sp_car_door_seq; + +create table earray_bean ( + id bigserial not null, + foo integer, + name varchar(255), + phone_numbers varchar[], + uids uuid[], + other_ids bigint[], + doubs float[], + statuses integer[], + vc_enums varchar[], + int_enums integer[], + status2 integer[], + version bigint not null, + constraint ck_earray_bean_foo check ( foo in (100,101,102)), + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigserial not null, + name varchar(255), + phone_numbers varchar[], + uids uuid[], + other_ids bigint[], + doubs float[], + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id serial not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date timestamptz, + constraint ck_e_basic_status check ( status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigserial not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created timestamptz not null, + when_modified timestamptz not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigserial not null, + name varchar(255), + title varchar(255), + description text, + last_update timestamptz not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigserial not null, + name varchar(255), + title varchar(255), + description text, + last_update timestamptz not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigserial not null, + name varchar(255), + description text, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id serial not null, + name varchar(255), + description bytea, + dob bytea, + status bytea, + last_update timestamptz, + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id serial not null, + name varchar(255), + description varchar(255), + data bytea, + some_time bytea, + last_update timestamptz not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigserial not null, + name varchar(255), + description bytea, + dob bytea, + status bytea, + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id serial not null, + status integer, + name varchar(255), + description varchar(255), + some_date timestamptz, + constraint ck_e_basic_eni_status check ( status in (1,2,3)), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigserial not null, + name varchar(255), + map hstore, + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigserial not null, + name varchar(255), + value_set json, + value_list jsonb, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigserial not null, + name varchar(255), + value_set json, + value_list jsonb, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigserial not null, + name varchar(255), + bean_set json, + bean_list jsonb, + bean_map json, + plain_bean json, + flags json, + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigserial not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigserial not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigserial not null, + name varchar(255), + content text, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigserial not null, + owner_id bigint, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigserial not null, + name varchar(255), + content jsonb, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigserial not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigserial not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigserial not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigserial not null, + name varchar(255), + content jsonb, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigserial not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id serial not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigserial not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigserial not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigserial not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id serial not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update timestamptz not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigserial not null, + name varchar(255), + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigserial not null, + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id serial not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update timestamptz not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id uuid not null, + name varchar(100), + root_id uuid not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id uuid not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigserial not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id serial not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id serial not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id serial not null, + nome_outer varchar(255), + date1 timestamptz, + date2 timestamptz, + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + ts_created timestamptz not null, + ts_updated timestamptz not null, + ldt_created timestamptz not null, + ldt_updated timestamptz not null, + odt_created timestamptz not null, + odt_updated timestamptz not null, + zdt_created timestamptz not null, + zdt_updated timestamptz not null, + instant_created timestamptz not null, + instant_updated timestamptz not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table einvoice ( + id bigserial not null, + invoice_date timestamptz, + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint ck_einvoice_state check ( state in (0,1,2)), + constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), + constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id serial not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id serial not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id serial not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id serial not null, + name_for_a varchar(255), + b_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id serial not null, + name_for_b varchar(255), + c_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id serial not null, + name_for_c varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigserial not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigserial not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigserial not null, + email varchar(127), + online_status boolean default false not null, + when_updated timestamptz not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid serial not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigserial not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigserial not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigserial not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigserial not null, + name varchar(255), + oneb_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigserial not null, + role_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigserial not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigserial not null, + up varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigserial not null, + user_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigserial not null, + name varchar(255), + money decimal(38), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id serial not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id serial not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id serial not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id serial not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id serial not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id serial not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id serial not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigserial not null, + name varchar(255), + inet_address inet, + inet2 inet, + cdir inet, + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null, + constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) +); + +create table ec_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ecbl_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecbm_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecm_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + number varchar(10) not null +); + +create table ecmc_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value text not null +); + +create table ecs_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table td_child ( + child_id serial not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id serial not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table empl ( + id bigserial not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigserial not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id serial not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigserial not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id serial not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigserial not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence SEQ; + +create table gen_key_table ( + id bigserial not null, + description varchar(255), + constraint pk_gen_key_table primary key (id) +); + +create table grand_parent_person ( + identifier serial not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigserial not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigserial not null, + inactive boolean default false not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigserial not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigserial not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigserial not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigserial not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigserial not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigserial not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigserial not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigserial not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigserial not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigserial not null, + name varchar(255), + title varchar(255), + when_title timestamptz, + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id uuid not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigserial not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigserial not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigserial not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq; + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified timestamptz, + date_created timestamptz, + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigserial not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigserial not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigserial not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigserial not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigserial not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigserial not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigserial not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigserial not null, + name varchar(255), + location varchar(255), + when_publish timestamptz, + link_comment varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigserial not null, + name varchar(255), + location varchar(255), + when_publish timestamptz, + link_comment varchar(255), + dirty boolean default false not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id serial not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigserial not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id uuid not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id uuid not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id uuid, + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id uuid not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id uuid not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id uuid not null, + name varchar(255), + notes varchar(255), + shipping_address_id uuid, + billing_address_id uuid, + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigserial not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigserial not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id serial not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigserial not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigserial not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigserial not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigserial not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid serial not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigserial not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid serial not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id serial not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id uuid not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigserial not null, + name varchar(255), + when_created timestamptz not null, + when_updated timestamptz not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigserial not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id uuid not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id uuid not null, + special_needs_client_id uuid not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id uuid not null, + name varchar(255), + primary_id uuid, + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id uuid not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id uuid not null, + address_data_id uuid, + contract_data_id uuid not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id serial not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id serial not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigserial not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigserial not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigserial not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigserial not null, + name varchar(255), + ms_many_a_many_b boolean default false not null, + ms_many_b boolean default false not null, + deleted boolean default false not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigserial not null, + name varchar(255), + deleted boolean default false not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id serial not null, + name varchar(255), + my_count integer not null, + my_lob text, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id serial not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created timestamptz not null +); + +create table o_cached_bean ( + id bigserial not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigserial not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigserial not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigserial not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigserial not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocar ( + id serial not null, + vin varchar(255), + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id serial not null, + corp_id varchar(50), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id uuid not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id uuid not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table oroad_show_msg ( + id serial not null, + company_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_ordered_detail ( + id bigserial not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id bigserial not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id serial not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + constraint ck_o_order_status check ( status in (0,1,2,3)), + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id serial not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price float, + product_id integer, + cretime timestamptz, + updtime timestamptz not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(38), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id serial not null, + order_id integer, + ship_time timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table organisation ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigserial not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigserial not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigserial not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id serial not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigserial not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigserial not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigserial not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigserial not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigserial not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigserial not null, + child varchar(255), + master_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigserial not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigserial not null, + one boolean default false not null, + many_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigserial not null, + topp varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigserial not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigserial not null, + optional varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id serial not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id serial not null, + content bytea, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id uuid, + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id serial not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigserial not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigserial not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigserial not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigserial not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier serial not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigserial not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint ck_c_participation_type check ( type in (0,1)), + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigserial not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 text, + enc4 bytea, + enc5 bytea, + enc6 bytea, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_password_store_model primary key (id) +); + +create table mt_permission ( + id uuid not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id serial not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id serial not null, + persistent_file_id integer, + content bytea, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigserial not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigserial not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigserial not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigserial not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id serial not null, + sku varchar(20), + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id uuid not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id uuid not null, + ww_id uuid not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigserial not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigserial not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigserial not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id uuid not null, + name varchar(50), + tenant_id uuid, + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id uuid not null, + mt_permission_id uuid not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigserial not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table f_second ( + id bigserial not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id serial not null, + article_id integer, + type integer, + content text, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint ck_section_type check ( type in (0,1)), + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigserial not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigserial not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigserial not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigserial not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigserial not null, + sibling_a_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id uuid not null, + name varchar(255), + parent_id uuid, + data_container_id uuid, + site_address_id uuid, + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id uuid not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigserial not null, + some_enum integer, + name varchar(255), + constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigserial not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigserial not null, + dow integer, + mth integer, + yr integer, + yr_mth date, + month_day date, + local_date date, + local_date_time timestamptz, + offset_date_time timestamptz, + zoned_date_time timestamptz, + local_time time, + instant timestamptz, + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), + constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigserial not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigserial not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id serial not null, + section_id integer, + title varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id serial not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigserial not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id serial not null, + content bytea, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigserial not null, + description varchar(255), + event_id bigint, + units integer not null, + amount float not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigserial not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint ck_tevent_one_status check ( status in (0,1)), + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer not null, + id serial not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id serial not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id serial not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id serial not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active boolean default false not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); +create sequence t_atable_detail_seq; + +create table ts_detail_two ( + id serial not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + master_id integer, + constraint pk_ts_detail_two primary key (id) +); + +create table t_atable_thatisrelatively ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_master_seq; + +create table ts_master_two ( + id serial not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_ts_master_two primary key (id) +); + +create table tuuid_entity ( + id uuid not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigserial not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id serial not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table mt_tenant ( + id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); +create sequence tire_seq; + +create table sa_tire ( + id bigint not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq; + +create table trip ( + id serial not null, + vehicle_driver_id integer, + destination varchar(255), + address_id smallint, + star_date timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id serial not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigserial not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table "type" ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigserial not null, + moda varchar(255), + ts timestamptz, + tstz timestamptz, + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id uuid not null, + parent_id bigint, + deleted boolean default false not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigserial not null, + child_id uuid, + deleted boolean default false not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigserial not null, + deleted boolean default false not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id serial not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount float, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id serial not null, + name varchar(255), + description varchar(255), + date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id uuid not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id uuid not null, + name varchar(255), + notes varchar(255), + master_id uuid, + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigserial not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigserial not null, + inactive boolean default false not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigserial not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigserial not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigserial not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id serial not null, + license_number varchar(255), + registration_date timestamptz, + lease_id bigint, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity float, + constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id serial not null, + name varchar(255), + vehicle_id integer, + address_id smallint, + license_issued_on timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigserial not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(38), + min_duration integer not null, + day_rate decimal(38), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table warehouses ( + id serial not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint not null, + version integer not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq; + +create table sa_wheel ( + id bigint not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq; + +create table sp_car_wheel ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq; + +create table g_who_props_otm ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigserial not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id serial not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id uuid not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id serial not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_organization_node_kind on organization_node (kind); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references "type" (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ts_detail_two_master_id on ts_detail_two (master_id); +alter table ts_detail_two add constraint fk_ts_detail_two_master_id foreign key (master_id) references ts_master_two (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on "type" (sub_type_id); +alter table "type" add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hx_link set sys_period = tstzrange(when_created, null); +create table hx_link_history(like hx_link); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_link set sys_period = tstzrange(when_created, null); +create table hi_link_history(like hi_link); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +create table hi_link_doc_history(like hi_link_doc); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_tone set sys_period = tstzrange(when_created, null); +create table hi_tone_history(like hi_tone); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_tthree set sys_period = tstzrange(when_created, null); +create table hi_tthree_history(like hi_tthree); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_ttwo set sys_period = tstzrange(when_created, null); +create table hi_ttwo_history(like hi_ttwo); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hsd_setting set sys_period = tstzrange(when_created, null); +create table hsd_setting_history(like hsd_setting); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hsd_user set sys_period = tstzrange(when_created, null); +create table hsd_user_history(like hsd_user); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update link set sys_period = tstzrange(when_created, null); +create table link_history(like link); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update c_user set sys_period = tstzrange(when_created, null); +create table c_user_history(like c_user); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +create or replace function hx_link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hx_link_history_upd + before update or delete on hx_link + for each row execute procedure hx_link_history_version(); + +create or replace function hi_link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_link_history_upd + before update or delete on hi_link + for each row execute procedure hi_link_history_version(); + +create or replace function hi_link_doc_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_link_doc_history_upd + before update or delete on hi_link_doc + for each row execute procedure hi_link_doc_history_version(); + +create or replace function hi_tone_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_tone_history_upd + before update or delete on hi_tone + for each row execute procedure hi_tone_history_version(); + +create or replace function hi_tthree_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_tthree_history_upd + before update or delete on hi_tthree + for each row execute procedure hi_tthree_history_version(); + +create or replace function hi_ttwo_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_ttwo_history_upd + before update or delete on hi_ttwo + for each row execute procedure hi_ttwo_history_version(); + +create or replace function hsd_setting_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hsd_setting_history_upd + before update or delete on hsd_setting + for each row execute procedure hsd_setting_history_version(); + +create or replace function hsd_user_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hsd_user_history_upd + before update or delete on hsd_user + for each row execute procedure hsd_user_history_version(); + +create or replace function link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger link_history_upd + before update or delete on link + for each row execute procedure link_history_version(); + +create or replace function c_user_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger c_user_history_upd + before update or delete on c_user + for each row execute procedure c_user_history_version(); +