mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Multi-platform tests
This commit is contained in:
+1
@@ -15,6 +15,7 @@ class ClickHouseDbArray {
|
||||
mapping.put("integer[]", "Array(UInt32)");
|
||||
mapping.put("bigint[]", "Array(UInt64)");
|
||||
mapping.put("float[]", "Array(Float32)");
|
||||
mapping.put("decimal[]", "Array(Decimal)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,9 +52,12 @@ public class DbMigrationGenerateTest {
|
||||
|
||||
migration.addPlatform(Platform.CLICKHOUSE);
|
||||
migration.addPlatform(Platform.COCKROACH);
|
||||
migration.addPlatform(Platform.DB2FORI);
|
||||
migration.addPlatform(Platform.DB2LUW);
|
||||
migration.addPlatform(Platform.DB2ZOS);
|
||||
// for platforms like DB2-LUW, we specify the exact platform in the migration path
|
||||
// see https://github.com/ebean-orm/ebean-migration/issues/102
|
||||
migration.addPlatform(Platform.DB2LUW, "db2luw");
|
||||
migration.addPlatform(Platform.DB2FORI, "db2fori");
|
||||
migration.addPlatform(Platform.DB2ZOS, "db2zos");
|
||||
migration.addPlatform(Platform.DB2, "db2legacy");
|
||||
migration.addPlatform(Platform.GENERIC);
|
||||
migration.addPlatform(Platform.H2);
|
||||
migration.addPlatform(Platform.HANA);
|
||||
@@ -62,16 +65,16 @@ public class DbMigrationGenerateTest {
|
||||
migration.addPlatform(Platform.MARIADB);
|
||||
migration.addPlatform(Platform.MARIADB, "mariadb-noprocs");
|
||||
migration.addPlatform(Platform.MYSQL);
|
||||
migration.addPlatform(Platform.MYSQL55);
|
||||
migration.addPlatform(Platform.MYSQL55, "mysql55");
|
||||
migration.addPlatform(Platform.NUODB);
|
||||
migration.addPlatform(Platform.ORACLE);
|
||||
migration.addPlatform(Platform.ORACLE11);
|
||||
migration.addPlatform(Platform.ORACLE11, "oracle11"); // uses sequences
|
||||
migration.addPlatform(Platform.POSTGRES);
|
||||
migration.addPlatform(Platform.POSTGRES9);
|
||||
migration.addPlatform(Platform.POSTGRES9, "postgres9"); // different DDL as base!
|
||||
migration.addPlatform(Platform.SQLANYWHERE);
|
||||
migration.addPlatform(Platform.SQLITE);
|
||||
migration.addPlatform(Platform.SQLSERVER16);
|
||||
migration.addPlatform(Platform.SQLSERVER17);
|
||||
migration.addPlatform(Platform.SQLSERVER16, "sqlserver16");
|
||||
migration.addPlatform(Platform.SQLSERVER17, "sqlserver17");
|
||||
migration.addPlatform(Platform.YUGABYTE);
|
||||
|
||||
|
||||
|
||||
@@ -5,15 +5,23 @@ import io.ebean.SqlRow;
|
||||
import io.ebean.SqlUpdate;
|
||||
import io.ebean.annotation.IgnorePlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.datasource.pool.ConnectionPool;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* This testcase tries to apply the migrationtests that are genearated by {@link DbMigrationGenerateTest}.
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
public class DbMigrationTest extends BaseTestCase {
|
||||
|
||||
private void runScript(String scriptName) throws IOException {
|
||||
@@ -30,12 +38,20 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
assertThat(LastMigration.nextVersion(d, null, true)).isEqualTo("1.4");
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.NUODB, Platform.POSTGRES, Platform.YUGABYTE})
|
||||
@IgnorePlatform({
|
||||
Platform.DB2, // currently does not work due missing reorg feature
|
||||
//Platform.CLICKHOUSE, // test(s) do not start at all
|
||||
//Platform.COCKROACH, // does not see applied DDL? commit missing?
|
||||
// Platform.NUODB nuodb container does not start
|
||||
})
|
||||
//Platform.ORACLE, Platform.NUODB, Platform.POSTGRES, Platform.YUGABYTE})
|
||||
// Note: Postgres locks up on build server
|
||||
// Note: YUGABYTE complains on "alter table migtest_e_basic alter column status set not null;"
|
||||
@Test
|
||||
public void testRunMigration() throws IOException {
|
||||
// first clean up previously created objects
|
||||
public void testRunMigration() throws IOException, SQLException {
|
||||
// Shutdown and reconnect - this prevents postgres from lock up
|
||||
((ConnectionPool)server().dataSource()).offline();
|
||||
((ConnectionPool)server().dataSource()).online();
|
||||
cleanup("migtest_ckey_assoc",
|
||||
"migtest_ckey_detail",
|
||||
"migtest_ckey_parent",
|
||||
@@ -63,7 +79,9 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
"migtest_mtm_m_migtest_mtm_c",
|
||||
"migtest_oto_child",
|
||||
"migtest_oto_master");
|
||||
|
||||
((ConnectionPool)server().dataSource()).offline();
|
||||
((ConnectionPool)server().dataSource()).online();
|
||||
|
||||
if (isSqlServer() || isMariaDB()) { // || isMySql()
|
||||
runScript("I__create_procs.sql");
|
||||
}
|
||||
|
||||
@@ -207,14 +207,15 @@ ebean.migrationtest.ddl.header=-- Migrationscripts for ebean unittest
|
||||
ebean.migrationtest.migration.appName=migrationtest
|
||||
ebean.migrationtest.migration.migrationPath=migrationtest/dbmigration
|
||||
ebean.migrationtest.migration.strict=true
|
||||
# enable stored procedures f
|
||||
dbmigration.platform.mariadb.useMigrationStoredProcedures=true
|
||||
dbmigration.platform.mysql.useMigrationStoredProcedures=true
|
||||
dbmigration.platform.mysql55.useMigrationStoredProcedures=true
|
||||
|
||||
# parameters for migration test
|
||||
datasource.migrationtest-history.username=SA
|
||||
datasource.migrationtest-history.password=SA
|
||||
datasource.migrationtest-history.url=jdbc:h2:mem:migration
|
||||
ebean.migrationtest-history.applyPrefix=V
|
||||
ebean.migrationtest-history.ddl.generate=false
|
||||
ebean.migrationtest-history.ddl.run=false
|
||||
ebean.migrationtest-history.ddl.header=-- Migrationscripts for ebean unittest DbMigrationDropHistoryTest
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer generated by default as identity not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer generated by default as identity not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id integer generated by default as identity not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date timestamp,
|
||||
old_boolean smallint default 0 default false not null,
|
||||
old_boolean2 smallint default 0,
|
||||
eref_id integer,
|
||||
indextest1 varchar(127),
|
||||
indextest2 varchar(127),
|
||||
indextest3 varchar(127),
|
||||
indextest4 varchar(127),
|
||||
indextest5 varchar(127),
|
||||
indextest6 varchar(127),
|
||||
user_id integer not null,
|
||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
|
||||
create table migtest_e_enum (
|
||||
id integer generated by default as identity not null,
|
||||
test_status varchar(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
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_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;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer generated by default as identity not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
value varchar(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_set_null drop constraint fk_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 restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic alter column status set default 'A';
|
||||
alter table migtest_e_basic alter column status set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(127);
|
||||
alter table migtest_e_basic alter column status2 drop default;
|
||||
alter table migtest_e_basic alter column status2 drop not null;
|
||||
|
||||
-- db2 does not support parial null indices :( - so we have to clean;
|
||||
update migtest_e_basic set status = 'N' where id = 1;
|
||||
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict;
|
||||
alter table migtest_e_basic alter column user_id drop not null;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field smallint default 0 default true not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 smallint default 0 default true not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history alter column test_string set data type bigint;
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
||||
alter table migtest_e_history2 alter column test_string set not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add column new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type bigint;
|
||||
alter table migtest_e_history5 add column test_boolean smallint default 0 default false not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 drop not null;
|
||||
alter table migtest_e_softdelete add column deleted smallint default 0 default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index ix_migtest_e_basic_indextest1;
|
||||
drop index ix_migtest_e_basic_indextest5;
|
||||
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;
|
||||
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict;
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
|
||||
alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id;
|
||||
alter table migtest_fk_set_null drop constraint fk_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;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic alter column status drop default;
|
||||
alter table migtest_e_basic alter column status drop not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(1);
|
||||
alter table migtest_e_basic alter column status2 set default 'N';
|
||||
alter table migtest_e_basic alter column status2 set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id;
|
||||
alter table migtest_e_basic alter column user_id set default 23;
|
||||
alter table migtest_e_basic alter column user_id set not null;
|
||||
alter table migtest_e_basic add column old_boolean smallint default 0 default false not null;
|
||||
alter table migtest_e_basic add column old_boolean2 smallint default 0;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 alter column test_string drop default;
|
||||
alter table migtest_e_history2 alter column test_string drop not null;
|
||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 drop not null;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
drop index ix_migtest_e_basic_indextest3;
|
||||
drop index ix_migtest_e_basic_indextest6;
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
545908658, 1.0__initial.sql
|
||||
-1594597621, 1.1.sql
|
||||
578073685, 1.2__dropsFor_1.1.sql
|
||||
99025497, 1.3.sql
|
||||
441227910, 1.4__dropsFor_1.3.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer generated by default as identity not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer generated by default as identity not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id integer generated by default as identity not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date timestamp,
|
||||
old_boolean boolean default false not null,
|
||||
old_boolean2 boolean,
|
||||
eref_id integer,
|
||||
indextest1 varchar(127),
|
||||
indextest2 varchar(127),
|
||||
indextest3 varchar(127),
|
||||
indextest4 varchar(127),
|
||||
indextest5 varchar(127),
|
||||
indextest6 varchar(127),
|
||||
user_id integer not null,
|
||||
constraint ck_mgtst__bsc_stts check ( status in ('N','A','I')),
|
||||
constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I')),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
|
||||
create table migtest_e_enum (
|
||||
id integer generated by default as identity not null,
|
||||
test_status varchar(1),
|
||||
constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
|
||||
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
|
||||
create index ix_mgtst_fk_mok1xj on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
create index ix_mgtst_fk_c4p3mv on migtest_fk_set_null (one_id);
|
||||
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete set null;
|
||||
|
||||
create index ix_mgtst__bsc_rf_d on migtest_e_basic (eref_id);
|
||||
alter table migtest_e_basic add constraint fk_mgtst__bsc_rf_d foreign key (eref_id) references migtest_e_ref (id) on delete restrict;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer generated by default as identity not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
value varchar(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_mgtst_ck_e1qkb5 foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
|
||||
alter table migtest_fk_none add constraint fk_mgtst_fk_nn_n_d foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_9tknzj foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x;
|
||||
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts;
|
||||
alter table migtest_e_basic alter column status set default 'A';
|
||||
alter table migtest_e_basic alter column status set not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(127);
|
||||
alter table migtest_e_basic alter column status2 drop default;
|
||||
alter table migtest_e_basic alter column status2 drop not null;
|
||||
|
||||
-- db2 does not support parial null indices :( - so we have to clean;
|
||||
update migtest_e_basic set status = 'N' where id = 1;
|
||||
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_mgtst__bsc_sr_d foreign key (user_id) references migtest_e_user (id) on delete restrict;
|
||||
alter table migtest_e_basic alter column user_id drop not null;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02;
|
||||
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok;
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history alter column test_string set data type bigint;
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
||||
alter table migtest_e_history2 alter column test_string set not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add column new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 drop not null;
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3);
|
||||
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
|
||||
drop index ix_mgtst__b_eu8csq;
|
||||
drop index ix_mgtst__b_eu8csu;
|
||||
create index ix_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_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_do9ma3 on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_mgtst_mt_s8neid foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_ck_x45o21 on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_mgtst_ck_da00mr foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict;
|
||||
|
||||
alter table migtest_oto_child add constraint fk_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict;
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_e_basic drop column old_boolean;
|
||||
|
||||
alter table migtest_e_basic drop column old_boolean2;
|
||||
|
||||
alter table migtest_e_basic drop column eref_id;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string1;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string2;
|
||||
|
||||
drop table migtest_e_ref;
|
||||
drop sequence migtest_e_ref_seq;
|
||||
@@ -0,0 +1,67 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5;
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d;
|
||||
alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj;
|
||||
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x;
|
||||
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete set null;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts;
|
||||
alter table migtest_e_basic alter column status drop default;
|
||||
alter table migtest_e_basic alter column status drop not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(1);
|
||||
alter table migtest_e_basic alter column status2 set default 'N';
|
||||
alter table migtest_e_basic alter column status2 set not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d;
|
||||
alter table migtest_e_basic alter column user_id set default 23;
|
||||
alter table migtest_e_basic alter column user_id set not null;
|
||||
alter table migtest_e_basic add column old_boolean boolean default false not null;
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01;
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok;
|
||||
alter table migtest_e_enum add constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 alter column test_string drop default;
|
||||
alter table migtest_e_history2 alter column test_string drop not null;
|
||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 drop not null;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
|
||||
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
|
||||
drop index ix_mgtst__b_eu8css;
|
||||
drop index ix_mgtst__b_eu8csv;
|
||||
create index ix_mgtst__bsc_rf_d on migtest_e_basic (eref_id);
|
||||
alter table migtest_e_basic add constraint fk_mgtst__bsc_rf_d foreign key (eref_id) references migtest_e_ref (id) on delete restrict;
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field2;
|
||||
|
||||
alter table migtest_e_basic drop column progress;
|
||||
|
||||
alter table migtest_e_basic drop column new_integer;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string2;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string3;
|
||||
|
||||
alter table migtest_e_history2 drop column new_column;
|
||||
|
||||
alter table migtest_e_history5 drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table migtest_e_user;
|
||||
drop sequence migtest_e_user_seq;
|
||||
drop table migtest_mtm_c_migtest_mtm_m;
|
||||
drop table migtest_mtm_m_migtest_mtm_c;
|
||||
drop table migtest_mtm_m_phone_numbers;
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-1494430232, 1.0__initial.sql
|
||||
-1126979163, 1.1.sql
|
||||
578073685, 1.2__dropsFor_1.1.sql
|
||||
-183167227, 1.3.sql
|
||||
441227910, 1.4__dropsFor_1.3.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_e_basic drop column old_boolean;
|
||||
|
||||
alter table migtest_e_basic drop column old_boolean2;
|
||||
|
||||
alter table migtest_e_basic drop column eref_id;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string1;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string2;
|
||||
|
||||
drop table migtest_e_ref;
|
||||
drop sequence migtest_e_ref_seq;
|
||||
@@ -0,0 +1,35 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field2;
|
||||
|
||||
alter table migtest_e_basic drop column progress;
|
||||
|
||||
alter table migtest_e_basic drop column new_integer;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string2;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string3;
|
||||
|
||||
alter table migtest_e_history2 drop column new_column;
|
||||
|
||||
alter table migtest_e_history5 drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table migtest_e_user;
|
||||
drop sequence migtest_e_user_seq;
|
||||
drop table migtest_mtm_c_migtest_mtm_m;
|
||||
drop table migtest_mtm_m_migtest_mtm_c;
|
||||
drop table migtest_mtm_m_phone_numbers;
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer generated by default as identity not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer generated by default as identity not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id integer generated by default as identity not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date timestamp,
|
||||
old_boolean boolean default false not null,
|
||||
old_boolean2 boolean,
|
||||
eref_id integer,
|
||||
indextest1 varchar(127),
|
||||
indextest2 varchar(127),
|
||||
indextest3 varchar(127),
|
||||
indextest4 varchar(127),
|
||||
indextest5 varchar(127),
|
||||
indextest6 varchar(127),
|
||||
user_id integer not null,
|
||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
|
||||
create table migtest_e_enum (
|
||||
id integer generated by default as identity not null,
|
||||
test_status varchar(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer generated by default as identity not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
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_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;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer generated by default as identity not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
value varchar(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_set_null drop constraint fk_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 restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic alter column status set default 'A';
|
||||
alter table migtest_e_basic alter column status set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(127);
|
||||
alter table migtest_e_basic alter column status2 drop default;
|
||||
alter table migtest_e_basic alter column status2 drop not null;
|
||||
|
||||
-- db2 does not support parial null indices :( - so we have to clean;
|
||||
update migtest_e_basic set status = 'N' where id = 1;
|
||||
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict;
|
||||
alter table migtest_e_basic alter column user_id drop not null;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history alter column test_string set data type bigint;
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
||||
alter table migtest_e_history2 alter column test_string set not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add column new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 drop not null;
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index ix_migtest_e_basic_indextest1;
|
||||
drop index ix_migtest_e_basic_indextest5;
|
||||
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;
|
||||
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict;
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_e_basic drop column old_boolean;
|
||||
|
||||
alter table migtest_e_basic drop column old_boolean2;
|
||||
|
||||
alter table migtest_e_basic drop column eref_id;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string1;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string2;
|
||||
|
||||
drop table migtest_e_ref;
|
||||
drop sequence migtest_e_ref_seq;
|
||||
@@ -0,0 +1,67 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
|
||||
alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id;
|
||||
alter table migtest_fk_set_null drop constraint fk_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;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic alter column status drop default;
|
||||
alter table migtest_e_basic alter column status drop not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(1);
|
||||
alter table migtest_e_basic alter column status2 set default 'N';
|
||||
alter table migtest_e_basic alter column status2 set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id;
|
||||
alter table migtest_e_basic alter column user_id set default 23;
|
||||
alter table migtest_e_basic alter column user_id set not null;
|
||||
alter table migtest_e_basic add column old_boolean boolean default false not null;
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 alter column test_string drop default;
|
||||
alter table migtest_e_history2 alter column test_string drop not null;
|
||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 drop not null;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
drop index ix_migtest_e_basic_indextest3;
|
||||
drop index ix_migtest_e_basic_indextest6;
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field2;
|
||||
|
||||
alter table migtest_e_basic drop column progress;
|
||||
|
||||
alter table migtest_e_basic drop column new_integer;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string2;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string3;
|
||||
|
||||
alter table migtest_e_history2 drop column new_column;
|
||||
|
||||
alter table migtest_e_history5 drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table migtest_e_user;
|
||||
drop sequence migtest_e_user_seq;
|
||||
drop table migtest_mtm_c_migtest_mtm_m;
|
||||
drop table migtest_mtm_m_migtest_mtm_c;
|
||||
drop table migtest_mtm_m_phone_numbers;
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
1580812656, 1.0__initial.sql
|
||||
1615151513, 1.1.sql
|
||||
578073685, 1.2__dropsFor_1.1.sql
|
||||
-1206650320, 1.3.sql
|
||||
441227910, 1.4__dropsFor_1.3.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -60,7 +60,7 @@ create table migtest_e_basic (
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date datetime,
|
||||
some_date datetime(6),
|
||||
old_boolean tinyint(1) default 0 not null,
|
||||
old_boolean2 tinyint(1),
|
||||
eref_id integer,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
1835064798, I__create_procs.sql
|
||||
-1087663151, 1.0__initial.sql
|
||||
1075178692, 1.0__initial.sql
|
||||
-1627573867, 1.1.sql
|
||||
1922991807, 1.2__dropsFor_1.1.sql
|
||||
-380371830, 1.3.sql
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer auto_increment not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer auto_increment not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigint auto_increment not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id bigint auto_increment not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id bigint auto_increment not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id bigint auto_increment not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id bigint auto_increment not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id bigint auto_increment not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id integer auto_increment not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date datetime,
|
||||
old_boolean tinyint(1) default 0 not null,
|
||||
old_boolean2 tinyint(1),
|
||||
eref_id integer,
|
||||
indextest1 varchar(127),
|
||||
indextest2 varchar(127),
|
||||
indextest3 varchar(127),
|
||||
indextest4 varchar(127),
|
||||
indextest5 varchar(127),
|
||||
indextest6 varchar(127),
|
||||
user_id integer not null,
|
||||
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
|
||||
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_enum (
|
||||
id integer auto_increment not null,
|
||||
test_status varchar(1),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id integer auto_increment not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id integer auto_increment not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id integer auto_increment not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer auto_increment not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer auto_increment not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer auto_increment not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer auto_increment not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigint auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigint auto_increment not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
|
||||
|
||||
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_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;
|
||||
|
||||
alter table migtest_e_history2 add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history2 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history2_history(
|
||||
id integer,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history3 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history3_history(
|
||||
id integer,
|
||||
test_string varchar(255),
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
|
||||
|
||||
alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history4 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history4_history(
|
||||
id integer,
|
||||
test_number integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
|
||||
|
||||
alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history5 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history5_history(
|
||||
id integer,
|
||||
test_number integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
|
||||
|
||||
alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history6 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history6_history(
|
||||
id integer,
|
||||
test_number1 integer,
|
||||
test_number2 integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
|
||||
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin
|
||||
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin
|
||||
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
|
||||
end$$
|
||||
@@ -0,0 +1,199 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
drop view if exists migtest_e_history3_with_history;
|
||||
drop view if exists migtest_e_history4_with_history;
|
||||
drop view if exists migtest_e_history5_with_history;
|
||||
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer auto_increment not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
value varchar(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_set_null drop foreign key fk_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 restrict on update restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic alter status set default 'A';
|
||||
alter table migtest_e_basic modify status varchar(1) not null;
|
||||
alter table migtest_e_basic alter status2 drop default;
|
||||
alter table migtest_e_basic modify status2 varchar(127);
|
||||
|
||||
-- rename all collisions;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
|
||||
alter table migtest_e_basic modify user_id integer;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field tinyint(1) default 1 not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 tinyint(1) default 1 not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
alter table migtest_e_history modify test_string bigint;
|
||||
alter table migtest_e_history comment = 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter test_string set default 'unknown';
|
||||
alter table migtest_e_history2 modify test_string varchar(255) not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add column new_column varchar(20);
|
||||
alter table migtest_e_history2_history add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown';
|
||||
alter table migtest_e_history2_history add column new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 modify test_number bigint;
|
||||
alter table migtest_e_history4_history modify test_number bigint;
|
||||
alter table migtest_e_history5 add column test_boolean tinyint(1) default 0 not null;
|
||||
alter table migtest_e_history5_history add column test_boolean tinyint(1) default 0;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter test_number1 set default 42;
|
||||
alter table migtest_e_history6 modify test_number1 integer not null;
|
||||
alter table migtest_e_history6 modify test_number2 integer;
|
||||
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index ix_migtest_e_basic_indextest1 on migtest_e_basic;
|
||||
drop index ix_migtest_e_basic_indextest5 on migtest_e_basic;
|
||||
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;
|
||||
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
|
||||
alter table migtest_e_history add column sys_period_end datetime(6);
|
||||
create table migtest_e_history_history(
|
||||
id integer,
|
||||
test_string bigint,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
|
||||
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
|
||||
|
||||
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
|
||||
|
||||
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
|
||||
|
||||
delimiter $$
|
||||
create trigger migtest_e_history_history_upd before update on migtest_e_history for each row begin
|
||||
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history_history_del before delete on migtest_e_history for each row begin
|
||||
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
end$$
|
||||
lock tables migtest_e_history2 write, migtest_e_history3 write, migtest_e_history4 write, migtest_e_history5 write;
|
||||
-- changes: [add test_string2, add test_string3, add new_column]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column, obsolete_string1, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column, OLD.obsolete_string1, OLD.obsolete_string2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column, obsolete_string1, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column, OLD.obsolete_string1, OLD.obsolete_string2);
|
||||
end$$
|
||||
-- changes: [exclude test_string]
|
||||
drop trigger migtest_e_history3_history_upd;
|
||||
drop trigger migtest_e_history3_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
|
||||
end$$
|
||||
-- changes: [alter test_number]
|
||||
drop trigger migtest_e_history4_history_upd;
|
||||
drop trigger migtest_e_history4_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
-- changes: [add test_boolean]
|
||||
drop trigger migtest_e_history5_history_upd;
|
||||
drop trigger migtest_e_history5_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
|
||||
end$$
|
||||
unlock tables;
|
||||
@@ -0,0 +1,34 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
|
||||
-- apply changes
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean2');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'eref_id');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string1');
|
||||
CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string1');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string2');
|
||||
CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string2');
|
||||
|
||||
drop table if exists migtest_e_ref;
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
lock tables migtest_e_history2 write;
|
||||
-- changes: [drop obsolete_string1, drop obsolete_string2]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
|
||||
end$$
|
||||
unlock tables;
|
||||
@@ -0,0 +1,115 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
drop view if exists migtest_e_history3_with_history;
|
||||
drop view if exists migtest_e_history4_with_history;
|
||||
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail drop foreign key fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
|
||||
alter table migtest_fk_none drop foreign key fk_migtest_fk_none_one_id;
|
||||
alter table migtest_fk_none_via_join drop foreign key fk_migtest_fk_none_via_join_one_id;
|
||||
alter table migtest_fk_set_null drop foreign key fk_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;
|
||||
alter table migtest_e_basic alter status drop default;
|
||||
alter table migtest_e_basic modify status varchar(1);
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic alter status2 set default 'N';
|
||||
alter table migtest_e_basic modify status2 varchar(1) not null;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_description;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table migtest_e_basic drop foreign key fk_migtest_e_basic_user_id;
|
||||
alter table migtest_e_basic alter user_id set default 23;
|
||||
alter table migtest_e_basic modify user_id integer not null;
|
||||
alter table migtest_e_basic add column old_boolean tinyint(1) default 0 not null;
|
||||
alter table migtest_e_basic add column old_boolean2 tinyint(1);
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
|
||||
alter table migtest_e_history comment = '';
|
||||
alter table migtest_e_history2 alter test_string drop default;
|
||||
alter table migtest_e_history2 modify test_string varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2_history add column obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 modify test_number integer;
|
||||
alter table migtest_e_history4_history modify test_number integer;
|
||||
alter table migtest_e_history6 alter test_number1 drop default;
|
||||
alter table migtest_e_history6 modify test_number1 integer;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter test_number2 set default 7;
|
||||
alter table migtest_e_history6 modify test_number2 integer not null;
|
||||
alter table migtest_oto_child add constraint uq_m12_otoc72 unique (name);
|
||||
alter table migtest_oto_master add constraint uq_migtest_oto_master_name unique (name);
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index ix_m12_otoc72 on migtest_oto_child (name);
|
||||
create index ix_migtest_oto_master_name on migtest_oto_master (name);
|
||||
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
|
||||
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
|
||||
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;
|
||||
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
|
||||
|
||||
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
|
||||
|
||||
lock tables migtest_e_history2 write, migtest_e_history3 write, migtest_e_history4 write;
|
||||
-- changes: [add obsolete_string1, add obsolete_string2]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2, test_string2, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2, OLD.test_string2, OLD.test_string3, OLD.new_column);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2, test_string2, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2, OLD.test_string2, OLD.test_string3, OLD.new_column);
|
||||
end$$
|
||||
-- changes: [include test_string]
|
||||
drop trigger migtest_e_history3_history_upd;
|
||||
drop trigger migtest_e_history3_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
end$$
|
||||
-- changes: [alter test_number]
|
||||
drop trigger migtest_e_history4_history_upd;
|
||||
drop trigger migtest_e_history4_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
unlock tables;
|
||||
@@ -0,0 +1,79 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop trigger migtest_e_history_history_upd;
|
||||
drop trigger migtest_e_history_history_del;
|
||||
drop view migtest_e_history_with_history;
|
||||
CALL usp_ebean_drop_column('migtest_e_history', 'sys_period_start');
|
||||
CALL usp_ebean_drop_column('migtest_e_history', 'sys_period_end');
|
||||
drop table migtest_e_history_history;
|
||||
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
drop view if exists migtest_e_history5_with_history;
|
||||
|
||||
-- apply changes
|
||||
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'new_string_field');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field2');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'progress');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'new_integer');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_history2', 'test_string2');
|
||||
CALL usp_ebean_drop_column('migtest_e_history2_history', 'test_string2');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_history2', 'test_string3');
|
||||
CALL usp_ebean_drop_column('migtest_e_history2_history', 'test_string3');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_history2', 'new_column');
|
||||
CALL usp_ebean_drop_column('migtest_e_history2_history', 'new_column');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
|
||||
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
|
||||
|
||||
drop table if exists migtest_e_user;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
||||
drop table if exists migtest_mtm_m_phone_numbers;
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
|
||||
|
||||
lock tables migtest_e_history2 write, migtest_e_history5 write;
|
||||
-- changes: [drop test_string2, drop test_string3, drop new_column]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
end$$
|
||||
-- changes: [drop test_boolean]
|
||||
drop trigger migtest_e_history5_history_upd;
|
||||
drop trigger migtest_e_history5_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
unlock tables;
|
||||
@@ -0,0 +1,48 @@
|
||||
-- Inital script to create stored procedures etc for mysql platform
|
||||
DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys;
|
||||
|
||||
delimiter $$
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
|
||||
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
|
||||
--
|
||||
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
|
||||
BEGIN
|
||||
DECLARE done INT DEFAULT FALSE;
|
||||
DECLARE c_fk_name CHAR(255);
|
||||
DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
|
||||
WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name
|
||||
AND REFERENCED_TABLE_NAME IS NOT NULL;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
|
||||
OPEN curs;
|
||||
|
||||
read_loop: LOOP
|
||||
FETCH curs INTO c_fk_name;
|
||||
IF done THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
END LOOP;
|
||||
|
||||
CLOSE curs;
|
||||
END
|
||||
$$
|
||||
|
||||
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
|
||||
|
||||
delimiter $$
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
|
||||
-- deletes the column and ensures that all indices and constraints are dropped first
|
||||
--
|
||||
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
|
||||
BEGIN
|
||||
CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
|
||||
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
END
|
||||
$$
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
1835064798, I__create_procs.sql
|
||||
-1087663151, 1.0__initial.sql
|
||||
-1627573867, 1.1.sql
|
||||
1922991807, 1.2__dropsFor_1.1.sql
|
||||
-380371830, 1.3.sql
|
||||
-1373040825, 1.4__dropsFor_1.3.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
assoc_one varchar2(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_assoc_seq;
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
something varchar2(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_detail_seq;
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key number(10) not null,
|
||||
@@ -23,47 +21,41 @@ create table migtest_ckey_parent (
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_cascade_seq;
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_cascade_one_seq;
|
||||
|
||||
create table migtest_fk_none (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_none_seq;
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_none_via_join_seq;
|
||||
|
||||
create table migtest_fk_one (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_one_seq;
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_set_null_seq;
|
||||
|
||||
create table migtest_e_basic (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
status varchar2(1),
|
||||
status2 varchar2(1) default 'N' not null,
|
||||
name varchar2(127),
|
||||
@@ -85,103 +77,89 @@ create table migtest_e_basic (
|
||||
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
create sequence migtest_e_basic_seq;
|
||||
|
||||
create table migtest_e_enum (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_status varchar2(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
create sequence migtest_e_enum_seq;
|
||||
|
||||
create table migtest_e_history (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history_seq;
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_string varchar2(255),
|
||||
obsolete_string1 varchar2(255),
|
||||
obsolete_string2 varchar2(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history2_seq;
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history3_seq;
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_number number(10),
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history4_seq;
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_number number(10),
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history5_seq;
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_number1 number(10),
|
||||
test_number2 number(10) not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history6_seq;
|
||||
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
name varchar2(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
create sequence migtest_e_ref_seq;
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
create sequence migtest_e_softdelete_seq;
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_c_seq;
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_m_seq;
|
||||
|
||||
create table migtest_oto_child (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_child_seq;
|
||||
|
||||
create table migtest_oto_master (
|
||||
id number(19) not null,
|
||||
id number(19) generated by default as identity not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_master_seq;
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
create sequence migtest_e_user_seq;
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id number(10) not null,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
id number(10) generated by default as identity not null,
|
||||
name varchar2(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
create sequence migtest_e_ref_seq;
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
1839897438, 1.0__initial.sql
|
||||
1927010726, 1.1.sql
|
||||
1164675950, 1.0__initial.sql
|
||||
-411370666, 1.1.sql
|
||||
238598298, 1.2__dropsFor_1.1.sql
|
||||
1543053715, 1.3.sql
|
||||
483114276, 1.3.sql
|
||||
-629809805, 1.4__dropsFor_1.3.sql
|
||||
1357801733, R__oracle_only_views.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id number(10) not null,
|
||||
assoc_one varchar2(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_assoc_seq;
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id number(10) not null,
|
||||
something varchar2(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_detail_seq;
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key number(10) not null,
|
||||
two_key varchar2(127) not null,
|
||||
name varchar2(255),
|
||||
version number(10) not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id number(19) not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_cascade_seq;
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id number(19) not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_cascade_one_seq;
|
||||
|
||||
create table migtest_fk_none (
|
||||
id number(19) not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_none_seq;
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id number(19) not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_none_via_join_seq;
|
||||
|
||||
create table migtest_fk_one (
|
||||
id number(19) not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_one_seq;
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id number(19) not null,
|
||||
one_id number(19),
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_set_null_seq;
|
||||
|
||||
create table migtest_e_basic (
|
||||
id number(10) not null,
|
||||
status varchar2(1),
|
||||
status2 varchar2(1) default 'N' not null,
|
||||
name varchar2(127),
|
||||
description varchar2(127),
|
||||
some_date timestamp,
|
||||
old_boolean number(1) default 0 not null,
|
||||
old_boolean2 number(1),
|
||||
eref_id number(10),
|
||||
indextest1 varchar2(127),
|
||||
indextest2 varchar2(127),
|
||||
indextest3 varchar2(127),
|
||||
indextest4 varchar2(127),
|
||||
indextest5 varchar2(127),
|
||||
indextest6 varchar2(127),
|
||||
user_id number(10) not null,
|
||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
||||
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
|
||||
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
create sequence migtest_e_basic_seq;
|
||||
|
||||
create table migtest_e_enum (
|
||||
id number(10) not null,
|
||||
test_status varchar2(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
create sequence migtest_e_enum_seq;
|
||||
|
||||
create table migtest_e_history (
|
||||
id number(10) not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history_seq;
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id number(10) not null,
|
||||
test_string varchar2(255),
|
||||
obsolete_string1 varchar2(255),
|
||||
obsolete_string2 varchar2(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history2_seq;
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id number(10) not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history3_seq;
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id number(10) not null,
|
||||
test_number number(10),
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history4_seq;
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id number(10) not null,
|
||||
test_number number(10),
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history5_seq;
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id number(10) not null,
|
||||
test_number1 number(10),
|
||||
test_number2 number(10) not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history6_seq;
|
||||
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
name varchar2(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
create sequence migtest_e_ref_seq;
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id number(10) not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
create sequence migtest_e_softdelete_seq;
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id number(10) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_c_seq;
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id number(19) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_m_seq;
|
||||
|
||||
create table migtest_oto_child (
|
||||
id number(10) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_child_seq;
|
||||
|
||||
create table migtest_oto_master (
|
||||
id number(19) not null,
|
||||
name varchar2(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_master_seq;
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
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_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);
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id number(10) not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
create sequence migtest_e_user_seq;
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id number(10) not null,
|
||||
migtest_mtm_m_id number(19) not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id number(19) not null,
|
||||
migtest_mtm_c_id number(10) not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id number(19) not null,
|
||||
value varchar2(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add one_key number(10);
|
||||
alter table migtest_ckey_detail add two_key varchar2(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
|
||||
alter table migtest_ckey_parent add assoc_id number(10);
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
|
||||
alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_nn_v_jn_n_d foreign key (one_id) references migtest_fk_one (id);
|
||||
alter table migtest_fk_set_null drop constraint fk_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);
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic modify status default 'A';
|
||||
alter table migtest_e_basic modify status not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic modify status2 varchar2(127);
|
||||
alter table migtest_e_basic modify status2 drop default;
|
||||
alter table migtest_e_basic modify status2 null;
|
||||
|
||||
-- rename all collisions;
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id);
|
||||
alter table migtest_e_basic modify user_id null;
|
||||
alter table migtest_e_basic add new_string_field varchar2(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add new_boolean_field number(1) default 1 not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add new_boolean_field2 number(1) default 1 not null;
|
||||
alter table migtest_e_basic add progress number(10) default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add new_integer number(10) default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_mgtst__bsc_stts_ndxtst1 unique (status,indextest1);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history modify test_string number(19);
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 modify test_string default 'unknown';
|
||||
alter table migtest_e_history2 modify test_string not null;
|
||||
alter table migtest_e_history2 add test_string2 varchar2(255);
|
||||
alter table migtest_e_history2 add test_string3 varchar2(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add new_column varchar2(20);
|
||||
|
||||
alter table migtest_e_history4 modify test_number number(19);
|
||||
alter table migtest_e_history5 add test_boolean number(1) default 0 not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 modify test_number1 default 42;
|
||||
alter table migtest_e_history6 modify test_number1 not null;
|
||||
alter table migtest_e_history6 modify test_number2 null;
|
||||
alter table migtest_e_softdelete add deleted number(1) default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add master_id number(19);
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
drop index ix_migtest_e_basic_indextest1;
|
||||
drop index ix_migtest_e_basic_indextest5;
|
||||
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);
|
||||
|
||||
create index ix_mgtst_mtm_c_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
|
||||
create index ix_mgtst_mtm_m_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
|
||||
create index ix_mgtst_mtm_m_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
|
||||
|
||||
create index ix_mgtst_mtm_m_phn_nmbr_do9ma3 on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_mgtst_mtm_m_phn_nmbr_s8neid foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
|
||||
create index ix_mgtst_cky_prnt_ssc_d on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_mgtst_cky_prnt_ssc_d foreign key (assoc_id) references migtest_ckey_assoc (id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_e_basic drop column old_boolean;
|
||||
|
||||
alter table migtest_e_basic drop column old_boolean2;
|
||||
|
||||
alter table migtest_e_basic drop column eref_id;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string1;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string2;
|
||||
|
||||
drop table migtest_e_ref cascade constraints purge;
|
||||
drop sequence migtest_e_ref_seq;
|
||||
@@ -0,0 +1,68 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
name varchar2(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
create sequence migtest_e_ref_seq;
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
|
||||
alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_nn_v_jn_n_d;
|
||||
alter table migtest_fk_set_null drop constraint fk_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;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic modify status drop default;
|
||||
alter table migtest_e_basic modify status null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic modify status2 varchar2(1);
|
||||
alter table migtest_e_basic modify status2 default 'N';
|
||||
alter table migtest_e_basic modify status2 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id;
|
||||
alter table migtest_e_basic modify user_id default 23;
|
||||
alter table migtest_e_basic modify user_id not null;
|
||||
alter table migtest_e_basic add old_boolean number(1) default 0 not null;
|
||||
alter table migtest_e_basic add old_boolean2 number(1);
|
||||
alter table migtest_e_basic add eref_id number(10);
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__bsc_stts_ndxtst1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2);
|
||||
-- NOT YET IMPLEMENTED: alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
|
||||
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 modify test_string drop default;
|
||||
alter table migtest_e_history2 modify test_string null;
|
||||
alter table migtest_e_history2 add obsolete_string1 varchar2(255);
|
||||
alter table migtest_e_history2 add obsolete_string2 varchar2(255);
|
||||
|
||||
alter table migtest_e_history4 modify test_number number(10);
|
||||
alter table migtest_e_history6 modify test_number1 drop default;
|
||||
alter table migtest_e_history6 modify test_number1 null;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 modify test_number2 default 7;
|
||||
alter table migtest_e_history6 modify test_number2 not null;
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
drop index ix_migtest_e_basic_indextest3;
|
||||
drop index ix_migtest_e_basic_indextest6;
|
||||
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);
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field2;
|
||||
|
||||
alter table migtest_e_basic drop column progress;
|
||||
|
||||
alter table migtest_e_basic drop column new_integer;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string2;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string3;
|
||||
|
||||
alter table migtest_e_history2 drop column new_column;
|
||||
|
||||
alter table migtest_e_history5 drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table migtest_e_user cascade constraints purge;
|
||||
drop sequence migtest_e_user_seq;
|
||||
drop table migtest_mtm_c_migtest_mtm_m cascade constraints purge;
|
||||
drop table migtest_mtm_m_migtest_mtm_c cascade constraints purge;
|
||||
drop table migtest_mtm_m_phone_numbers cascade constraints purge;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
|
||||
-- oracle only script
|
||||
select * from dual;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
1839897438, 1.0__initial.sql
|
||||
1927010726, 1.1.sql
|
||||
238598298, 1.2__dropsFor_1.1.sql
|
||||
1543053715, 1.3.sql
|
||||
-629809805, 1.4__dropsFor_1.3.sql
|
||||
1357801733, R__oracle_only_views.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
@@ -21,41 +21,41 @@ create table migtest_ckey_parent (
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
@@ -79,20 +79,20 @@ create table migtest_e_basic (
|
||||
);
|
||||
|
||||
create table migtest_e_enum (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_status varchar(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
@@ -100,63 +100,63 @@ create table migtest_e_history2 (
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigserial not null,
|
||||
id bigint generated by default as identity not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ drop view if exists migtest_e_history5_with_history;
|
||||
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ drop view if exists migtest_e_history4_with_history;
|
||||
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id serial not null,
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
1428934272, 1.0__initial.sql
|
||||
1253246780, 1.1.sql
|
||||
1329543701, 1.0__initial.sql
|
||||
1548995254, 1.1.sql
|
||||
-1861367028, 1.2__dropsFor_1.1.sql
|
||||
326342179, 1.3.sql
|
||||
-1798982281, 1.3.sql
|
||||
-1991941691, 1.4__dropsFor_1.3.sql
|
||||
783227075, R__multi_comments.sql
|
||||
561281075, R__order_views.sql
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id serial not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id serial not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id bigserial not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id bigserial not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id bigserial not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id bigserial not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id bigserial not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id bigserial not null,
|
||||
one_id bigint,
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id serial not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date timestamptz,
|
||||
old_boolean boolean default false not null,
|
||||
old_boolean2 boolean,
|
||||
eref_id integer,
|
||||
indextest1 varchar(127),
|
||||
indextest2 varchar(127),
|
||||
indextest3 varchar(127),
|
||||
indextest4 varchar(127),
|
||||
indextest5 varchar(127),
|
||||
indextest6 varchar(127),
|
||||
user_id integer not null,
|
||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
||||
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
|
||||
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_enum (
|
||||
id serial not null,
|
||||
test_status varchar(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id serial not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id serial not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id serial not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id serial not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id serial not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id serial not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id serial not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id serial not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id serial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id bigserial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id serial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id bigserial not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index if not exists ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index if not exists ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index idxd_migtest_0 on migtest_oto_child using hash (upper(name)) where upper(name) = 'JIM';
|
||||
create index concurrently if not exists ix_migtest_oto_child_lowername_id on migtest_oto_child (lower(name),id);
|
||||
create index if not exists ix_migtest_oto_child_lowername on migtest_oto_child (lower(name));
|
||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
|
||||
|
||||
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_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;
|
||||
|
||||
alter table migtest_e_history2 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history2_history(like migtest_e_history2);
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
alter table migtest_e_history3 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history3_history(like migtest_e_history3);
|
||||
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
|
||||
|
||||
alter table migtest_e_history4 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history4_history(like migtest_e_history4);
|
||||
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
|
||||
|
||||
alter table migtest_e_history5 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history5_history(like migtest_e_history5);
|
||||
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
|
||||
|
||||
alter table migtest_e_history6 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history6_history(like migtest_e_history6);
|
||||
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
|
||||
|
||||
create or replace function migtest_e_history2_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
create trigger migtest_e_history2_history_upd
|
||||
before update or delete on migtest_e_history2
|
||||
for each row execute procedure migtest_e_history2_history_version();
|
||||
|
||||
create or replace function migtest_e_history3_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history3_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history3_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
create trigger migtest_e_history3_history_upd
|
||||
before update or delete on migtest_e_history3
|
||||
for each row execute procedure migtest_e_history3_history_version();
|
||||
|
||||
create or replace function migtest_e_history4_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
create trigger migtest_e_history4_history_upd
|
||||
before update or delete on migtest_e_history4
|
||||
for each row execute procedure migtest_e_history4_history_version();
|
||||
|
||||
create or replace function migtest_e_history5_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history5_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history5_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
create trigger migtest_e_history5_history_upd
|
||||
before update or delete on migtest_e_history5
|
||||
for each row execute procedure migtest_e_history5_history_version();
|
||||
|
||||
create or replace function migtest_e_history6_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
create trigger migtest_e_history6_history_upd
|
||||
before update or delete on migtest_e_history6
|
||||
for each row execute procedure migtest_e_history6_history_version();
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
drop view if exists migtest_e_history3_with_history;
|
||||
drop view if exists migtest_e_history4_with_history;
|
||||
drop view if exists migtest_e_history5_with_history;
|
||||
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id serial not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
value varchar(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
||||
alter table if exists migtest_fk_set_null drop constraint if exists fk_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 restrict on update restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic alter column status set default 'A';
|
||||
alter table migtest_e_basic alter column status set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic alter column status2 type varchar(127) using status2::varchar(127);
|
||||
alter table migtest_e_basic alter column status2 drop default;
|
||||
alter table migtest_e_basic alter column status2 drop not null;
|
||||
|
||||
-- rename all collisions;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
|
||||
alter table migtest_e_basic alter column user_id drop not null;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
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_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
||||
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
|
||||
|
||||
alter table migtest_e_history alter column test_string TYPE bigint USING (test_string::integer);
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history alter column test_string type bigint using test_string::bigint;
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
||||
alter table migtest_e_history2 alter column test_string set not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add column new_column varchar(20);
|
||||
alter table migtest_e_history2_history add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown';
|
||||
alter table migtest_e_history2_history add column new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number type bigint using test_number::bigint;
|
||||
alter table migtest_e_history4_history alter column test_number type bigint using test_number::bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
alter table migtest_e_history5_history add column test_boolean boolean default false;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 drop not null;
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
create index if not exists ix_migtest_oto_child_name on migtest_oto_child (name);
|
||||
drop index if exists ix_migtest_e_basic_indextest1;
|
||||
drop index if exists ix_migtest_e_basic_indextest5;
|
||||
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;
|
||||
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;
|
||||
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
||||
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
||||
|
||||
alter table migtest_e_history add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
|
||||
create table migtest_e_history_history(like migtest_e_history);
|
||||
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
|
||||
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
|
||||
|
||||
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
|
||||
|
||||
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
|
||||
|
||||
create or replace function migtest_e_history_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
create trigger migtest_e_history_history_upd
|
||||
before update or delete on migtest_e_history
|
||||
for each row execute procedure migtest_e_history_history_version();
|
||||
|
||||
-- changes: [add test_string2, add test_string3, add new_column]
|
||||
create or replace function migtest_e_history2_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column, obsolete_string1, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column, OLD.obsolete_string1, OLD.obsolete_string2);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column, obsolete_string1, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column, OLD.obsolete_string1, OLD.obsolete_string2);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- changes: [exclude test_string]
|
||||
create or replace function migtest_e_history3_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- changes: [alter test_number]
|
||||
create or replace function migtest_e_history4_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- changes: [add test_boolean]
|
||||
create or replace function migtest_e_history5_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
|
||||
-- apply changes
|
||||
alter table migtest_e_basic drop column old_boolean;
|
||||
|
||||
alter table migtest_e_basic drop column old_boolean2;
|
||||
|
||||
alter table migtest_e_basic drop column eref_id;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string1;
|
||||
alter table migtest_e_history2_history drop column obsolete_string1;
|
||||
|
||||
alter table migtest_e_history2 drop column obsolete_string2;
|
||||
alter table migtest_e_history2_history drop column obsolete_string2;
|
||||
|
||||
drop table if exists migtest_e_ref cascade;
|
||||
drop sequence if exists migtest_e_ref_seq;
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
-- changes: [drop obsolete_string1, drop obsolete_string2]
|
||||
create or replace function migtest_e_history2_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
drop view if exists migtest_e_history3_with_history;
|
||||
drop view if exists migtest_e_history4_with_history;
|
||||
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id serial not null,
|
||||
name varchar(127) not null,
|
||||
constraint uq_migtest_e_ref_name unique (name),
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
|
||||
alter table if exists migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
|
||||
alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
|
||||
alter table if exists migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
|
||||
alter table if exists migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id;
|
||||
alter table if exists migtest_fk_set_null drop constraint if exists fk_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;
|
||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic alter column status drop default;
|
||||
alter table migtest_e_basic alter column status drop not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic alter column status2 type varchar(1) using status2::varchar(1);
|
||||
alter table migtest_e_basic alter column status2 set default 'N';
|
||||
alter table migtest_e_basic alter column status2 set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table if exists migtest_e_basic drop constraint if exists fk_migtest_e_basic_user_id;
|
||||
alter table migtest_e_basic alter column user_id set default 23;
|
||||
alter table migtest_e_basic alter column user_id set not null;
|
||||
alter table migtest_e_basic add column old_boolean boolean default false not null;
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2);
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
|
||||
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
|
||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 alter column test_string drop default;
|
||||
alter table migtest_e_history2 alter column test_string drop not null;
|
||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2_history add column obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number type integer using test_number::integer;
|
||||
alter table migtest_e_history4_history alter column test_number type integer using test_number::integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 drop not null;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||
create index if not exists ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index if not exists ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index if not exists ix_m12_otoc71 on migtest_oto_child (name);
|
||||
create unique index if not exists uq_m12_otoc71 on migtest_oto_child (lower(name));
|
||||
create unique index if not exists ix_migtest_oto_master_lowername on migtest_oto_master (lower(name));
|
||||
drop index if exists ix_migtest_e_basic_indextest3;
|
||||
drop index if exists ix_migtest_e_basic_indextest6;
|
||||
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;
|
||||
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
|
||||
|
||||
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
|
||||
|
||||
-- changes: [add obsolete_string1, add obsolete_string2]
|
||||
create or replace function migtest_e_history2_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2, test_string2, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2, OLD.test_string2, OLD.test_string3, OLD.new_column);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2, test_string2, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2, OLD.test_string2, OLD.test_string3, OLD.new_column);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- changes: [include test_string]
|
||||
create or replace function migtest_e_history3_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history3_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history3_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- changes: [alter test_number]
|
||||
create or replace function migtest_e_history4_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- drop dependencies
|
||||
drop trigger if exists migtest_e_history_history_upd on migtest_e_history cascade;
|
||||
drop function if exists migtest_e_history_history_version();
|
||||
|
||||
drop view migtest_e_history_with_history;
|
||||
alter table migtest_e_history drop column sys_period;
|
||||
drop table migtest_e_history_history;
|
||||
|
||||
drop view if exists migtest_e_history2_with_history;
|
||||
drop view if exists migtest_e_history5_with_history;
|
||||
|
||||
-- apply changes
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
|
||||
alter table migtest_e_basic drop column new_boolean_field2;
|
||||
|
||||
alter table migtest_e_basic drop column progress;
|
||||
|
||||
alter table migtest_e_basic drop column new_integer;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string2;
|
||||
alter table migtest_e_history2_history drop column test_string2;
|
||||
|
||||
alter table migtest_e_history2 drop column test_string3;
|
||||
alter table migtest_e_history2_history drop column test_string3;
|
||||
|
||||
alter table migtest_e_history2 drop column new_column;
|
||||
alter table migtest_e_history2_history drop column new_column;
|
||||
|
||||
alter table migtest_e_history5 drop column test_boolean;
|
||||
alter table migtest_e_history5_history drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
alter table migtest_oto_child drop column master_id;
|
||||
|
||||
drop table if exists migtest_e_user cascade;
|
||||
drop sequence if exists migtest_e_user_seq;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m cascade;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c cascade;
|
||||
drop table if exists migtest_mtm_m_phone_numbers cascade;
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
|
||||
|
||||
-- changes: [drop test_string2, drop test_string3, drop new_column]
|
||||
create or replace function migtest_e_history2_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- changes: [drop test_boolean]
|
||||
create or replace function migtest_e_history5_history_version() returns trigger as $$
|
||||
declare
|
||||
lowerTs timestamptz;
|
||||
upperTs timestamptz;
|
||||
begin
|
||||
lowerTs = lower(OLD.sys_period);
|
||||
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
|
||||
if (TG_OP = 'UPDATE') then
|
||||
insert into migtest_e_history5_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
NEW.sys_period = tstzrange(upperTs,null);
|
||||
return new;
|
||||
elsif (TG_OP = 'DELETE') then
|
||||
insert into migtest_e_history5_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
|
||||
return old;
|
||||
end if;
|
||||
end;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
-- h2 and postgres script
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
-- postgres specific indexes
|
||||
create index ix_ebasic_jmjb_gin2 on ebasic_json_map_json_b using gin(content jsonb_path_ops);
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
1428934272, 1.0__initial.sql
|
||||
1253246780, 1.1.sql
|
||||
-1861367028, 1.2__dropsFor_1.1.sql
|
||||
326342179, 1.3.sql
|
||||
-1991941691, 1.4__dropsFor_1.3.sql
|
||||
783227075, R__multi_comments.sql
|
||||
561281075, R__order_views.sql
|
||||
283077354, R__pg_indexes.sql
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer identity(1,1) not null,
|
||||
assoc_one varchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer identity(1,1) not null,
|
||||
something varchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key varchar(127) not null,
|
||||
name varchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_one (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_basic (
|
||||
id integer identity(1,1) not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
some_date datetime2,
|
||||
old_boolean bit default 0 not null,
|
||||
old_boolean2 bit,
|
||||
eref_id integer,
|
||||
indextest1 varchar(127),
|
||||
indextest2 varchar(127),
|
||||
indextest3 varchar(127),
|
||||
indextest4 varchar(127),
|
||||
indextest5 varchar(127),
|
||||
indextest6 varchar(127),
|
||||
user_id integer not null,
|
||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) where indextest2 is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) where indextest6 is not null;
|
||||
|
||||
create table migtest_e_enum (
|
||||
id integer identity(1,1) not null,
|
||||
test_status varchar(1),
|
||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
||||
constraint pk_migtest_e_enum primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history (
|
||||
id integer identity(1,1) not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id integer identity(1,1) not null,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id integer identity(1,1) not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer identity(1,1) not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer identity(1,1) not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer identity(1,1) not null,
|
||||
test_number1 integer,
|
||||
test_number2 integer not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer identity(1,1) not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer identity(1,1) not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer identity(1,1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer identity(1,1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_oto_master (
|
||||
id numeric(19) identity(1,1) not null,
|
||||
name varchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
|
||||
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_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);
|
||||
|
||||
alter table migtest_e_history2
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
period for system_time (sys_periodFrom, sys_periodTo);
|
||||
alter table migtest_e_history2 set (system_versioning = on (history_table=dbo.migtest_e_history2_history));
|
||||
alter table migtest_e_history3
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
period for system_time (sys_periodFrom, sys_periodTo);
|
||||
alter table migtest_e_history3 set (system_versioning = on (history_table=dbo.migtest_e_history3_history));
|
||||
alter table migtest_e_history4
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
period for system_time (sys_periodFrom, sys_periodTo);
|
||||
alter table migtest_e_history4 set (system_versioning = on (history_table=dbo.migtest_e_history4_history));
|
||||
alter table migtest_e_history5
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
period for system_time (sys_periodFrom, sys_periodTo);
|
||||
alter table migtest_e_history5 set (system_versioning = on (history_table=dbo.migtest_e_history5_history));
|
||||
alter table migtest_e_history6
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
period for system_time (sys_periodFrom, sys_periodTo);
|
||||
alter table migtest_e_history6 set (system_versioning = on (history_table=dbo.migtest_e_history6_history));
|
||||
@@ -0,0 +1,125 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer identity(1,1) not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id numeric(19) not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id numeric(19) not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_phone_numbers (
|
||||
migtest_mtm_m_id numeric(19) not null,
|
||||
value varchar(255) not null
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add one_key integer;
|
||||
alter table migtest_ckey_detail add two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
|
||||
alter table migtest_ckey_parent add assoc_id integer;
|
||||
|
||||
IF OBJECT_ID('fk_migtest_fk_cascade_one_id', 'F') IS NOT NULL alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
|
||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id);
|
||||
IF OBJECT_ID('fk_migtest_fk_set_null_one_id', 'F') IS NOT NULL alter table migtest_fk_set_null drop constraint fk_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);
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_status', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
alter table migtest_e_basic add default 'A' for status;
|
||||
alter table migtest_e_basic alter column status varchar(1) not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_status2', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
EXEC usp_ebean_drop_default_constraint migtest_e_basic, status2;
|
||||
alter table migtest_e_basic alter column status2 varchar(127);
|
||||
|
||||
-- rename all collisions;
|
||||
create unique nonclustered index uq_migtest_e_basic_description on migtest_e_basic(description) where description is not null;
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id);
|
||||
alter table migtest_e_basic alter column user_id integer;
|
||||
alter table migtest_e_basic add new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add new_boolean_field bit default 1 not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add new_boolean_field2 bit default 1 not null;
|
||||
alter table migtest_e_basic add progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add new_integer integer default 42 not null;
|
||||
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest2') drop index uq_migtest_e_basic_indextest2 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_indextest2', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest6') drop index uq_migtest_e_basic_indextest6 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_indextest6', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
||||
create unique nonclustered index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) where indextest1 is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_name on migtest_e_basic(name) where name is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) where indextest4 is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) where indextest5 is not null;
|
||||
IF (OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL) alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
alter table migtest_e_history alter column test_string numeric(19);
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 add default 'unknown' for test_string;
|
||||
alter table migtest_e_history2 alter column test_string varchar(255) not null;
|
||||
alter table migtest_e_history2 add test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number numeric(19);
|
||||
alter table migtest_e_history5 add test_boolean bit default 0 not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 add default 42 for test_number1;
|
||||
alter table migtest_e_history6 alter column test_number1 integer not null;
|
||||
alter table migtest_e_history6 alter column test_number2 integer;
|
||||
alter table migtest_e_softdelete add deleted bit default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add master_id numeric(19);
|
||||
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest1') drop index ix_migtest_e_basic_indextest1 ON migtest_e_basic;
|
||||
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;
|
||||
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);
|
||||
|
||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
|
||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
|
||||
|
||||
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
|
||||
|
||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id);
|
||||
|
||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
|
||||
|
||||
alter table migtest_e_history
|
||||
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
|
||||
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
|
||||
period for system_time (sys_periodFrom, sys_periodTo);
|
||||
alter table migtest_e_history set (system_versioning = on (history_table=dbo.migtest_e_history_history));
|
||||
-- alter table migtest_e_history3 set (system_versioning = off (history_table=dbo.migtest_e_history3_history));
|
||||
-- history migration goes here
|
||||
-- alter table migtest_e_history3 set (system_versioning = on (history_table=dbo.migtest_e_history3_history));
|
||||
@@ -0,0 +1,72 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer identity(1,1) not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
|
||||
IF OBJECT_ID('fk_migtest_ckey_detail_parent', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
|
||||
IF OBJECT_ID('fk_migtest_fk_cascade_one_id', 'F') IS NOT NULL alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
IF OBJECT_ID('fk_migtest_fk_none_one_id', 'F') IS NOT NULL alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
|
||||
IF OBJECT_ID('fk_migtest_fk_none_via_join_one_id', 'F') IS NOT NULL alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id;
|
||||
IF OBJECT_ID('fk_migtest_fk_set_null_one_id', 'F') IS NOT NULL alter table migtest_fk_set_null drop constraint fk_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;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_status', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_status;
|
||||
EXEC usp_ebean_drop_default_constraint migtest_e_basic, status;
|
||||
alter table migtest_e_basic alter column status varchar(1);
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_status2', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2;
|
||||
alter table migtest_e_basic add default 'N' for status2;
|
||||
alter table migtest_e_basic alter column status2 varchar(1) not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_description') drop index uq_migtest_e_basic_description ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_description', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_user_id', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id;
|
||||
alter table migtest_e_basic add default 23 for user_id;
|
||||
alter table migtest_e_basic alter column user_id integer not null;
|
||||
alter table migtest_e_basic add old_boolean bit default 0 not null;
|
||||
alter table migtest_e_basic add old_boolean2 bit;
|
||||
alter table migtest_e_basic add eref_id integer;
|
||||
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_status_indextest1') drop index uq_migtest_e_basic_status_indextest1 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_status_indextest1', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_name') drop index uq_migtest_e_basic_name ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_name', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest4') drop index uq_migtest_e_basic_indextest4 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_indextest4', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest5') drop index uq_migtest_e_basic_indextest5 ON migtest_e_basic;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_indextest5', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) where indextest2 is not null;
|
||||
create unique nonclustered index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) where indextest6 is not null;
|
||||
IF (OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL) alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
|
||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
||||
EXEC usp_ebean_drop_default_constraint migtest_e_history2, test_string;
|
||||
alter table migtest_e_history2 alter column test_string varchar(255);
|
||||
alter table migtest_e_history2 add obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number integer;
|
||||
EXEC usp_ebean_drop_default_constraint migtest_e_history6, test_number1;
|
||||
alter table migtest_e_history6 alter column test_number1 integer;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 add default 7 for test_number2;
|
||||
alter table migtest_e_history6 alter column test_number2 integer not null;
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest3') drop index ix_migtest_e_basic_indextest3 ON migtest_e_basic;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest6') drop index ix_migtest_e_basic_indextest6 ON migtest_e_basic;
|
||||
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);
|
||||
|
||||
-- alter table migtest_e_history3 set (system_versioning = off (history_table=dbo.migtest_e_history3_history));
|
||||
-- history migration goes here
|
||||
-- alter table migtest_e_history3 set (system_versioning = on (history_table=dbo.migtest_e_history3_history));
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
-2122378240, I__create_procs.sql
|
||||
802205012, 1.0__initial.sql
|
||||
-1042228916, 1.1.sql
|
||||
-1805601919, 1.2__dropsFor_1.1.sql
|
||||
-807119885, 1.3.sql
|
||||
-1335541264, 1.4__dropsFor_1.3.sql
|
||||
1607822082, R__order_views_mssql.sql
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, old_boolean;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, old_boolean2;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, eref_id;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_history2, obsolete_string1;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_history2, obsolete_string2;
|
||||
|
||||
IF OBJECT_ID('migtest_e_ref', 'U') IS NOT NULL drop table migtest_e_ref;
|
||||
IF OBJECT_ID('migtest_e_ref_seq', 'SO') IS NOT NULL drop sequence migtest_e_ref_seq;
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
EXEC usp_ebean_drop_column migtest_ckey_detail, one_key;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_ckey_detail, two_key;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_ckey_parent, assoc_id;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, new_string_field;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, new_boolean_field;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, new_boolean_field2;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, progress;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_basic, new_integer;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_history2, test_string2;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_history2, test_string3;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_history2, new_column;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_history5, test_boolean;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_e_softdelete, deleted;
|
||||
|
||||
EXEC usp_ebean_drop_column migtest_oto_child, master_id;
|
||||
|
||||
IF OBJECT_ID('migtest_e_user', 'U') IS NOT NULL drop table migtest_e_user;
|
||||
IF OBJECT_ID('migtest_e_user_seq', 'SO') IS NOT NULL drop sequence migtest_e_user_seq;
|
||||
IF OBJECT_ID('migtest_mtm_c_migtest_mtm_m', 'U') IS NOT NULL drop table migtest_mtm_c_migtest_mtm_m;
|
||||
IF OBJECT_ID('migtest_mtm_m_migtest_mtm_c', 'U') IS NOT NULL drop table migtest_mtm_m_migtest_mtm_c;
|
||||
IF OBJECT_ID('migtest_mtm_m_phone_numbers', 'U') IS NOT NULL drop table migtest_mtm_m_phone_numbers;
|
||||
-- dropping history support for migtest_e_history;
|
||||
EXEC usp_ebean_drop_default_constraint migtest_e_history, sys_periodFrom;
|
||||
EXEC usp_ebean_drop_default_constraint migtest_e_history, sys_periodTo;
|
||||
alter table migtest_e_history set (system_versioning = off);
|
||||
alter table migtest_e_history drop period for system_time;
|
||||
alter table migtest_e_history drop column sys_periodFrom;
|
||||
alter table migtest_e_history drop column sys_periodTo;
|
||||
IF OBJECT_ID('migtest_e_history_history', 'U') IS NOT NULL drop table migtest_e_history_history;
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
-- Initial script to create stored procedures etc for sqlserver platform
|
||||
|
||||
-- create table-value-parameters
|
||||
if not exists (select name from sys.types where name = 'ebean_bigint_tvp') create type ebean_bigint_tvp as table (c1 bigint)
|
||||
GO
|
||||
if not exists (select name from sys.types where name = 'ebean_float_tvp') create type ebean_float_tvp as table (c1 float)
|
||||
GO
|
||||
if not exists (select name from sys.types where name = 'ebean_bit_tvp') create type ebean_bit_tvp as table (c1 bit)
|
||||
GO
|
||||
if not exists (select name from sys.types where name = 'ebean_date_tvp') create type ebean_date_tvp as table (c1 date)
|
||||
GO
|
||||
if not exists (select name from sys.types where name = 'ebean_time_tvp') create type ebean_time_tvp as table (c1 time)
|
||||
GO
|
||||
if not exists (select name from sys.types where name = 'ebean_uniqueidentifier_tvp') create type ebean_uniqueidentifier_tvp as table (c1 uniqueidentifier)
|
||||
GO
|
||||
if not exists (select name from sys.types where name = 'ebean_nvarchar_tvp') create type ebean_nvarchar_tvp as table (c1 nvarchar(max))
|
||||
GO
|
||||
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_indices TABLE, COLUMN
|
||||
-- deletes all indices referring to TABLE.COLUMN
|
||||
--
|
||||
CREATE OR ALTER PROCEDURE usp_ebean_drop_indices @tableName nvarchar(255), @columnName nvarchar(255)
|
||||
AS SET NOCOUNT ON
|
||||
declare @sql nvarchar(1000)
|
||||
declare @indexName nvarchar(255)
|
||||
BEGIN
|
||||
DECLARE index_cursor CURSOR FOR SELECT i.name from sys.indexes i
|
||||
join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id
|
||||
join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id
|
||||
where i.object_id = OBJECT_ID(@tableName) AND c.name = @columnName;
|
||||
OPEN index_cursor
|
||||
FETCH NEXT FROM index_cursor INTO @indexName
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
set @sql = 'drop index ' + @indexName + ' on ' + @tableName;
|
||||
EXECUTE(@sql);
|
||||
|
||||
FETCH NEXT FROM index_cursor INTO @indexName
|
||||
END;
|
||||
CLOSE index_cursor;
|
||||
DEALLOCATE index_cursor;
|
||||
END
|
||||
GO
|
||||
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_default_constraint TABLE, COLUMN
|
||||
-- deletes the default constraint, which has a random name
|
||||
--
|
||||
CREATE OR ALTER PROCEDURE usp_ebean_drop_default_constraint @tableName nvarchar(255), @columnName nvarchar(255)
|
||||
AS SET NOCOUNT ON
|
||||
declare @tmp nvarchar(1000)
|
||||
BEGIN
|
||||
select @tmp = t1.name from sys.default_constraints t1
|
||||
join sys.columns t2 on t1.object_id = t2.default_object_id
|
||||
where t1.parent_object_id = OBJECT_ID(@tableName) and t2.name = @columnName;
|
||||
|
||||
if @tmp is not null EXEC('alter table ' + @tableName +' drop constraint ' + @tmp);
|
||||
END
|
||||
GO
|
||||
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_constraints TABLE, COLUMN
|
||||
-- deletes constraints and foreign keys refering to TABLE.COLUMN
|
||||
--
|
||||
CREATE OR ALTER PROCEDURE usp_ebean_drop_constraints @tableName nvarchar(255), @columnName nvarchar(255)
|
||||
AS SET NOCOUNT ON
|
||||
declare @sql nvarchar(1000)
|
||||
declare @constraintName nvarchar(255)
|
||||
BEGIN
|
||||
DECLARE name_cursor CURSOR FOR
|
||||
SELECT cc.name from sys.check_constraints cc
|
||||
join sys.columns c on c.object_id = cc.parent_object_id and c.column_id = cc.parent_column_id
|
||||
where parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName
|
||||
UNION SELECT fk.name from sys.foreign_keys fk
|
||||
join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id
|
||||
and fkc.parent_object_id = fk.parent_object_id
|
||||
join sys.columns c on c.object_id = fkc.parent_object_id and c.column_id = fkc.parent_column_id
|
||||
where fkc.parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName;
|
||||
|
||||
OPEN name_cursor
|
||||
FETCH NEXT FROM name_cursor INTO @constraintName
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
set @sql = 'alter table ' + @tableName + ' drop constraint ' + @constraintName;
|
||||
EXECUTE(@sql);
|
||||
|
||||
FETCH NEXT FROM name_cursor INTO @constraintName
|
||||
END;
|
||||
CLOSE name_cursor;
|
||||
DEALLOCATE name_cursor;
|
||||
END
|
||||
GO
|
||||
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
|
||||
-- deletes the column annd ensures that all indices and constraints are dropped first
|
||||
--
|
||||
CREATE OR ALTER PROCEDURE usp_ebean_drop_column @tableName nvarchar(255), @columnName nvarchar(255)
|
||||
AS SET NOCOUNT ON
|
||||
declare @sql nvarchar(1000)
|
||||
BEGIN
|
||||
EXEC usp_ebean_drop_indices @tableName, @columnName;
|
||||
EXEC usp_ebean_drop_default_constraint @tableName, @columnName;
|
||||
EXEC usp_ebean_drop_constraints @tableName, @columnName;
|
||||
|
||||
set @sql = 'alter table ' + @tableName + ' drop column ' + @columnName;
|
||||
EXECUTE(@sql);
|
||||
END
|
||||
GO
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'order_agg_vw')
|
||||
DROP VIEW order_agg_vw;
|
||||
|
||||
create view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
from o_order_detail d
|
||||
group by d.order_id;
|
||||
|
||||
Reference in New Issue
Block a user