mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1340 - (test only change) Split SQL Server Platform into SqlServer16 and SqlServer17 (where 2017 which uses UTF8 types nvarchar etc and prefers Sequences).
Update DbMigrationGenerateTest ... for SqlServer17 platform
This commit is contained in:
@@ -4,9 +4,6 @@ import io.ebean.EbeanServer;
|
||||
import io.ebean.EbeanServerFactory;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -54,11 +51,7 @@ public class DbMigrationGenerateTest {
|
||||
migration.addPlatform(Platform.POSTGRES, "postgres");
|
||||
migration.addPlatform(Platform.ORACLE, "oracle");
|
||||
migration.addPlatform(Platform.SQLITE, "sqlite");
|
||||
|
||||
// we need sequence here, so that migration will work properly
|
||||
DatabasePlatform sqlServer = new SqlServer17Platform();
|
||||
sqlServer.getDbIdentity().setIdType(IdType.SEQUENCE);
|
||||
migration.addDatabasePlatform(sqlServer, "sqlserver");
|
||||
migration.addPlatform(Platform.SQLSERVER17, "sqlserver17");
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setName("migrationtest");
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_ckey_assoc (
|
||||
id integer not null,
|
||||
assoc_one nvarchar(255),
|
||||
constraint pk_migtest_ckey_assoc primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_assoc_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_ckey_detail (
|
||||
id integer not null,
|
||||
something nvarchar(255),
|
||||
constraint pk_migtest_ckey_detail primary key (id)
|
||||
);
|
||||
create sequence migtest_ckey_detail_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_ckey_parent (
|
||||
one_key integer not null,
|
||||
two_key nvarchar(127) not null,
|
||||
name nvarchar(255),
|
||||
version integer not null,
|
||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
||||
);
|
||||
|
||||
create table migtest_fk_cascade (
|
||||
id numeric(19) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_cascade primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_cascade_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_fk_cascade_one (
|
||||
id numeric(19) not null,
|
||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_cascade_one_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_fk_none (
|
||||
id numeric(19) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_none primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_none_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_fk_none_via_join (
|
||||
id numeric(19) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_none_via_join_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_fk_one (
|
||||
id numeric(19) not null,
|
||||
constraint pk_migtest_fk_one primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_one_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_fk_set_null (
|
||||
id numeric(19) not null,
|
||||
one_id numeric(19),
|
||||
constraint pk_migtest_fk_set_null primary key (id)
|
||||
);
|
||||
create sequence migtest_fk_set_null_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_basic (
|
||||
id integer not null,
|
||||
status nvarchar(1),
|
||||
name nvarchar(127),
|
||||
description nvarchar(127),
|
||||
some_date datetime2,
|
||||
old_boolean bit default 0 not null,
|
||||
old_boolean2 bit,
|
||||
eref_id integer,
|
||||
indextest1 nvarchar(127),
|
||||
indextest2 nvarchar(127),
|
||||
indextest3 nvarchar(127),
|
||||
indextest4 nvarchar(127),
|
||||
indextest5 nvarchar(127),
|
||||
indextest6 nvarchar(127),
|
||||
user_id integer not null,
|
||||
constraint ck_migtest_e_basic_status check ( status 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 sequence migtest_e_basic_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_history (
|
||||
id integer not null,
|
||||
test_string nvarchar(255),
|
||||
constraint pk_migtest_e_history primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_history2 (
|
||||
id integer not null,
|
||||
test_string nvarchar(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history2_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_ref (
|
||||
id integer not null,
|
||||
name nvarchar(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 sequence migtest_e_ref_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_e_softdelete (
|
||||
id integer not null,
|
||||
test_string nvarchar(255),
|
||||
constraint pk_migtest_e_softdelete primary key (id)
|
||||
);
|
||||
create sequence migtest_e_softdelete_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_mtm_c (
|
||||
id integer not null,
|
||||
name nvarchar(255),
|
||||
constraint pk_migtest_mtm_c primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_c_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_mtm_m (
|
||||
id numeric(19) not null,
|
||||
name nvarchar(255),
|
||||
constraint pk_migtest_mtm_m primary key (id)
|
||||
);
|
||||
create sequence migtest_mtm_m_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_oto_child (
|
||||
id integer not null,
|
||||
name nvarchar(255),
|
||||
constraint pk_migtest_oto_child primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_child_seq as bigint start with 1 ;
|
||||
|
||||
create table migtest_oto_master (
|
||||
id numeric(19) not null,
|
||||
name nvarchar(255),
|
||||
constraint pk_migtest_oto_master primary key (id)
|
||||
);
|
||||
create sequence migtest_oto_master_seq as bigint start with 1 ;
|
||||
|
||||
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 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 on update 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));
|
||||
@@ -1,104 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
create sequence migtest_e_user_seq as bigint start with 1 ;
|
||||
|
||||
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)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add one_key integer;
|
||||
alter table migtest_ckey_detail add two_key nvarchar(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 nvarchar(1) not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
|
||||
-- rename all collisions;
|
||||
create unique nonclustered index uq_migtest_e_basic_description on migtest_e_basic(description) where description is not null;
|
||||
|
||||
update migtest_e_basic set some_date = '2000-01-01T00:00:00' where some_date is null;
|
||||
alter table migtest_e_basic add default '2000-01-01T00:00:00' for some_date;
|
||||
alter table migtest_e_basic alter column some_date datetime2 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 nvarchar(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 (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_indextest2') drop index uq_migtest_e_basic_indextest2 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;
|
||||
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;
|
||||
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;
|
||||
alter table migtest_e_history alter column test_string numeric(19);
|
||||
|
||||
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 nvarchar(255) not null;
|
||||
alter table migtest_e_history2 add test_string2 nvarchar(255);
|
||||
alter table migtest_e_history2 add test_string3 nvarchar(255) default 'unknown' not null;
|
||||
|
||||
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_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));
|
||||
@@ -1,43 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
-- drop column migtest_e_basic.old_boolean;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_old_boolean', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_old_boolean;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_old_boolean') drop index uq_migtest_e_basic_old_boolean ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'old_boolean';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_old_boolean', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_old_boolean;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_old_boolean') drop index ix_migtest_e_basic_old_boolean ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_old_boolean', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_old_boolean;
|
||||
alter table migtest_e_basic drop column old_boolean;
|
||||
|
||||
-- drop column migtest_e_basic.old_boolean2;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_old_boolean2', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_old_boolean2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_old_boolean2') drop index uq_migtest_e_basic_old_boolean2 ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'old_boolean2';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_old_boolean2', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_old_boolean2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_old_boolean2') drop index ix_migtest_e_basic_old_boolean2 ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_old_boolean2', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_old_boolean2;
|
||||
alter table migtest_e_basic drop column old_boolean2;
|
||||
|
||||
-- drop column migtest_e_basic.eref_id;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_eref_id', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_eref_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_eref_id') drop index uq_migtest_e_basic_eref_id ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'eref_id';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_eref_id', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_eref_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_eref_id') drop index ix_migtest_e_basic_eref_id ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_eref_id', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_eref_id;
|
||||
alter table migtest_e_basic drop column eref_id;
|
||||
|
||||
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;
|
||||
@@ -1,62 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer not null,
|
||||
name nvarchar(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 sequence migtest_e_ref_seq as bigint start with 1 ;
|
||||
|
||||
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 on update 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 on update 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;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'status';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_description', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
||||
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;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'some_date';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
|
||||
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 (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_status_indextest1') drop index uq_migtest_e_basic_status_indextest1 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_name') drop index uq_migtest_e_basic_name 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_indextest4') drop index uq_migtest_e_basic_indextest4 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;
|
||||
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;
|
||||
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;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_history2') and t2.name = 'test_string';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_history2 drop constraint ' + @Tmp)$$;
|
||||
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);
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
-- drop column migtest_ckey_detail.one_key;
|
||||
IF (OBJECT_ID('uq_migtest_ckey_detail_one_key', 'UQ') IS NOT NULL) alter table migtest_ckey_detail drop constraint uq_migtest_ckey_detail_one_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'uq_migtest_ckey_detail_one_key') drop index uq_migtest_ckey_detail_one_key ON migtest_ckey_detail;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_ckey_detail') and t2.name = 'one_key';
|
||||
if @Tmp is not null EXEC('alter table migtest_ckey_detail drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_ckey_detail_one_key', 'C') IS NOT NULL) alter table migtest_ckey_detail drop constraint ck_migtest_ckey_detail_one_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'ix_migtest_ckey_detail_one_key') drop index ix_migtest_ckey_detail_one_key ON migtest_ckey_detail;
|
||||
IF OBJECT_ID('fk_migtest_ckey_detail_one_key', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_one_key;
|
||||
alter table migtest_ckey_detail drop column one_key;
|
||||
|
||||
-- drop column migtest_ckey_detail.two_key;
|
||||
IF (OBJECT_ID('uq_migtest_ckey_detail_two_key', 'UQ') IS NOT NULL) alter table migtest_ckey_detail drop constraint uq_migtest_ckey_detail_two_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'uq_migtest_ckey_detail_two_key') drop index uq_migtest_ckey_detail_two_key ON migtest_ckey_detail;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_ckey_detail') and t2.name = 'two_key';
|
||||
if @Tmp is not null EXEC('alter table migtest_ckey_detail drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_ckey_detail_two_key', 'C') IS NOT NULL) alter table migtest_ckey_detail drop constraint ck_migtest_ckey_detail_two_key;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_detail','U') AND name = 'ix_migtest_ckey_detail_two_key') drop index ix_migtest_ckey_detail_two_key ON migtest_ckey_detail;
|
||||
IF OBJECT_ID('fk_migtest_ckey_detail_two_key', 'F') IS NOT NULL alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_two_key;
|
||||
alter table migtest_ckey_detail drop column two_key;
|
||||
|
||||
-- drop column migtest_ckey_parent.assoc_id;
|
||||
IF (OBJECT_ID('uq_migtest_ckey_parent_assoc_id', 'UQ') IS NOT NULL) alter table migtest_ckey_parent drop constraint uq_migtest_ckey_parent_assoc_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_parent','U') AND name = 'uq_migtest_ckey_parent_assoc_id') drop index uq_migtest_ckey_parent_assoc_id ON migtest_ckey_parent;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_ckey_parent') and t2.name = 'assoc_id';
|
||||
if @Tmp is not null EXEC('alter table migtest_ckey_parent drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_ckey_parent_assoc_id', 'C') IS NOT NULL) alter table migtest_ckey_parent drop constraint ck_migtest_ckey_parent_assoc_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_ckey_parent','U') AND name = 'ix_migtest_ckey_parent_assoc_id') drop index ix_migtest_ckey_parent_assoc_id ON migtest_ckey_parent;
|
||||
IF OBJECT_ID('fk_migtest_ckey_parent_assoc_id', 'F') IS NOT NULL alter table migtest_ckey_parent drop constraint fk_migtest_ckey_parent_assoc_id;
|
||||
alter table migtest_ckey_parent drop column assoc_id;
|
||||
|
||||
-- drop column migtest_e_basic.new_string_field;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_new_string_field', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_new_string_field;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_new_string_field') drop index uq_migtest_e_basic_new_string_field ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'new_string_field';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_new_string_field', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_new_string_field;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_new_string_field') drop index ix_migtest_e_basic_new_string_field ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_new_string_field', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_new_string_field;
|
||||
alter table migtest_e_basic drop column new_string_field;
|
||||
|
||||
-- drop column migtest_e_basic.new_boolean_field;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_new_boolean_field', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_new_boolean_field;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_new_boolean_field') drop index uq_migtest_e_basic_new_boolean_field ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'new_boolean_field';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_new_boolean_field', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_new_boolean_field;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_new_boolean_field') drop index ix_migtest_e_basic_new_boolean_field ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_new_boolean_field', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_new_boolean_field;
|
||||
alter table migtest_e_basic drop column new_boolean_field;
|
||||
|
||||
-- drop column migtest_e_basic.new_boolean_field2;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_new_boolean_field2', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_new_boolean_field2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_new_boolean_field2') drop index uq_migtest_e_basic_new_boolean_field2 ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'new_boolean_field2';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_new_boolean_field2', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_new_boolean_field2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_new_boolean_field2') drop index ix_migtest_e_basic_new_boolean_field2 ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_new_boolean_field2', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_new_boolean_field2;
|
||||
alter table migtest_e_basic drop column new_boolean_field2;
|
||||
|
||||
-- drop column migtest_e_basic.progress;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_progress', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_progress;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_progress') drop index uq_migtest_e_basic_progress ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'progress';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_progress', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_progress;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_progress') drop index ix_migtest_e_basic_progress ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_progress', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_progress;
|
||||
alter table migtest_e_basic drop column progress;
|
||||
|
||||
-- drop column migtest_e_basic.new_integer;
|
||||
IF (OBJECT_ID('uq_migtest_e_basic_new_integer', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_new_integer;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_new_integer') drop index uq_migtest_e_basic_new_integer ON migtest_e_basic;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_basic') and t2.name = 'new_integer';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_basic drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_basic_new_integer', 'C') IS NOT NULL) alter table migtest_e_basic drop constraint ck_migtest_e_basic_new_integer;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_new_integer') drop index ix_migtest_e_basic_new_integer ON migtest_e_basic;
|
||||
IF OBJECT_ID('fk_migtest_e_basic_new_integer', 'F') IS NOT NULL alter table migtest_e_basic drop constraint fk_migtest_e_basic_new_integer;
|
||||
alter table migtest_e_basic drop column new_integer;
|
||||
|
||||
-- drop column migtest_e_history2.test_string2;
|
||||
IF (OBJECT_ID('uq_migtest_e_history2_test_string2', 'UQ') IS NOT NULL) alter table migtest_e_history2 drop constraint uq_migtest_e_history2_test_string2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_history2','U') AND name = 'uq_migtest_e_history2_test_string2') drop index uq_migtest_e_history2_test_string2 ON migtest_e_history2;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_history2') and t2.name = 'test_string2';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_history2 drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_history2_test_string2', 'C') IS NOT NULL) alter table migtest_e_history2 drop constraint ck_migtest_e_history2_test_string2;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_history2','U') AND name = 'ix_migtest_e_history2_test_string2') drop index ix_migtest_e_history2_test_string2 ON migtest_e_history2;
|
||||
IF OBJECT_ID('fk_migtest_e_history2_test_string2', 'F') IS NOT NULL alter table migtest_e_history2 drop constraint fk_migtest_e_history2_test_string2;
|
||||
alter table migtest_e_history2 drop column test_string2;
|
||||
|
||||
-- drop column migtest_e_history2.test_string3;
|
||||
IF (OBJECT_ID('uq_migtest_e_history2_test_string3', 'UQ') IS NOT NULL) alter table migtest_e_history2 drop constraint uq_migtest_e_history2_test_string3;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_history2','U') AND name = 'uq_migtest_e_history2_test_string3') drop index uq_migtest_e_history2_test_string3 ON migtest_e_history2;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_history2') and t2.name = 'test_string3';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_history2 drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_history2_test_string3', 'C') IS NOT NULL) alter table migtest_e_history2 drop constraint ck_migtest_e_history2_test_string3;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_history2','U') AND name = 'ix_migtest_e_history2_test_string3') drop index ix_migtest_e_history2_test_string3 ON migtest_e_history2;
|
||||
IF OBJECT_ID('fk_migtest_e_history2_test_string3', 'F') IS NOT NULL alter table migtest_e_history2 drop constraint fk_migtest_e_history2_test_string3;
|
||||
alter table migtest_e_history2 drop column test_string3;
|
||||
|
||||
-- drop column migtest_e_softdelete.deleted;
|
||||
IF (OBJECT_ID('uq_migtest_e_softdelete_deleted', 'UQ') IS NOT NULL) alter table migtest_e_softdelete drop constraint uq_migtest_e_softdelete_deleted;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_softdelete','U') AND name = 'uq_migtest_e_softdelete_deleted') drop index uq_migtest_e_softdelete_deleted ON migtest_e_softdelete;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_softdelete') and t2.name = 'deleted';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_softdelete drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_e_softdelete_deleted', 'C') IS NOT NULL) alter table migtest_e_softdelete drop constraint ck_migtest_e_softdelete_deleted;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_softdelete','U') AND name = 'ix_migtest_e_softdelete_deleted') drop index ix_migtest_e_softdelete_deleted ON migtest_e_softdelete;
|
||||
IF OBJECT_ID('fk_migtest_e_softdelete_deleted', 'F') IS NOT NULL alter table migtest_e_softdelete drop constraint fk_migtest_e_softdelete_deleted;
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
-- drop column migtest_oto_child.master_id;
|
||||
IF (OBJECT_ID('uq_migtest_oto_child_master_id', 'UQ') IS NOT NULL) alter table migtest_oto_child drop constraint uq_migtest_oto_child_master_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_oto_child','U') AND name = 'uq_migtest_oto_child_master_id') drop index uq_migtest_oto_child_master_id ON migtest_oto_child;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_oto_child') and t2.name = 'master_id';
|
||||
if @Tmp is not null EXEC('alter table migtest_oto_child drop constraint ' + @Tmp)$$;
|
||||
IF (OBJECT_ID('ck_migtest_oto_child_master_id', 'C') IS NOT NULL) alter table migtest_oto_child drop constraint ck_migtest_oto_child_master_id;
|
||||
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_oto_child','U') AND name = 'ix_migtest_oto_child_master_id') drop index ix_migtest_oto_child_master_id ON migtest_oto_child;
|
||||
IF OBJECT_ID('fk_migtest_oto_child_master_id', 'F') IS NOT NULL alter table migtest_oto_child drop constraint fk_migtest_oto_child_master_id;
|
||||
alter table migtest_oto_child drop column 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;
|
||||
-- dropping history support for migtest_e_history;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_history') and t2.name = 'sys_periodFrom';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_history drop constraint ' + @Tmp)$$;
|
||||
delimiter $$
|
||||
DECLARE @Tmp nvarchar(200);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('migtest_e_history') and t2.name = 'sys_periodTo';
|
||||
if @Tmp is not null EXEC('alter table migtest_e_history drop constraint ' + @Tmp)$$;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user