diff --git a/ebean-core/src/test/ddl-review/pg-create-all.sql b/ebean-core/src/test/ddl-review/pg-create-all.sql index 5b4bc24dd..3299399c4 100644 --- a/ebean-core/src/test/ddl-review/pg-create-all.sql +++ b/ebean-core/src/test/ddl-review/pg-create-all.sql @@ -1,4 +1,4 @@ --- Generated by ebean unknown at 2020-08-24T21:02:32.420817Z +-- Generated by ebean unknown at 2021-08-22T04:36:53.704559Z create table asimple_bean ( id bigint generated by default as identity not null, name varchar(255), @@ -103,6 +103,18 @@ create table animal_shelter ( constraint pk_animal_shelter primary key (id) ); +create table app_config ( + id integer generated by default as identity not null, + constraint pk_app_config primary key (id) +); + +create table app_config_control ( + id integer generated by default as identity not null, + name varchar(255), + config_id integer, + constraint pk_app_config_control primary key (id) +); + create table article ( id integer generated by default as identity not null, name varchar(255), @@ -203,7 +215,17 @@ create table bsite_user_d ( 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)) + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_d primary key (site_id,user_id) +); + +create table bsite_user_dmany ( + site_id uuid not null, + user_id uuid not null, + name varchar(255) not null, + many varchar(255), + version bigint not null, + constraint pk_bsite_user_dmany primary key (site_id,user_id,name) ); create table bsite_user_e ( @@ -396,6 +418,18 @@ create table coroot ( constraint pk_coroot primary key (id) ); +create table calcd_data ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_calcd_data primary key (id) +); + +create table calcd_input ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_calcd_input primary key (id) +); + create table calculation_result ( id integer generated by default as identity not null, charge float not null, @@ -486,6 +520,13 @@ create table child_person ( constraint pk_child_person primary key (identifier) ); +create table child_with_cache ( + id bigint generated by default as identity not null, + name varchar(255), + address varchar(255), + constraint pk_child_with_cache primary key (id) +); + create table cke_client ( cod_cpny integer not null, cod_client varchar(100) not null, @@ -922,6 +963,7 @@ create table earray_set_bean ( uids uuid[], other_ids bigint[], doubs float[], + status integer[], version bigint not null, constraint pk_earray_set_bean primary key (id) ); @@ -941,6 +983,7 @@ create table ebasic_change_log ( name varchar(20), short_description varchar(50), long_description varchar(100), + plain_bean json, who_created varchar(255) not null, who_modified varchar(255) not null, when_created timestamptz not null, @@ -1059,10 +1102,20 @@ create table ebasic_json_jackson2 ( constraint pk_ebasic_json_jackson2 primary key (id) ); +create table ebasic_json_jackson3 ( + id bigint generated by default as identity not null, + name varchar(255), + plain_value json, + plain_value2 json, + plain_value3 json, + version bigint not null, + constraint pk_ebasic_json_jackson3 primary key (id) +); + create table ebasic_json_list ( id bigint generated by default as identity not null, name varchar(255), - bean_set json, + beans json, bean_list jsonb, bean_map json, plain_bean json, @@ -1121,6 +1174,16 @@ create table ebasic_json_map_varchar ( constraint pk_ebasic_json_map_varchar primary key (id) ); +create table ebasic_json_multi ( + id bigint generated by default as identity not null, + name varchar(255), + plain_value1 json, + plain_value2 json, + plain_value3 json, + version bigint not null, + constraint pk_ebasic_json_multi primary key (id) +); + create table ebasic_json_node ( id bigint generated by default as identity not null, name varchar(255), @@ -1160,6 +1223,12 @@ create table ebasic_json_unmapped ( constraint pk_ebasic_json_unmapped primary key (id) ); +create table e_basic_log ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_e_basic_log primary key (id) +); + create table e_basic_ndc ( id integer generated by default as identity not null, name varchar(255), @@ -1175,6 +1244,32 @@ create table ebasic_no_sdchild ( constraint pk_ebasic_no_sdchild primary key (id) ); +create table ebasic_old_value ( + id bigint generated by default as identity not null, + name varchar(255), + string_set json, + long_set json, + int_set json, + string_list json, + long_list json, + int_list json, + object_map json, + long_map json, + int_map json, + json_node json, + string_arr varchar[], + constraint pk_ebasic_old_value primary key (id) +); + +create table ebasic_plain ( + id bigint generated by default as identity not null, + attr varchar(255), + plain_bean json, + plain_bean2 json, + version bigint not null, + constraint pk_ebasic_plain primary key (id) +); + create table ebasic_sdchild ( id bigint generated by default as identity not null, owner_id bigint not null, @@ -1219,6 +1314,14 @@ create table e_basic_with_ex ( constraint pk_e_basic_with_ex primary key (id) ); +create table e_basic_withlog ( + id bigint generated by default as identity not null, + name varchar(255), + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_withlog primary key (id) +); + create table e_basicverucon ( id integer generated by default as identity not null, name varchar(127), @@ -1345,10 +1448,14 @@ create table einvoice ( ship_suburb varchar(255), ship_city varchar(255), ship_status varchar(3), + ship_jbean json, + ship_jraw json, bill_street varchar(255), bill_suburb varchar(255), bill_city varchar(255), bill_status varchar(3), + bill_jbean json, + bill_jraw json, 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')), @@ -1425,11 +1532,42 @@ create table eperson ( suburb varchar(255), addr_city varchar(255), addr_status varchar(3), + addr_jbean json, + jraw json, version bigint not null, constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), constraint pk_eperson primary key (id) ); +create table eperson2 ( + id bigint generated by default as identity not null, + name varchar(255), + notes varchar(255), + street varchar(10), + suburb varchar(100), + city varchar(255), + status varchar(3), + jbean json, + jraw json, + version bigint not null, + constraint ck_eperson2_status check ( status in ('ONE','TWO')), + constraint pk_eperson2 primary key (id) +); + +create table eperson3 ( + id bigint generated by default as identity not null, + name varchar(255), + street varchar(255), + suburb varchar(255), + city varchar(255), + status varchar(3), + jbean json, + jraw json, + version bigint not null, + constraint ck_eperson3_status check ( status in ('ONE','TWO')), + constraint pk_eperson3 primary key (id) +); + create table e_person_online ( id bigint generated by default as identity not null, email varchar(127), @@ -1540,6 +1678,29 @@ create table esoft_del_user_esoft_del_role ( constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) ); +create table esoft_del_x ( + id uuid not null, + y_id bigint, + organization_id bigint, + deleted boolean default false not null, + constraint uq_esoft_del_x_y_id unique (y_id), + constraint pk_esoft_del_x primary key (id) +); + +create table esoft_del_y ( + id bigint generated by default as identity not null, + organization_id bigint, + deleted boolean default false not null, + constraint pk_esoft_del_y primary key (id) +); + +create table esoft_del_z ( + id bigint generated by default as identity not null, + uuid uuid, + deleted boolean default false not null, + constraint pk_esoft_del_z primary key (id) +); + create table esome_convert_type ( id bigint generated by default as identity not null, name varchar(255), @@ -1863,6 +2024,15 @@ create table c_group ( constraint pk_c_group primary key (id) ); +create table hembi_bean ( + part bigint not null, + brand varchar(20) not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_hembi_bean primary key (part,brand) +); + create table he_doc ( id bigint generated by default as identity not null, name varchar(255), @@ -2214,6 +2384,29 @@ create table looney ( constraint pk_looney primary key (id) ); +create table m2_mcache_child ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_m2_mcache_child primary key (id) +); + +create table m2_mcache_master ( + id integer generated by default as identity not null, + constraint pk_m2_mcache_master primary key (id) +); + +create table m2mcache_set1 ( + m2_mcache_master_id integer not null, + m2_mcache_child_id integer not null, + constraint pk_m2mcache_set1 primary key (m2_mcache_master_id,m2_mcache_child_id) +); + +create table m2mcache_set2 ( + m2_mcache_master_id integer not null, + m2_mcache_child_id integer not null, + constraint pk_m2mcache_set2 primary key (m2_mcache_master_id,m2_mcache_child_id) +); + create table maddress ( id uuid not null, street varchar(255), @@ -2508,6 +2701,22 @@ create table mny_c ( constraint pk_mny_c primary key (id) ); +create table mny_edge ( + id integer generated by default as identity not null, + from_id integer, + to_id integer, + flags integer not null, + constraint uq_mny_edge_from_id_to_id unique (from_id,to_id), + constraint uq_mny_edge_to_id_from_id unique (to_id,from_id), + constraint pk_mny_edge primary key (id) +); + +create table mny_node ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_mny_node primary key (id) +); + create table mny_topic ( id bigint generated by default as identity not null, name varchar(255), @@ -2749,6 +2958,20 @@ create table om_basic_parent ( constraint pk_om_basic_parent primary key (id) ); +create table om_bean_list_child ( + id bigint generated by default as identity not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_om_bean_list_child primary key (id) +); + +create table om_bean_list_parent ( + id bigint generated by default as identity not null, + version bigint not null, + constraint pk_om_bean_list_parent primary key (id) +); + create table om_ordered_detail ( id bigint generated by default as identity not null, name varchar(255), @@ -3188,6 +3411,19 @@ create table e_save_test_c ( constraint pk_e_save_test_c primary key (id) ); +create table parent_a ( + id bigint generated by default as identity not null, + child_id bigint, + name varchar(255), + constraint pk_parent_a primary key (id) +); + +create table parent_b ( + id bigint generated by default as identity not null, + child_id bigint, + constraint pk_parent_b primary key (id) +); + create table parent_person ( identifier integer generated by default as identity not null, name varchar(255), @@ -3319,6 +3555,24 @@ create table person_cache_info ( constraint pk_person_cache_info primary key (person_id) ); +create table person_other ( + id varchar(128) not null, + email varchar(255), + when_created timestamptz not null, + when_modified timestamptz not null, + version bigint not null, + constraint pk_person_other primary key (id) +); + +create table persona ( + id bigint generated by default as identity not null, + persona varchar(255), + person_oid bigint, + version integer not null, + constraint uq_persona_person_oid unique (person_oid), + constraint pk_persona primary key (id) +); + create table phones ( id bigint generated by default as identity not null, phone_number varchar(7) not null, @@ -3429,6 +3683,12 @@ create table rel_master ( constraint pk_rel_master primary key (id) ); +create table app_config_re ( + id integer generated by default as identity not null, + config_id integer, + constraint pk_app_config_re primary key (id) +); + create table resourcefile ( id varchar(64) not null, parentresourcefileid varchar(64), @@ -3485,6 +3745,18 @@ create table section ( constraint pk_section primary key (id) ); +create table self_many_many ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_self_many_many primary key (id) +); + +create table self_many_bridge ( + self_1_id bigint not null, + self_2_id bigint not null, + constraint pk_self_many_bridge primary key (self_1_id,self_2_id) +); + create table self_parent ( id bigint generated by default as identity not null, name varchar(255), @@ -3638,6 +3910,7 @@ create table tbytes_only ( create table tcar ( type varchar(31) not null, plate_no varchar(32) not null, + deleted boolean default false not null, truckload bigint, constraint pk_tcar primary key (plate_no) ); @@ -3653,7 +3926,7 @@ create table tevent_many ( id bigint generated by default as identity not null, description varchar(255), event_id bigint, - units integer not null, + my_units integer not null, amount float not null, version bigint not null, constraint pk_tevent_many primary key (id) @@ -3781,6 +4054,16 @@ create table test_annotation_base_entity ( null3 varchar(255) ); +create table test_jakarta_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, @@ -4104,17 +4387,17 @@ create table zones ( 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_ecsm_values_host_id on ecsm_values (host_id); -create index ix_order_referenced_parent_type on order_referenced_parent (type); -create index ix_organization_node_kind on organization_node (kind); -create unique index concurrently ix_t_detail_with_other_namexxxyy_lowername on t_detail_with_other_namexxxyy (lower(name)); +create index if not exists ix_contact_last_name_first_name on contact (last_name,first_name); +create index if not exists ix_e_basic_name on e_basic (name); +create index if not exists ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index if not exists ix_ecsm_values_host_id on ecsm_values (host_id); +create index if not exists ix_order_referenced_parent_type on order_referenced_parent (type); +create index if not exists ix_organization_node_kind on organization_node (kind); +create unique index concurrently if not exists ix_t_detail_with_other_namexxxyy_lowername on t_detail_with_other_namexxxyy (lower(name)); create index ix_t_detail_with_other_namexxxyy_defn on t_detail_with_other_namexxxyy using hash (lower(name)) where lower(name) like 'r%'; -create index ano_3 on test_annotation_base_entity (direct); -create index ano_1 on test_annotation_base_entity (direct); -create index ano_2 on test_annotation_base_entity (direct); +create index if not exists ano_3 on test_annotation_base_entity (direct); +create index if not exists ano_1 on test_jakarta_annotation_base_entity (direct); +create index if not exists ano_2 on test_jakarta_annotation_base_entity (direct); 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; @@ -4135,6 +4418,9 @@ alter table album add constraint fk_album_cover_id foreign key (cover_id) refere 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_app_config_control_config_id on app_config_control (config_id); +alter table app_config_control add constraint fk_app_config_control_config_id foreign key (config_id) references app_config (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; @@ -4162,6 +4448,9 @@ alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (si 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_dmany_bsite_user_d on bsite_user_dmany (site_id,user_id); +alter table bsite_user_dmany add constraint fk_bsite_user_dmany_bsite_user_d foreign key (site_id,user_id) references bsite_user_d (site_id,user_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; @@ -4200,6 +4489,8 @@ alter table coone_many add constraint fk_coone_many_coone_id foreign key (coone_ alter table coroot add constraint fk_coroot_one_id foreign key (one_id) references coone (id) on delete restrict on update restrict; +alter table calcd_data add constraint fk_calcd_data_id foreign key (id) references calcd_input (id) on delete cascade 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; @@ -4296,10 +4587,10 @@ alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_ alter table defaults_model add constraint fk_defaults_model_id foreign key (id) references defaults_model_draft (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; +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 restrict; 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 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 restrict; alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; @@ -4390,6 +4681,14 @@ alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft 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; +alter table esoft_del_x add constraint fk_esoft_del_x_y_id foreign key (y_id) references esoft_del_y (id) on delete restrict on update restrict; + +create index ix_esoft_del_x_organization_id on esoft_del_x (organization_id); +alter table esoft_del_x add constraint fk_esoft_del_x_organization_id foreign key (organization_id) references esoft_del_z (id) on delete restrict on update restrict; + +create index ix_esoft_del_y_organization_id on esoft_del_y (organization_id); +alter table esoft_del_y add constraint fk_esoft_del_y_organization_id foreign key (organization_id) references esoft_del_z (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; @@ -4533,6 +4832,18 @@ alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_at 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_m2mcache_set1_m2_mcache_master on m2mcache_set1 (m2_mcache_master_id); +alter table m2mcache_set1 add constraint fk_m2mcache_set1_m2_mcache_master foreign key (m2_mcache_master_id) references m2_mcache_master (id) on delete restrict on update restrict; + +create index ix_m2mcache_set1_m2_mcache_child on m2mcache_set1 (m2_mcache_child_id); +alter table m2mcache_set1 add constraint fk_m2mcache_set1_m2_mcache_child foreign key (m2_mcache_child_id) references m2_mcache_child (id) on delete restrict on update restrict; + +create index ix_m2mcache_set2_m2_mcache_master on m2mcache_set2 (m2_mcache_master_id); +alter table m2mcache_set2 add constraint fk_m2mcache_set2_m2_mcache_master foreign key (m2_mcache_master_id) references m2_mcache_master (id) on delete restrict on update restrict; + +create index ix_m2mcache_set2_m2_mcache_child on m2mcache_set2 (m2_mcache_child_id); +alter table m2mcache_set2 add constraint fk_m2mcache_set2_m2_mcache_child foreign key (m2_mcache_child_id) references m2_mcache_child (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; @@ -4618,6 +4929,12 @@ alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_i 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_mny_edge_from_id on mny_edge (from_id); +alter table mny_edge add constraint fk_mny_edge_from_id foreign key (from_id) references mny_node (id) on delete restrict on update restrict; + +create index ix_mny_edge_to_id on mny_edge (to_id); +alter table mny_edge add constraint fk_mny_edge_to_id foreign key (to_id) references mny_node (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; @@ -4672,6 +4989,9 @@ alter table om_account_child_dbo add constraint fk_om_account_child_dbo_banana_r create index ix_om_basic_child_parent_id on om_basic_child (parent_id); alter table om_basic_child add constraint fk_om_basic_child_parent_id foreign key (parent_id) references om_basic_parent (id) on delete restrict on update restrict; +create index ix_om_bean_list_child_parent_id on om_bean_list_child (parent_id); +alter table om_bean_list_child add constraint fk_om_bean_list_child_parent_id foreign key (parent_id) references om_bean_list_parent (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; @@ -4755,6 +5075,12 @@ alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_paren 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_a_child_id on parent_a (child_id); +alter table parent_a add constraint fk_parent_a_child_id foreign key (child_id) references child_with_cache (id) on delete restrict on update restrict; + +create index ix_parent_b_child_id on parent_b (child_id); +alter table parent_b add constraint fk_parent_b_child_id foreign key (child_id) references child_with_cache (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; @@ -4788,6 +5114,8 @@ alter table person add constraint fk_person_default_address_oid foreign key (def 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; +alter table persona add constraint fk_persona_person_oid foreign key (person_oid) references person (oid) 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; @@ -4817,6 +5145,9 @@ alter table referenced_defaults_model_draft add constraint fk_referenced_default 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_app_config_re_config_id on app_config_re (config_id); +alter table app_config_re add constraint fk_app_config_re_config_id foreign key (config_id) references app_config (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; @@ -4837,6 +5168,12 @@ alter table f_second add constraint fk_f_second_first foreign key (first) refere 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_many_bridge_self_many_many_1 on self_many_bridge (self_1_id); +alter table self_many_bridge add constraint fk_self_many_bridge_self_many_many_1 foreign key (self_1_id) references self_many_many (id) on delete restrict on update restrict; + +create index ix_self_many_bridge_self_many_many_2 on self_many_bridge (self_2_id); +alter table self_many_bridge add constraint fk_self_many_bridge_self_many_many_2 foreign key (self_2_id) references self_many_many (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; @@ -4965,6 +5302,10 @@ alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id fo 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 hembi_bean add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +create table hembi_bean_history(like hembi_bean); +create view hembi_bean_with_history as select * from hembi_bean union all select * from hembi_bean_history; + 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); @@ -5014,6 +5355,28 @@ 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 hembi_bean_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 hembi_bean_history (sys_period,part, brand, name, description, version) values (tstzrange(lowerTs,upperTs), OLD.part, OLD.brand, OLD.name, OLD.description, OLD.version); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hembi_bean_history (sys_period,part, brand, name, description, version) values (tstzrange(lowerTs,upperTs), OLD.part, OLD.brand, OLD.name, OLD.description, OLD.version); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hembi_bean_history_upd + before update or delete on hembi_bean + for each row execute procedure hembi_bean_history_version(); + create or replace function hx_link_history_version() returns trigger as $$ declare lowerTs timestamptz; diff --git a/ebean-core/src/test/ddl-review/pg-drop-all.sql b/ebean-core/src/test/ddl-review/pg-drop-all.sql index e3fbd4432..bcf680914 100644 --- a/ebean-core/src/test/ddl-review/pg-drop-all.sql +++ b/ebean-core/src/test/ddl-review/pg-drop-all.sql @@ -1,4 +1,4 @@ --- Generated by ebean unknown at 2020-08-24T21:02:32.420817Z +-- Generated by ebean unknown at 2021-08-22T04:36:53.704559Z alter table if exists bar drop constraint if exists fk_bar_foo_id; drop index if exists ix_bar_foo_id; @@ -19,6 +19,9 @@ alter table if exists album drop constraint if exists fk_album_cover_id; alter table if exists animal drop constraint if exists fk_animal_shelter_id; drop index if exists ix_animal_shelter_id; +alter table if exists app_config_control drop constraint if exists fk_app_config_control_config_id; +drop index if exists ix_app_config_control_config_id; + alter table if exists attribute drop constraint if exists fk_attribute_attribute_holder_id; drop index if exists ix_attribute_attribute_holder_id; @@ -46,6 +49,9 @@ drop index if exists ix_bsite_user_c_site_uid; alter table if exists bsite_user_c drop constraint if exists fk_bsite_user_c_user_uid; drop index if exists ix_bsite_user_c_user_uid; +alter table if exists bsite_user_dmany drop constraint if exists fk_bsite_user_dmany_bsite_user_d; +drop index if exists ix_bsite_user_dmany_bsite_user_d; + alter table if exists bsite_user_e drop constraint if exists fk_bsite_user_e_site_id; drop index if exists ix_bsite_user_e_site_id; @@ -84,6 +90,8 @@ drop index if exists ix_coone_many_coone_id; alter table if exists coroot drop constraint if exists fk_coroot_one_id; +alter table if exists calcd_data drop constraint if exists fk_calcd_data_id; + alter table if exists calculation_result drop constraint if exists fk_calculation_result_product_configuration_id; drop index if exists ix_calculation_result_product_configuration_id; @@ -274,6 +282,14 @@ drop index if exists ix_esoft_del_user_esoft_del_role_esoft_del_user; alter table if exists esoft_del_user_esoft_del_role drop constraint if exists fk_esoft_del_user_esoft_del_role_esoft_del_role; drop index if exists ix_esoft_del_user_esoft_del_role_esoft_del_role; +alter table if exists esoft_del_x drop constraint if exists fk_esoft_del_x_y_id; + +alter table if exists esoft_del_x drop constraint if exists fk_esoft_del_x_organization_id; +drop index if exists ix_esoft_del_x_organization_id; + +alter table if exists esoft_del_y drop constraint if exists fk_esoft_del_y_organization_id; +drop index if exists ix_esoft_del_y_organization_id; + alter table if exists rawinherit_uncle drop constraint if exists fk_rawinherit_uncle_parent_id; drop index if exists ix_rawinherit_uncle_parent_id; @@ -417,6 +433,18 @@ drop index if exists ix_la_attr_value_attribute_attribute; alter table if exists looney drop constraint if exists fk_looney_tune_id; drop index if exists ix_looney_tune_id; +alter table if exists m2mcache_set1 drop constraint if exists fk_m2mcache_set1_m2_mcache_master; +drop index if exists ix_m2mcache_set1_m2_mcache_master; + +alter table if exists m2mcache_set1 drop constraint if exists fk_m2mcache_set1_m2_mcache_child; +drop index if exists ix_m2mcache_set1_m2_mcache_child; + +alter table if exists m2mcache_set2 drop constraint if exists fk_m2mcache_set2_m2_mcache_master; +drop index if exists ix_m2mcache_set2_m2_mcache_master; + +alter table if exists m2mcache_set2 drop constraint if exists fk_m2mcache_set2_m2_mcache_child; +drop index if exists ix_m2mcache_set2_m2_mcache_child; + alter table if exists mcontact drop constraint if exists fk_mcontact_customer_id; drop index if exists ix_mcontact_customer_id; @@ -502,6 +530,12 @@ drop index if exists ix_mny_b_mny_c_mny_b; alter table if exists mny_b_mny_c drop constraint if exists fk_mny_b_mny_c_mny_c; drop index if exists ix_mny_b_mny_c_mny_c; +alter table if exists mny_edge drop constraint if exists fk_mny_edge_from_id; +drop index if exists ix_mny_edge_from_id; + +alter table if exists mny_edge drop constraint if exists fk_mny_edge_to_id; +drop index if exists ix_mny_edge_to_id; + alter table if exists subtopics drop constraint if exists fk_subtopics_mny_topic_1; drop index if exists ix_subtopics_mny_topic_1; @@ -556,6 +590,9 @@ drop index if exists ix_om_account_child_dbo_banana_rama_id; alter table if exists om_basic_child drop constraint if exists fk_om_basic_child_parent_id; drop index if exists ix_om_basic_child_parent_id; +alter table if exists om_bean_list_child drop constraint if exists fk_om_bean_list_child_parent_id; +drop index if exists ix_om_bean_list_child_parent_id; + alter table if exists om_ordered_detail drop constraint if exists fk_om_ordered_detail_master_id; drop index if exists ix_om_ordered_detail_master_id; @@ -639,6 +676,12 @@ drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_parent; alter table if exists rawinherit_parent_rawinherit_data drop constraint if exists fk_rawinherit_parent_rawinherit_data_rawinherit_data; drop index if exists ix_rawinherit_parent_rawinherit_data_rawinherit_data; +alter table if exists parent_a drop constraint if exists fk_parent_a_child_id; +drop index if exists ix_parent_a_child_id; + +alter table if exists parent_b drop constraint if exists fk_parent_b_child_id; +drop index if exists ix_parent_b_child_id; + alter table if exists parent_person drop constraint if exists fk_parent_person_some_bean_id; drop index if exists ix_parent_person_some_bean_id; @@ -672,6 +715,8 @@ drop index if exists ix_person_default_address_oid; alter table if exists person_cache_email drop constraint if exists fk_person_cache_email_person_info_person_id; drop index if exists ix_person_cache_email_person_info_person_id; +alter table if exists persona drop constraint if exists fk_persona_person_oid; + alter table if exists phones drop constraint if exists fk_phones_person_id; drop index if exists ix_phones_person_id; @@ -701,6 +746,9 @@ drop index if exists ix_referenced_defaults_model_draft_defaults_model_id; alter table if exists rel_master drop constraint if exists fk_rel_master_detail_id; drop index if exists ix_rel_master_detail_id; +alter table if exists app_config_re drop constraint if exists fk_app_config_re_config_id; +drop index if exists ix_app_config_re_config_id; + alter table if exists resourcefile drop constraint if exists fk_resourcefile_parentresourcefileid; drop index if exists ix_resourcefile_parentresourcefileid; @@ -721,6 +769,12 @@ alter table if exists f_second drop constraint if exists fk_f_second_first; alter table if exists section drop constraint if exists fk_section_article_id; drop index if exists ix_section_article_id; +alter table if exists self_many_bridge drop constraint if exists fk_self_many_bridge_self_many_many_1; +drop index if exists ix_self_many_bridge_self_many_many_1; + +alter table if exists self_many_bridge drop constraint if exists fk_self_many_bridge_self_many_many_2; +drop index if exists ix_self_many_bridge_self_many_many_2; + alter table if exists self_parent drop constraint if exists fk_self_parent_parent_id; drop index if exists ix_self_parent_parent_id; @@ -873,6 +927,10 @@ drop table if exists animal cascade; drop table if exists animal_shelter cascade; +drop table if exists app_config cascade; + +drop table if exists app_config_control cascade; + drop table if exists article cascade; drop table if exists attribute cascade; @@ -899,6 +957,8 @@ drop table if exists bsite_user_c cascade; drop table if exists bsite_user_d cascade; +drop table if exists bsite_user_dmany cascade; + drop table if exists bsite_user_e cascade; drop table if exists buser cascade; @@ -946,6 +1006,10 @@ drop table if exists coone_many cascade; drop table if exists coroot cascade; +drop table if exists calcd_data cascade; + +drop table if exists calcd_input cascade; + drop table if exists calculation_result cascade; drop table if exists cao_bean cascade; @@ -970,6 +1034,8 @@ drop table if exists e_save_test_d cascade; drop table if exists child_person cascade; +drop table if exists child_with_cache cascade; + drop table if exists cke_client cascade; drop table if exists cke_user cascade; @@ -1105,6 +1171,8 @@ drop table if exists ebasic_json_jackson cascade; drop table if exists ebasic_json_jackson2 cascade; +drop table if exists ebasic_json_jackson3 cascade; + drop table if exists ebasic_json_list cascade; drop table if exists ebasic_json_map cascade; @@ -1119,6 +1187,8 @@ drop table if exists ebasic_json_map_json_b cascade; drop table if exists ebasic_json_map_varchar cascade; +drop table if exists ebasic_json_multi cascade; + drop table if exists ebasic_json_node cascade; drop table if exists ebasic_json_node_blob cascade; @@ -1129,10 +1199,16 @@ drop table if exists ebasic_json_node_varchar cascade; drop table if exists ebasic_json_unmapped cascade; +drop table if exists e_basic_log cascade; + drop table if exists e_basic_ndc cascade; drop table if exists ebasic_no_sdchild cascade; +drop table if exists ebasic_old_value cascade; + +drop table if exists ebasic_plain cascade; + drop table if exists ebasic_sdchild cascade; drop table if exists ebasic_soft_delete cascade; @@ -1143,6 +1219,8 @@ drop table if exists e_basic_withlife cascade; drop table if exists e_basic_with_ex cascade; +drop table if exists e_basic_withlog cascade; + drop table if exists e_basicverucon cascade; drop table if exists ecache_child cascade; @@ -1189,6 +1267,10 @@ drop table if exists eper_addr cascade; drop table if exists eperson cascade; +drop table if exists eperson2 cascade; + +drop table if exists eperson3 cascade; + drop table if exists e_person_online cascade; drop table if exists esimple cascade; @@ -1217,6 +1299,12 @@ drop table if exists esoft_del_user cascade; drop table if exists esoft_del_user_esoft_del_role cascade; +drop table if exists esoft_del_x cascade; + +drop table if exists esoft_del_y cascade; + +drop table if exists esoft_del_z cascade; + drop table if exists esome_convert_type cascade; drop table if exists esome_type cascade; @@ -1308,6 +1396,15 @@ drop table if exists survey_group cascade; drop table if exists c_group cascade; +drop trigger if exists hembi_bean_history_upd on hembi_bean cascade; +drop function if exists hembi_bean_history_version(); + +drop view hembi_bean_with_history; +alter table hembi_bean drop column sys_period; +drop table hembi_bean_history; + +drop table if exists hembi_bean cascade; + drop table if exists he_doc cascade; drop trigger if exists hx_link_history_upd on hx_link cascade; @@ -1458,6 +1555,14 @@ drop table if exists la_attr_value_attribute cascade; drop table if exists looney cascade; +drop table if exists m2_mcache_child cascade; + +drop table if exists m2_mcache_master cascade; + +drop table if exists m2mcache_set1 cascade; + +drop table if exists m2mcache_set2 cascade; + drop table if exists maddress cascade; drop table if exists mcontact cascade; @@ -1534,6 +1639,10 @@ drop table if exists mny_b_mny_c cascade; drop table if exists mny_c cascade; +drop table if exists mny_edge cascade; + +drop table if exists mny_node cascade; + drop table if exists mny_topic cascade; drop table if exists subtopics cascade; @@ -1598,6 +1707,10 @@ drop table if exists om_basic_child cascade; drop table if exists om_basic_parent cascade; +drop table if exists om_bean_list_child cascade; + +drop table if exists om_bean_list_parent cascade; + drop table if exists om_ordered_detail cascade; drop table if exists om_ordered_master cascade; @@ -1710,6 +1823,10 @@ drop table if exists rawinherit_parent_rawinherit_data cascade; drop table if exists e_save_test_c cascade; +drop table if exists parent_a cascade; + +drop table if exists parent_b cascade; + drop table if exists parent_person cascade; drop table if exists c_participation cascade; @@ -1740,6 +1857,10 @@ drop table if exists person_cache_email cascade; drop table if exists person_cache_info cascade; +drop table if exists person_other cascade; + +drop table if exists persona cascade; + drop table if exists phones cascade; drop table if exists e_position cascade; @@ -1770,6 +1891,8 @@ drop table if exists rel_detail cascade; drop table if exists rel_master cascade; +drop table if exists app_config_re cascade; + drop table if exists resourcefile cascade; drop table if exists mt_role cascade; @@ -1784,6 +1907,10 @@ drop table if exists f_second cascade; drop table if exists section cascade; +drop table if exists self_many_many cascade; + +drop table if exists self_many_bridge cascade; + drop table if exists self_parent cascade; drop table if exists self_ref_customer cascade; @@ -1856,6 +1983,8 @@ drop table if exists mt_tenant cascade; drop table if exists test_annotation_base_entity cascade; +drop table if exists test_jakarta_annotation_base_entity cascade; + drop table if exists tire cascade; drop sequence if exists tire_seq;