From c04171c1a5c0797b28d037d69e062d7e4eec6be6 Mon Sep 17 00:00:00 2001 From: Michael Benz Date: Wed, 14 Jun 2023 14:34:09 +0200 Subject: [PATCH 1/3] Update CONFIGURATION.md with small corrections Updated configuration markdown with small corrections and removed TODO for includeGeneratedFileComment See https://github.com/ebean-orm/ebean/issues/550 --- CONFIGURATION.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 46be98f0b..0c9df93eb 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -4,13 +4,13 @@ Overview of ebean.properties file ### DbMigration options -You can set individual values for different platforms when generating migrations +You can set individual values for different platforms when generating migrations. `dbmigration.platform..databaseSequenceBatchSize` For DB's using sequences this is the number of sequence values prefetched. `dbmigration.platform..dbuuid` -Control, how UUID generation should work - it affects DDL which column type is generated. Possible values: +Control, how UUID generation should work - it affects which column type is generated in DDL. Possible values: - BINARY enforces binary UUID - VARCHAR enforces varchar UUID - BINARY_OPTIMIZED enforces binary-optimized UUID (makes sense only with Type1 ID) @@ -19,7 +19,7 @@ Control, how UUID generation should work - it affects DDL which column type is g - AUTO_VARCHAR (default) use varchar when platform does not support UUID `dbmigration.platform..uuidStoreAsBinary` -Same as setting dbuuid to BINARY +Same as setting dbuuid to BINARY. `dbmigration.platform..geometrySRID` The Geometry SRID value (default 4326). @@ -30,7 +30,6 @@ The ID type (IDENTITY, SEQUENCE, GENERATOR, EXTERNAL) `dbmigration.platform..mapping` Adjust the mapping. For example `BOOLEAN=integer(32);BIT=tinyint(3)` - `ebean.migration.applyPrefix` Set this to "V" to be compatible with FlywayDB. @@ -50,7 +49,7 @@ Set to true if the DB migration should be generated on server start. The version of a pending drop that should be generated as the next migration. `ebean.migration.includeGeneratedFileComment` -TODO +Adds the header about the migration files being generated when true. Reading 'THIS IS A GENERATED FILE - DO NOT MODIFY' `ebean.migration.metaTable` For running migration the DB table that holds migration execution status. Default 'db_migration' @@ -65,17 +64,17 @@ Subdirectory the model xml files go into. Default 'model' Suffix. Default '.model.xml' `ebean.migration.name` -Description text that can be appended to the version to become the ddl script file name +Description text that can be appended to the version to become the ddl script file name. `ebean.migration.patchInsertOn` -migration versions that should be added to history without running. +Migration versions that should be added to history without running. `ebean.migration.patchResetChecksumOn` migration versions that should have their checksum reset and not run. Use this if you get a 'Checksum mismatch' error. `ebean.migration.placeholders` -A comma and equals delimited placeholders that are substituted in SQL scripts when running migration (used by DB Migration runner only). +A comma and equals delimited map of placeholders that are substituted in SQL scripts when running migration (used by DB Migration runner only). `ebean.migration.platform` The database platform to generate migration DDL for. @@ -90,7 +89,7 @@ The migration version name (typically FlywayDb compatible). Example: 1.1.1_2 ### Ebean UUID options `ebean.uuidVersion` -Controls, how the UUIDs are generated. Possible values +Controls how the UUIDs are generated. Possible values: - VERSION4 (default) generate random V4 UUIDs, - VERSION1 generate rfc4122 compliant Type 1 UUIDs (requires a state file) - VERSION1RND generate fake Type 1 UUIDs @@ -98,7 +97,7 @@ Controls, how the UUIDs are generated. Possible values Note, that V1 UUIDs in conjunction with AUTO_BINARY_OPTIMIZED will give you the best index performance, but you MUST understand how this works to avoid collisions. `ebean.uuidStateFile` -The state file that is Required to generate V1 UUIDs +The state file that is required to generate V1 UUIDs. ### DocStoreConfig @@ -107,7 +106,7 @@ The state file that is Required to generate V1 UUIDs True when the Document store integration is active/on. `ebean.docstore.allowAllCertificates` -Set to true such that the client allows connections to invalid/self signed SSL certificates. +Set to true such that the client allows connections to invalid/self-signed SSL certificates. `ebean.docstore.bulkBatchSize` The default batch size to use for the Bulk API calls. @@ -192,7 +191,7 @@ Suffix appended to the base table to derive the view that contains the union of Set to true if the DataSource uses autoCommit. Indicates that Ebean should use autoCommit friendly Transactions and TransactionManager. `ebean.autoReadOnlyDataSource` -When true create a read only DataSource using readOnlyDataSourceConfig defaulting values from dataSourceConfig +When true create a read only DataSource using readOnlyDataSourceConfig defaulting values from dataSourceConfig. `ebean.autostart` Should the server start all From 55477d4fab4ed755b00c7d7e184a3691789f9213 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 15 Jun 2023 08:07:51 +0200 Subject: [PATCH 2/3] No code change: Regenerated scripts --- .../dbmigration/clickhouse/1.0__initial.sql | 18 ---------- .../dbmigration/clickhouse/1.1.sql | 18 ++++++++++ .../clickhouse/idx_clickhouse.migrations | 4 +-- .../dbmigration/cockroach/1.0__initial.sql | 31 ----------------- .../dbmigration/cockroach/1.1.sql | 31 +++++++++++++++++ .../cockroach/idx_cockroach.migrations | 4 +-- .../dbmigration/db2fori/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/db2fori/1.1.sql | 31 +++++++++++++++++ .../dbmigration/db2fori/idx_db2.migrations | 4 +-- .../dbmigration/db2legacy/1.0__initial.sql | 31 ----------------- .../dbmigration/db2legacy/1.1.sql | 31 +++++++++++++++++ .../db2legacy/idx_generic.migrations | 4 +-- .../dbmigration/db2luw/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/db2luw/1.1.sql | 31 +++++++++++++++++ .../dbmigration/db2luw/idx_db2.migrations | 4 +-- .../dbmigration/db2zos/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/db2zos/1.1.sql | 31 +++++++++++++++++ .../dbmigration/db2zos/idx_db2.migrations | 4 +-- .../dbmigration/generic/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/generic/1.1.sql | 31 +++++++++++++++++ .../generic/idx_generic.migrations | 4 +-- .../dbmigration/h2/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/h2/1.1.sql | 31 +++++++++++++++++ .../dbmigration/h2/idx_h2.migrations | 4 +-- .../dbmigration/hana/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/hana/1.1.sql | 31 +++++++++++++++++ .../dbmigration/hana/idx_hana.migrations | 4 +-- .../dbmigration/hsqldb/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/hsqldb/1.1.sql | 31 +++++++++++++++++ .../dbmigration/hsqldb/idx_hsqldb.migrations | 4 +-- .../mariadb-noprocs/1.0__initial.sql | 31 ----------------- .../dbmigration/mariadb-noprocs/1.1.sql | 31 +++++++++++++++++ .../mariadb-noprocs/idx_mariadb.migrations | 4 +-- .../dbmigration/mariadb/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/mariadb/1.1.sql | 31 +++++++++++++++++ .../mariadb/idx_mariadb.migrations | 4 +-- .../dbmigration/model/1.0__initial.model.xml | 16 --------- .../dbmigration/model/1.1.model.xml | 16 +++++++++ .../dbmigration/mysql/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/mysql/1.1.sql | 31 +++++++++++++++++ .../dbmigration/mysql/idx_mysql.migrations | 4 +-- .../dbmigration/mysql55/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/mysql55/1.1.sql | 31 +++++++++++++++++ .../dbmigration/mysql55/idx_mysql.migrations | 4 +-- .../dbmigration/nuodb/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/nuodb/1.1.sql | 31 +++++++++++++++++ .../dbmigration/nuodb/idx_nuodb.migrations | 4 +-- .../dbmigration/oracle/1.0__initial.sql | 31 ----------------- .../migrationtest/dbmigration/oracle/1.1.sql | 31 +++++++++++++++++ .../dbmigration/oracle/idx_oracle.migrations | 4 +-- .../dbmigration/oracle11/1.0__initial.sql | 34 ------------------- .../dbmigration/oracle11/1.1.sql | 34 +++++++++++++++++++ .../oracle11/idx_oracle.migrations | 4 +-- .../dbmigration/postgres/1.0__initial.sql | 31 ----------------- .../dbmigration/postgres/1.1.sql | 31 +++++++++++++++++ .../postgres/idx_postgres.migrations | 4 +-- .../dbmigration/postgres9/1.0__initial.sql | 31 ----------------- .../dbmigration/postgres9/1.1.sql | 31 +++++++++++++++++ .../postgres9/idx_postgres.migrations | 4 +-- .../dbmigration/sqlanywhere/1.0__initial.sql | 31 ----------------- .../dbmigration/sqlanywhere/1.1.sql | 31 +++++++++++++++++ .../sqlanywhere/idx_sqlanywhere.migrations | 4 +-- .../dbmigration/sqlite/1.0__initial.sql | 25 -------------- .../migrationtest/dbmigration/sqlite/1.1.sql | 25 ++++++++++++++ .../dbmigration/sqlite/idx_sqlite.migrations | 4 +-- .../dbmigration/sqlserver16/1.0__initial.sql | 31 ----------------- .../dbmigration/sqlserver16/1.1.sql | 31 +++++++++++++++++ .../sqlserver16/idx_sqlserver.migrations | 4 +-- .../dbmigration/sqlserver17/1.0__initial.sql | 34 ------------------- .../dbmigration/sqlserver17/1.1.sql | 34 +++++++++++++++++++ .../sqlserver17/idx_sqlserver.migrations | 4 +-- .../dbmigration/yugabyte/1.0__initial.sql | 31 ----------------- .../dbmigration/yugabyte/1.1.sql | 31 +++++++++++++++++ .../yugabyte/idx_yugabyte.migrations | 4 +-- 74 files changed, 795 insertions(+), 795 deletions(-) diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql index 3c8ce6567..228422449 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql @@ -45,24 +45,6 @@ create table migtest_fk_set_null ( one_id UInt64 ) ENGINE = Log(); -create table drop_main ( - id UInt32 -) ENGINE = Log(); - -create table drop_main_drop_ref_many ( - drop_main_id UInt32, - drop_ref_many_id UInt32 -) ENGINE = Log(); - -create table drop_ref_many ( - id UInt32 -) ENGINE = Log(); - -create table drop_ref_one ( - id UInt32, - parent_id UInt32 -) ENGINE = Log(); - create table migtest_e_basic ( id UInt32, status String, diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql index 9849b051c..9e681c917 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql @@ -6,6 +6,24 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; -- apply changes +create table drop_main ( + id UInt32 +) ENGINE = Log(); + +create table drop_main_drop_ref_many ( + drop_main_id UInt32, + drop_ref_many_id UInt32 +) ENGINE = Log(); + +create table drop_ref_many ( + id UInt32 +) ENGINE = Log(); + +create table drop_ref_one ( + id UInt32, + parent_id UInt32 +) ENGINE = Log(); + create table migtest_e_user ( id UInt32 ) ENGINE = Log(); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations index a38537136..c38e16579 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations @@ -1,5 +1,5 @@ -1672735407, 1.0__initial.sql -540706946, 1.1.sql +193400547, 1.0__initial.sql +-572177405, 1.1.sql 688811494, 1.2__dropsFor_1.1.sql 1015552567, 1.3.sql 677297367, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql index 79a5c4329..4f47e0774 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -215,15 +193,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql index 183dcdc71..72b163ae6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -90,6 +112,15 @@ alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5); alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations index 3a59a4520..f7a5c61fa 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations @@ -1,5 +1,5 @@ -1867456246, 1.0__initial.sql -1284257915, 1.1.sql +1434934404, 1.0__initial.sql +-1182436907, 1.1.sql 856096334, 1.2__dropsFor_1.1.sql -279468991, 1.3.sql 2137365848, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql index b4660d18f..9931da4b1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -254,15 +232,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql index 3032d4353..03f5e189b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql @@ -85,6 +85,28 @@ if exists (select indname from syscat.indexes where indschema = current_schema a end if; end$$; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -210,6 +232,15 @@ comment on column "table"."index" is 'this is an other comment'; alter table "table" add versioning use history table table_history; create unique index uq_table_select on "table"("select") exclude null keys; -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations index d305cb8ef..9938d1f0b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations @@ -1,5 +1,5 @@ --283216660, 1.0__initial.sql --184000413, 1.1.sql +-1467839063, 1.0__initial.sql +300902032, 1.1.sql -1187336846, 1.2__dropsFor_1.1.sql -1811865535, 1.3.sql -1255430844, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql index 1490ff004..7b7bddd1d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -216,15 +194,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql index 645d357f2..e17bc6574 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -93,6 +115,15 @@ comment on table migtest_e_history is 'We have history now'; comment on column "table"."index" is 'this is an other comment'; alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations index 7b2bfb788..348be5392 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations @@ -1,5 +1,5 @@ --528359263, 1.0__initial.sql -253988246, 1.1.sql +-1547037623, 1.0__initial.sql +647357251, 1.1.sql 688811494, 1.2__dropsFor_1.1.sql 674925120, 1.3.sql 677297367, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql index 132b608f7..8b9d60aad 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -254,15 +232,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql index 2f4beedaa..adc9f49a6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql @@ -85,6 +85,28 @@ if exists (select indname from syscat.indexes where indschema = current_schema a end if; end$$; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -210,6 +232,15 @@ comment on column "table"."index" is 'this is an other comment'; alter table "table" add versioning use history table table_history; create unique index uq_table_select on "table"("select") exclude null keys; -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations index 769c506f2..8b8601367 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations @@ -1,6 +1,6 @@ 1307787475, I__create_tablespaces.sql -1681764655, 1.0__initial.sql --1450326352, 1.1.sql +2058232717, 1.0__initial.sql +1290834425, 1.1.sql -1187336846, 1.2__dropsFor_1.1.sql 469192394, 1.3.sql -1255430844, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql index 132b608f7..8b9d60aad 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -254,15 +232,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql index 2f4beedaa..adc9f49a6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql @@ -85,6 +85,28 @@ if exists (select indname from syscat.indexes where indschema = current_schema a end if; end$$; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -210,6 +232,15 @@ comment on column "table"."index" is 'this is an other comment'; alter table "table" add versioning use history table table_history; create unique index uq_table_select on "table"("select") exclude null keys; -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations index 5a08e6b7c..e23deaabf 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations @@ -1,5 +1,5 @@ -1681764655, 1.0__initial.sql --1450326352, 1.1.sql +2058232717, 1.0__initial.sql +1290834425, 1.1.sql -1187336846, 1.2__dropsFor_1.1.sql 469192394, 1.3.sql -1255430844, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql index 1490ff004..7b7bddd1d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -216,15 +194,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql index 645d357f2..e17bc6574 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -93,6 +115,15 @@ comment on table migtest_e_history is 'We have history now'; comment on column "table"."index" is 'this is an other comment'; alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations index 7b2bfb788..348be5392 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations @@ -1,5 +1,5 @@ --528359263, 1.0__initial.sql -253988246, 1.1.sql +-1547037623, 1.0__initial.sql +647357251, 1.1.sql 688811494, 1.2__dropsFor_1.1.sql 674925120, 1.3.sql 677297367, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql index 93a101a08..d405e6e70 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -291,15 +269,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql index 93ae665e6..beeec16ed 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -137,6 +159,15 @@ create view table_with_history as select * from "table" union all select * from create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.platform.h2.H2HistoryTrigger"; alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations index 6f155dc9a..d5a6d5712 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations @@ -1,5 +1,5 @@ -400361768, 1.0__initial.sql -1979519453, 1.1.sql +-1854589550, 1.0__initial.sql +-298026519, 1.1.sql 1579867974, 1.2__dropsFor_1.1.sql 64466326, 1.3.sql 255910011, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql index b42347e19..2c4188555 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql @@ -54,28 +54,6 @@ create column table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create column table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create column table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create column table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create column table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create column table migtest_e_basic ( id integer generated by default as identity not null, status nvarchar(1), @@ -297,15 +275,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei -- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary; alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; --- explicit index "ix_drop_main_drop_ref_many_drop_main" for single column "drop_main_id" of table "drop_main_drop_ref_many" is not necessary; -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - --- explicit index "ix_drop_main_drop_ref_many_drop_ref_many" for single column "drop_ref_many_id" of table "drop_main_drop_ref_many" is not necessary; -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - --- explicit index "ix_drop_ref_one_parent_id" for single column "parent_id" of table "drop_ref_one" is not necessary; -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - -- explicit index "ix_migtest_e_basic_eref_id" for single column "eref_id" of table "migtest_e_basic" is not necessary; alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql index 98d826685..47adc66fa 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql @@ -59,6 +59,28 @@ exec 'drop index ix_migtest_quoted_status1'; end; $$; -- apply changes +create column table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create column table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create column table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create column table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create column table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -168,6 +190,15 @@ comment on column "table"."index" is 'this is an other comment'; alter table "table" add system versioning history table table_history not validated; -- cannot create unique index "uq_table_select" on table ""table"" with nullable columns; -- foreign keys and indices +-- explicit index "ix_drop_main_drop_ref_many_drop_main" for single column "drop_main_id" of table "drop_main_drop_ref_many" is not necessary; +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +-- explicit index "ix_drop_main_drop_ref_many_drop_ref_many" for single column "drop_ref_many_id" of table "drop_main_drop_ref_many" is not necessary; +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +-- explicit index "ix_drop_ref_one_parent_id" for single column "parent_id" of table "drop_ref_one" is not necessary; +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + -- explicit index "ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" for single column "migtest_mtm_c_id" of table "migtest_mtm_c_migtest_mtm_m" is not necessary; alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations index fe3245fb3..00547d47b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations @@ -1,6 +1,6 @@ -745347271, I__create_procs.sql --1399184401, 1.0__initial.sql --1727762906, 1.1.sql +-2017770851, 1.0__initial.sql +1261740376, 1.1.sql 1535221752, 1.2__dropsFor_1.1.sql 1459381570, 1.3.sql 1163601680, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql index 90807ee40..ff2f34299 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity (start with 1) not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity (start with 1) not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity (start with 1) not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity (start with 1) not null, status varchar(1), @@ -216,15 +194,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql index 94010fa00..c07a9e9a2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer generated by default as identity (start with 1) not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity (start with 1) not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity (start with 1) not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity (start with 1) not null, constraint pk_migtest_e_user primary key (id) @@ -93,6 +115,15 @@ comment on table migtest_e_history is 'We have history now'; comment on column "table"."index" is 'this is an other comment'; alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations index 389d2fb13..cdc9da585 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations @@ -1,5 +1,5 @@ -617421105, 1.0__initial.sql -84224587, 1.1.sql +1833930558, 1.0__initial.sql +-1636879297, 1.1.sql -848622216, 1.2__dropsFor_1.1.sql -1921508585, 1.3.sql 1870787524, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql index 18c10634b..f9b1b3f43 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -217,15 +195,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql index 4213de18e..10dc07db1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql @@ -8,6 +8,28 @@ drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -82,6 +104,15 @@ alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique alter table migtest_e_history comment = 'We have history now'; alter table `table` add constraint uq_table_select unique (`select`); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations index f64c4144b..0e7ac7e89 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations @@ -1,5 +1,5 @@ --1588268581, 1.0__initial.sql --1101751768, 1.1.sql +-2111548334, 1.0__initial.sql +-359661866, 1.1.sql 919151678, 1.2__dropsFor_1.1.sql -413458006, 1.3.sql -1557805741, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql index 18c10634b..f9b1b3f43 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -217,15 +195,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql index 4213de18e..10dc07db1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql @@ -8,6 +8,28 @@ drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -82,6 +104,15 @@ alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique alter table migtest_e_history comment = 'We have history now'; alter table `table` add constraint uq_table_select unique (`select`); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations index 4bd9b1117..e7b3da927 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations @@ -1,6 +1,6 @@ -1933396282, I__create_procs.sql --1588268581, 1.0__initial.sql --1101751768, 1.1.sql +-2111548334, 1.0__initial.sql +-359661866, 1.1.sql 1187950993, 1.2__dropsFor_1.1.sql -413458006, 1.3.sql -430651388, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml index d3b46df24..b0d93151a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml @@ -37,22 +37,6 @@ - - - - - - - - - - - - - - - - diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml index 1c704408c..e6f43d0f5 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml @@ -13,6 +13,22 @@ + + + + + + + + + + + + + + + + diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql index eb95f6816..f2eb08f85 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -345,15 +323,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql index 2b8461633..ef9406857 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql @@ -8,6 +8,28 @@ drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -200,6 +222,15 @@ end$$ unlock tables; alter table `table` add constraint uq_table_select unique (`select`); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations index 805eb4459..5f73a8546 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations @@ -1,6 +1,6 @@ -1933396282, I__create_procs.sql --1156696445, 1.0__initial.sql --92753611, 1.1.sql +1980830787, 1.0__initial.sql +-868893802, 1.1.sql -1097227916, 1.2__dropsFor_1.1.sql 141196883, 1.3.sql 1435550240, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql index 7e6906ea4..b1db29fc1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -345,15 +323,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql index 2b8461633..ef9406857 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql @@ -8,6 +8,28 @@ drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -200,6 +222,15 @@ end$$ unlock tables; alter table `table` add constraint uq_table_select unique (`select`); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations index 503e38c46..d224e3a0d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations @@ -1,6 +1,6 @@ -1933396282, I__create_procs.sql --165038024, 1.0__initial.sql --92753611, 1.1.sql +369577572, 1.0__initial.sql +-868893802, 1.1.sql -1097227916, 1.2__dropsFor_1.1.sql 141196883, 1.3.sql 1435550240, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql index 58cfc41bb..b5d81c5bd 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -362,15 +340,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id); -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql index 31cdd3756..62b1c5837 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -224,6 +246,15 @@ $$ alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations index 40897ee77..be14e7cfd 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations @@ -1,5 +1,5 @@ --588780599, 1.0__initial.sql --2079708895, 1.1.sql +390216918, 1.0__initial.sql +1677721520, 1.1.sql 1530685455, 1.2__dropsFor_1.1.sql -956168377, 1.3.sql 146295108, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql index a97688926..4b2f1f9a5 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id number(10) generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id number(10) not null, - drop_ref_many_id number(10) not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id number(10) generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id number(10) generated by default as identity not null, - parent_id number(10), - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id number(10) generated by default as identity not null, status varchar2(1), @@ -216,15 +194,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; -create index ix_drp_mn_drp_rf_mny_drp_mn on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_drp_mn foreign key (drop_main_id) references drop_main (id); - -create index ix_drp_mn_drp_rf_mny_dr_d70vl on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_dr_joeslj foreign key (drop_ref_many_id) references drop_ref_many (id); - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql index f78c04b78..fc3569c81 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql @@ -56,6 +56,28 @@ drop index ix_migtest_e_basic_indextest1; drop index ix_migtest_e_basic_indextest5; drop index ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id number(10) generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id number(10) not null, + drop_ref_many_id number(10) not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id number(10) generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id number(10) generated by default as identity not null, + parent_id number(10), + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id number(10) generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -138,6 +160,15 @@ comment on table migtest_e_history is 'We have history now'; comment on column "table"."index" is 'this is an other comment'; -- NOT YET IMPLEMENTED: alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drp_mn_drp_rf_mny_drp_mn on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_drp_mn foreign key (drop_main_id) references drop_main (id); + +create index ix_drp_mn_drp_rf_mny_dr_d70vl on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_dr_joeslj foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_mgtst_mtm_c_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations index 9b6a8abe8..ad1f33d3f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations @@ -1,5 +1,5 @@ --126940583, 1.0__initial.sql -740264587, 1.1.sql +1757923548, 1.0__initial.sql +-425348886, 1.1.sql 930172034, 1.2__dropsFor_1.1.sql -647790612, 1.3.sql 1707389466, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql index 3d4518972..bfbc238c4 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql @@ -62,31 +62,6 @@ create table migtest_fk_set_null ( ); create sequence migtest_fk_set_null_seq; -create table drop_main ( - id number(10) not null, - constraint pk_drop_main primary key (id) -); -create sequence drop_main_seq; - -create table drop_main_drop_ref_many ( - drop_main_id number(10) not null, - drop_ref_many_id number(10) not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id number(10) not null, - constraint pk_drop_ref_many primary key (id) -); -create sequence drop_ref_many_seq; - -create table drop_ref_one ( - id number(10) not null, - parent_id number(10), - constraint pk_drop_ref_one primary key (id) -); -create sequence drop_ref_one_seq; - create table migtest_e_basic ( id number(10) not null, status varchar2(1), @@ -241,15 +216,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; -create index ix_drp_mn_drp_rf_mny_drp_mn on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_drp_mn foreign key (drop_main_id) references drop_main (id); - -create index ix_drp_mn_drp_rf_mny_dr_d70vl on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_dr_joeslj foreign key (drop_ref_many_id) references drop_ref_many (id); - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql index 7a24eef36..bd6c098dc 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql @@ -56,6 +56,31 @@ drop index ix_migtest_e_basic_indextest1; drop index ix_migtest_e_basic_indextest5; drop index ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id number(10) not null, + constraint pk_drop_main primary key (id) +); +create sequence drop_main_seq; + +create table drop_main_drop_ref_many ( + drop_main_id number(10) not null, + drop_ref_many_id number(10) not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id number(10) not null, + constraint pk_drop_ref_many primary key (id) +); +create sequence drop_ref_many_seq; + +create table drop_ref_one ( + id number(10) not null, + parent_id number(10), + constraint pk_drop_ref_one primary key (id) +); +create sequence drop_ref_one_seq; + create table migtest_e_user ( id number(10) not null, constraint pk_migtest_e_user primary key (id) @@ -139,6 +164,15 @@ comment on table migtest_e_history is 'We have history now'; comment on column "table"."index" is 'this is an other comment'; -- NOT YET IMPLEMENTED: alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drp_mn_drp_rf_mny_drp_mn on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_drp_mn foreign key (drop_main_id) references drop_main (id); + +create index ix_drp_mn_drp_rf_mny_dr_d70vl on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_dr_joeslj foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_mgtst_mtm_c_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations index 2fee87c5d..5edc1625a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations @@ -1,5 +1,5 @@ -21261569, 1.0__initial.sql --123689547, 1.1.sql +-1422254768, 1.0__initial.sql +1978733753, 1.1.sql 930172034, 1.2__dropsFor_1.1.sql 1369863782, 1.3.sql 1707389466, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql index eaff8a84d..acc4504bc 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, description_file bytea, @@ -374,15 +352,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql index 3a0faaf28..aadfbb8b7 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql @@ -14,6 +14,28 @@ drop index if exists idxd_migtest_0; drop index concurrently if exists ix_migtest_oto_child_lowername_id; drop index if exists ix_migtest_oto_child_lowername; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -295,6 +317,15 @@ create trigger table_history_upd alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations index 0dab55900..0f5fc0b20 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations @@ -1,5 +1,5 @@ --22203872, 1.0__initial.sql --1432572923, 1.1.sql +1942370812, 1.0__initial.sql +106674126, 1.1.sql -261111052, 1.2__dropsFor_1.1.sql 788727457, 1.3.sql -596521697, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql index af6cf0911..e91b2b1c3 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id serial not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id serial not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id serial not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id serial not null, description_file bytea, @@ -374,15 +352,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql index f86699016..6a33648b1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql @@ -14,6 +14,28 @@ drop index if exists idxd_migtest_0; drop index concurrently if exists ix_migtest_oto_child_lowername_id; drop index if exists ix_migtest_oto_child_lowername; -- apply changes +create table drop_main ( + id serial not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id serial not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id serial not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id serial not null, constraint pk_migtest_e_user primary key (id) @@ -295,6 +317,15 @@ create trigger table_history_upd alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations index a6ae1b7d8..1005e2e01 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations @@ -1,5 +1,5 @@ -559327334, 1.0__initial.sql --690271384, 1.1.sql +-1015076364, 1.0__initial.sql +-1513219932, 1.1.sql -261111052, 1.2__dropsFor_1.1.sql -1811829200, 1.3.sql -596521697, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql index 3d95c0561..3d79a3500 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer auto_increment not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer auto_increment not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer auto_increment not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -216,15 +194,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql index f6c2af545..3b0e78e49 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer auto_increment not null, constraint pk_migtest_e_user primary key (id) @@ -93,6 +115,15 @@ comment on table migtest_e_history is 'We have history now'; comment on column "table"."index" is 'this is an other comment'; alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations index 06bb6b597..5b50f740c 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations @@ -1,5 +1,5 @@ -1278110701, 1.0__initial.sql -128425002, 1.1.sql +-951189503, 1.0__initial.sql +2050079154, 1.1.sql 688811494, 1.2__dropsFor_1.1.sql -680526370, 1.3.sql 677297367, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql index dbb047e57..bfd05a961 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql @@ -56,31 +56,6 @@ create table migtest_fk_set_null ( foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict ); -create table drop_main ( - id integer not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id), - foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict, - foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict -); - -create table drop_ref_many ( - id integer not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id), - foreign key (parent_id) references drop_main (id) on delete restrict on update restrict -); - create table migtest_e_basic ( id integer not null, status varchar(1), diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql index 3c93d203c..f0642be0c 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql @@ -11,6 +11,31 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id), + foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict, + foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict +); + +create table drop_ref_many ( + id integer not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id), + foreign key (parent_id) references drop_main (id) on delete restrict on update restrict +); + create table migtest_e_user ( id integer not null, constraint pk_migtest_e_user primary key (id) diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations index ce94a01e1..a92a75476 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations @@ -1,5 +1,5 @@ -238997470, 1.0__initial.sql -1828386122, 1.1.sql +-1527127682, 1.0__initial.sql +-2104033639, 1.1.sql 688811494, 1.2__dropsFor_1.1.sql 142780650, 1.3.sql 677297367, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql index 52b69c27f..00b472a4b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer identity(1,1) not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer identity(1,1) not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer identity(1,1) not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer identity(1,1) not null, status varchar(1), @@ -246,15 +224,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql index fd69bd2dd..98bd0273f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql @@ -13,6 +13,28 @@ IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_b IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest5') drop index ix_migtest_e_basic_indextest5 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"migtest_QuOtEd"','U') AND name = 'ix_migtest_quoted_status1') drop index ix_migtest_quoted_status1 ON "migtest_QuOtEd"; -- apply changes +create table drop_main ( + id integer identity(1,1) not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer identity(1,1) not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer identity(1,1) not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer identity(1,1) not null, constraint pk_migtest_e_user primary key (id) @@ -117,6 +139,15 @@ period for system_time (sys_periodFrom, sys_periodTo); alter table migtest_e_history set (system_versioning = on (history_table=dbo.migtest_e_history_history)); create unique nonclustered index uq_table_select on "table"("select") where "select" is not null; -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations index dd52a9c47..b835cb154 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations @@ -1,6 +1,6 @@ 891357544, I__create_procs.sql -254353963, 1.0__initial.sql -1327099983, 1.1.sql +-1455820494, 1.0__initial.sql +2006139920, 1.1.sql -1431095657, 1.2__dropsFor_1.1.sql 1846195516, 1.3.sql -1390979787, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql index e79e2d7b5..248baa645 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql @@ -62,31 +62,6 @@ create table migtest_fk_set_null ( ); create sequence migtest_fk_set_null_seq as bigint start with 1; -create table drop_main ( - id integer not null, - constraint pk_drop_main primary key (id) -); -create sequence drop_main_seq as bigint start with 1; - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer not null, - constraint pk_drop_ref_many primary key (id) -); -create sequence drop_ref_many_seq as bigint start with 1; - -create table drop_ref_one ( - id integer not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); -create sequence drop_ref_one_seq as bigint start with 1; - create table migtest_e_basic ( id integer not null, status nvarchar(1), @@ -271,15 +246,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql index c6a7c1466..a10f69cf4 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql @@ -13,6 +13,31 @@ IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_b IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest5') drop index ix_migtest_e_basic_indextest5 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"migtest_QuOtEd"','U') AND name = 'ix_migtest_quoted_status1') drop index ix_migtest_quoted_status1 ON "migtest_QuOtEd"; -- apply changes +create table drop_main ( + id integer not null, + constraint pk_drop_main primary key (id) +); +create sequence drop_main_seq as bigint start with 1; + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer not null, + constraint pk_drop_ref_many primary key (id) +); +create sequence drop_ref_many_seq as bigint start with 1; + +create table drop_ref_one ( + id integer not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); +create sequence drop_ref_one_seq as bigint start with 1; + create table migtest_e_user ( id integer not null, constraint pk_migtest_e_user primary key (id) @@ -118,6 +143,15 @@ period for system_time (sys_periodFrom, sys_periodTo); alter table migtest_e_history set (system_versioning = on (history_table=dbo.migtest_e_history_history)); create unique nonclustered index uq_table_select on "table"("select") where "select" is not null; -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations index 29d90f613..a1fe87d52 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations @@ -1,6 +1,6 @@ 891357544, I__create_procs.sql --2080592180, 1.0__initial.sql --579377447, 1.1.sql +29271754, 1.0__initial.sql +-449063882, 1.1.sql -1431095657, 1.2__dropsFor_1.1.sql -1712303917, 1.3.sql -1390979787, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql index 71e927175..1dbcc0776 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql @@ -54,28 +54,6 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); -create table drop_main ( - id integer generated by default as identity not null, - constraint pk_drop_main primary key (id) -); - -create table drop_main_drop_ref_many ( - drop_main_id integer not null, - drop_ref_many_id integer not null, - constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) -); - -create table drop_ref_many ( - id integer generated by default as identity not null, - constraint pk_drop_ref_many primary key (id) -); - -create table drop_ref_one ( - id integer generated by default as identity not null, - parent_id integer, - constraint pk_drop_ref_one primary key (id) -); - create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -405,15 +383,6 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; - -create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); -alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; - -create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); -alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; - create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql index f6a1e56ff..ae32ed1c4 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql @@ -11,6 +11,28 @@ drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; -- apply changes +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_user ( id integer generated by default as identity not null, constraint pk_migtest_e_user primary key (id) @@ -294,6 +316,15 @@ create trigger table_history_upd alter table "table" add constraint uq_table_select unique ("select"); -- foreign keys and indices +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations index a3e8f8961..741777201 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations @@ -1,5 +1,5 @@ -1799266243, 1.0__initial.sql --1967687506, 1.1.sql +-1646972843, 1.0__initial.sql +-1446648810, 1.1.sql -261111052, 1.2__dropsFor_1.1.sql -526466104, 1.3.sql -596521697, 1.4__dropsFor_1.3.sql From c7f6c508a61bb4aee7f0e5dc122838ab908e3317 Mon Sep 17 00:00:00 2001 From: "robin.bygrave" Date: Fri, 16 Jun 2023 13:44:03 +1200 Subject: [PATCH 3/3] #3101 - Support JPA Indexes --- .gitignore | 1 + .../java/io/ebean/config/DbConstraintNaming.java | 2 +- .../java/io/ebean/config/DbConstraintNormalise.java | 2 -- .../server/deploy/IndexDefinition.java | 13 ++++++++++--- .../server/deploy/parse/AnnotationClass.java | 4 ++++ .../ebean/xtest/config/DbConstraintNamingTest.java | 5 +++++ .../org/tests/model/basic/FeatureDescription.java | 3 ++- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 861a33064..a95675f95 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ ebean-profiling*.xml /db /mydb.db profiling/ +.DS_Store # Intellij project files *.iml diff --git a/ebean-api/src/main/java/io/ebean/config/DbConstraintNaming.java b/ebean-api/src/main/java/io/ebean/config/DbConstraintNaming.java index 7b23244cb..310ec1d7c 100644 --- a/ebean-api/src/main/java/io/ebean/config/DbConstraintNaming.java +++ b/ebean-api/src/main/java/io/ebean/config/DbConstraintNaming.java @@ -144,7 +144,7 @@ public class DbConstraintNaming { } sb.append(normaliseColumn(columns[i])); } - return sb.toString(); + return sb.toString().replace(" ", "_"); } /** diff --git a/ebean-api/src/main/java/io/ebean/config/DbConstraintNormalise.java b/ebean-api/src/main/java/io/ebean/config/DbConstraintNormalise.java index c8dd4da60..12c2d703c 100644 --- a/ebean-api/src/main/java/io/ebean/config/DbConstraintNormalise.java +++ b/ebean-api/src/main/java/io/ebean/config/DbConstraintNormalise.java @@ -27,7 +27,6 @@ public class DbConstraintNormalise { * quoted identifier characters (",',[,] etc). */ public String normaliseTable(String tableName) { - tableName = trimQuotes(tableName); int lastPeriod = tableName.lastIndexOf('.'); if (lastPeriod > -1) { @@ -59,7 +58,6 @@ public class DbConstraintNormalise { * Trim off the platform quoted identifier quotes like [ ' and ". */ public String trimQuotes(String identifier) { - if (identifier == null) { return ""; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/IndexDefinition.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/IndexDefinition.java index c87947386..18f840b4a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/IndexDefinition.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/IndexDefinition.java @@ -27,17 +27,24 @@ public final class IndexDefinition { } /** - * Create a unique constraint given the column names. + * Create from JPA Index. */ - public IndexDefinition(String name, String[] columns) { + public IndexDefinition(String name, String[] columns, boolean unique) { this.columns = columns; - this.unique = true; + this.unique = unique; this.name = name; this.platforms = null; this.concurrent = false; this.definition = null; } + /** + * Create a unique constraint given the column names. + */ + public IndexDefinition(String name, String[] columns) { + this(name, columns, true); + } + /** * Return true if this can be used as a unique constraint. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java index 662b73be8..fe45a72d8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java @@ -129,6 +129,10 @@ final class AnnotationClass extends AnnotationParser { for (UniqueConstraint c : uniqueConstraints) { descriptor.addIndex(new IndexDefinition(c.name(), convertColumnNames(c.columnNames()))); } + for (javax.persistence.Index index : table.indexes()) { + final String[] cols = index.columnList().split(","); + descriptor.addIndex(new IndexDefinition(index.name(), convertColumnNames(cols), index.unique())); + } } StorageEngine storage = typeGet(cls, StorageEngine.class); if (storage != null) { diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/DbConstraintNamingTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/DbConstraintNamingTest.java index b08777c04..21f77be2f 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/DbConstraintNamingTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/DbConstraintNamingTest.java @@ -31,6 +31,11 @@ public class DbConstraintNamingTest { assertThat(naming.normaliseTable("foo_bar]")).isEqualTo("foo_bar"); } + @Test + public void testIndexNameWithSpaces() { + assertThat(naming.indexName("foo", new String[]{"name", "other desc"})).isEqualTo("ix_foo_name_other_desc"); + } + @Test public void testDefaultToLower() { assertThat(naming.normaliseTable("SCH.FOO_BAR]")).isEqualTo("foo_bar"); diff --git a/ebean-test/src/test/java/org/tests/model/basic/FeatureDescription.java b/ebean-test/src/test/java/org/tests/model/basic/FeatureDescription.java index 955b5f7f6..a939f472b 100644 --- a/ebean-test/src/test/java/org/tests/model/basic/FeatureDescription.java +++ b/ebean-test/src/test/java/org/tests/model/basic/FeatureDescription.java @@ -4,11 +4,12 @@ import io.ebean.annotation.Cache; import javax.persistence.Entity; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.Table; @Cache(readOnly = true) @Entity -@Table(name = "feature_desc") +@Table(name = "feature_desc", indexes = @Index(columnList = "name, description desc")) public class FeatureDescription { @Id