This commit is contained in:
Roland Praml committed 2022-04-08 16:19:53 +02:00
commit 72d8a73aa7
387 files changed
+3716 -2671

No files matched your search

+28 -12
View File
@@ -26,6 +26,12 @@
<version>${ebean-datasource.version}</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
@@ -72,6 +78,14 @@
<version>2.3.6</version>
</dependency>
<!-- Needed for module path compile, jaxb foo bar needs review -->
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
<!-- Not strictly required but bring in H2 Driver because we use it so much -->
<dependency>
<groupId>com.h2database</groupId>
@@ -79,12 +93,20 @@
<version>${h2database.version}</version>
</dependency>
<!-- provided for module path compile for tests with @PostConstruct -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305-x</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsr305</artifactId>
<version>1.1</version>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>13.2.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
@@ -131,12 +153,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
@@ -230,11 +246,12 @@
<scope>test</scope>
</dependency>
<!-- provided scope for Java 11 compilation (not required for Java 17+) -->
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.1</version>
<scope>test</scope>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -249,8 +266,7 @@
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.15.0</tile>
<tile>io.avaje.tile:moditech-module:1.0</tile>
<tile>io.ebean.tile:enhancement:13.1.0</tile>
</tiles>
</configuration>
</plugin>
@@ -1,5 +1,5 @@
open module io.ebean.test {
module io.ebean.test {
exports io.ebean.test;
exports io.ebean.test.config;
@@ -13,6 +13,7 @@ open module io.ebean.test {
requires transitive io.ebean.datasource;
requires transitive io.ebean.core;
requires transitive io.ebean.ddl.generator;
requires com.fasterxml.jackson.annotation;
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
@@ -22,4 +23,9 @@ open module io.ebean.test {
requires transitive java.xml.bind;
requires transitive com.h2database;
// support testing
requires static org.junit.jupiter.api;
requires static jdk.management;
requires static io.avaje.jsr305x;
requires io.ebean.api;
}
@@ -1,9 +1,10 @@
package io.ebean.config;
package io.ebean.test.config;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceAlert;
import io.ebean.datasource.DataSourceInitialiseException;
import io.ebean.xtest.ForPlatform;
@@ -4,8 +4,8 @@ import io.ebean.xtest.BaseTestCase;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.config.*;
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
import io.ebean.platform.mysql.MySqlPlatform;
import io.ebean.platform.postgres.PostgresPlatform;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -3,8 +3,8 @@ package io.ebean.xtest.config;
import io.ebean.config.MatchingNamingConvention;
import io.ebean.config.PlatformConfig;
import io.ebean.config.TableName;
import io.ebean.config.dbplatform.h2.H2Platform;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebean.platform.h2.H2Platform;
import io.ebean.platform.sqlserver.SqlServer17Platform;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.Customer;
@@ -7,7 +7,7 @@ import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DbIdentity;
import io.ebean.config.dbplatform.IdType;
import io.ebean.config.dbplatform.h2.H2Platform;
import io.ebean.platform.h2.H2Platform;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.EBasicVer;
@@ -2,13 +2,13 @@ package io.ebean.xtest.config.dbplatform;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.DbPlatformTypeMapping;
import io.ebean.config.dbplatform.clickhouse.ClickHousePlatform;
import io.ebean.config.dbplatform.h2.H2Platform;
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
import io.ebean.config.dbplatform.sqlserver.SqlServer16Platform;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebean.platform.clickhouse.ClickHousePlatform;
import io.ebean.platform.h2.H2Platform;
import io.ebean.platform.mysql.MySqlPlatform;
import io.ebean.platform.oracle.OraclePlatform;
import io.ebean.platform.postgres.PostgresPlatform;
import io.ebean.platform.sqlserver.SqlServer16Platform;
import io.ebean.platform.sqlserver.SqlServer17Platform;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -1,6 +1,6 @@
package io.ebean.xtest.config.dbplatform;
import io.ebean.config.dbplatform.hana.HanaHistorySupport;
import io.ebean.platform.hana.HanaHistorySupport;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -2,7 +2,7 @@ package io.ebean.xtest.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.hana.HanaPlatform;
import io.ebean.platform.hana.HanaPlatform;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -1,7 +1,7 @@
package io.ebean.xtest.config.dbplatform;
import io.ebean.config.dbplatform.mysql.MySqlHistorySupport;
import io.ebean.platform.mysql.MySqlHistorySupport;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -1,6 +1,6 @@
package io.ebean.xtest.config.dbplatform;
import io.ebean.config.dbplatform.postgres.PostgresHistorySupport;
import io.ebean.platform.postgres.PostgresHistorySupport;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -2,7 +2,7 @@ package io.ebean.xtest.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebean.platform.sqlserver.SqlServer17Platform;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -1,7 +1,7 @@
package io.ebean.xtest.config.dbplatform.sqlserver;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebean.config.dbplatform.sqlserver.SqlServerHistorySupport;
import io.ebean.platform.sqlserver.SqlServer17Platform;
import io.ebean.platform.sqlserver.SqlServerHistorySupport;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -4,7 +4,7 @@ import io.ebean.BackgroundExecutor;
import io.ebean.xtest.BaseTestCase;
import io.ebean.xtest.ForPlatform;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.sqlserver.SqlServerStepSequence;
import io.ebean.platform.sqlserver.SqlServerStepSequence;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -4,7 +4,7 @@ import io.ebean.*;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DbHistorySupport;
import io.ebean.datasource.pool.ConnectionPool;
import io.ebean.datasource.DataSourcePool;
import io.ebean.xtest.BaseTestCase;
import io.ebean.xtest.IgnorePlatform;
import misc.migration.v1_0.ETable;
@@ -38,7 +38,7 @@ public class DbMigrationTest extends BaseTestCase {
private void runScript(String scriptName) {
URL url = getClass().getResource("/migrationtest/dbmigration/" + server().platform().name().toLowerCase() + "/" + scriptName);
assert url != null : scriptName + " not found";
assert url != null : scriptName + " not found for platform [" + server().platform().name().toLowerCase() + "]";
server().script().run(url);
}
@@ -51,8 +51,8 @@ public class DbMigrationTest extends BaseTestCase {
@Test
public void testRunMigration() throws IOException, SQLException {
// Shutdown and reconnect - this prevents postgres from lock up
((ConnectionPool)server().dataSource()).offline();
((ConnectionPool)server().dataSource()).online();
((DataSourcePool)server().dataSource()).offline();
((DataSourcePool)server().dataSource()).online();
cleanup("migtest_ckey_assoc",
"migtest_ckey_detail",
"migtest_ckey_parent",
@@ -86,8 +86,8 @@ public class DbMigrationTest extends BaseTestCase {
"table",
"\"table\"",
"`table`");
((ConnectionPool)server().dataSource()).offline();
((ConnectionPool)server().dataSource()).online();
((DataSourcePool)server().dataSource()).offline();
((DataSourcePool)server().dataSource()).online();
if (isSqlServer() || isMariaDB() || isMySql() || isHana()) {
runScript("I__create_procs.sql");
@@ -4,7 +4,6 @@ import io.ebean.xtest.BaseTestCase;
import io.ebean.DB;
import io.ebean.Query;
import io.ebean.test.LoggedSql;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.Contact;
import org.tests.model.basic.Customer;
@@ -495,21 +495,11 @@ public class TDSpiEbeanServer extends TDSpiServer implements SpiEbeanServer {
return null;
}
@Override
public SqlQuery createSqlQuery(String sql) {
return sqlQuery(sql);
}
@Override
public SqlUpdate sqlUpdate(String sql) {
return null;
}
@Override
public SqlUpdate createSqlUpdate(String sql) {
return sqlUpdate(sql);
}
@Override
public CallableSql createCallableSql(String callableSql) {
return null;
@@ -653,11 +643,6 @@ public class TDSpiEbeanServer extends TDSpiServer implements SpiEbeanServer {
return null;
}
@Override
public <T> Stream<T> findLargeStream(Query<T> query, Transaction transaction) {
return null;
}
@Override
public <T> void findEach(Query<T> query, Consumer<T> consumer, Transaction transaction) {
}
@@ -177,21 +177,11 @@ public class TDSpiServer implements SpiServer {
return null;
}
@Override
public SqlQuery createSqlQuery(String sql) {
return null;
}
@Override
public SqlUpdate sqlUpdate(String sql) {
return null;
}
@Override
public SqlUpdate createSqlUpdate(String sql) {
return null;
}
@Override
public CallableSql createCallableSql(String callableSql) {
return null;
@@ -3,7 +3,7 @@ package io.ebean.xtest.internal.server.text.json;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.h2.H2Platform;
import io.ebean.platform.h2.H2Platform;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebeaninternal.server.text.json.DJsonScalar;
import io.ebeaninternal.server.type.DefaultTypeManager;
@@ -2,13 +2,22 @@ package org.multitenant.partition;
import io.ebean.config.CurrentTenantProvider;
import java.util.concurrent.atomic.AtomicInteger;
class CurrentTenant implements CurrentTenantProvider {
static AtomicInteger callCounter = new AtomicInteger();
static int count() {
return callCounter.get();
}
/**
* Return the current tenantId from the user context.
*/
@Override
public String currentId() {
callCounter.incrementAndGet();
return UserContext.get().getTenantId();
}
}
@@ -0,0 +1,21 @@
package org.multitenant.partition;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Version;
@Entity
public class MtNone {
@Id
long id;
final String none;
@Version
long version;
public MtNone(String none) {
this.none = none;
}
}
@@ -1,11 +1,11 @@
package org.multitenant.partition;
import io.ebean.xtest.BaseTestCase;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.TenantMode;
import io.ebean.test.LoggedSql;
import io.ebean.xtest.BaseTestCase;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
@@ -15,7 +15,7 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class MultiTenantPartitionTest extends BaseTestCase {
class MultiTenantPartitionTest extends BaseTestCase {
private static final String[] names = {"Ace", "Base", "Case", "Dae", "Eva"};
@@ -33,13 +33,26 @@ public class MultiTenantPartitionTest extends BaseTestCase {
}
@AfterAll
public static void shutdown() {
static void shutdown() {
server.shutdown();
}
@Test
public void start() {
void queryOnly_noTenantIdRequired_expect_currentTenantNotCalled() {
// MtNone does not have any @TenantId property
MtNone none = new MtNone("none");
server.save(none);
int beforeCount = CurrentTenant.count();
// CurrentTenant should not be called for this query
server.find(MtNone.class).findList();
int afterCount = CurrentTenant.count();
assertThat(afterCount).isSameAs(beforeCount);
}
@Test
void start() {
UserContext.set("rob", "ten_1");
LoggedSql.start();
@@ -64,8 +77,7 @@ public class MultiTenantPartitionTest extends BaseTestCase {
}
@Test
public void deleteById() {
void deleteById() {
UserContext.set("fred", "ten_2");
MtContent content = new MtContent("first title");
@@ -83,8 +95,7 @@ public class MultiTenantPartitionTest extends BaseTestCase {
}
@Test
public void deleteByIds() {
void deleteByIds() {
UserContext.set("fred", "ten_2");
MtContent a = newContent("title a");
@@ -107,11 +118,8 @@ public class MultiTenantPartitionTest extends BaseTestCase {
return content;
}
private static Database init() {
DatabaseConfig config = new DatabaseConfig();
config.setName("h2multitenant");
config.loadFromProperties();
config.setDdlGenerate(true);
@@ -124,6 +132,7 @@ public class MultiTenantPartitionTest extends BaseTestCase {
config.getClasses().add(MtTenant.class);
config.getClasses().add(MtContent.class);
config.getClasses().add(MtNone.class);
return DatabaseFactory.create(config);
}
@@ -5,7 +5,7 @@ import io.ebean.DatabaseFactory;
import io.ebean.Query;
import io.ebean.SqlRow;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
import io.ebean.platform.postgres.PostgresPlatform;
import io.ebean.datasource.DataSourceConfig;
import org.tests.model.basic.TOne;
import org.tests.model.basic.TSDetail;
@@ -25,7 +25,7 @@ public class TestManyOneInterface extends BaseTestCase {
IPerson p = DB.getDefault().createEntityBean(Person.class);
assertThat(p).isInstanceOf(ExtPerson1and2.class);
p = DB.getDefault().getPluginApi().createEntityBean(IPerson.class);
p = DB.getDefault().pluginApi().createEntityBean(IPerson.class);
assertThat(p).isInstanceOf(ExtPerson1and2.class);
p.setDefaultAddress(a);
@@ -46,8 +46,8 @@ public class TestManyOneInterface extends BaseTestCase {
assertThat(p2.getDefaultAddress()).isInstanceOf(Address.class);
// some more checks
IExtPerson1 pe1 = DB.getDefault().getPluginApi().createEntityBean(IExtPerson1.class);
IExtPerson2 pe2 = DB.getDefault().getPluginApi().createEntityBean(IExtPerson2.class);
IExtPerson1 pe1 = DB.getDefault().pluginApi().createEntityBean(IExtPerson1.class);
IExtPerson2 pe2 = DB.getDefault().pluginApi().createEntityBean(IExtPerson2.class);
assertThat(pe1).isInstanceOf(ExtPerson1and2.class);
assertThat(pe2).isInstanceOf(ExtPerson1and2.class);
@@ -1,7 +1,5 @@
package org.tests.model;
import io.ebean.annotation.CreatedTimestamp;
import io.ebean.annotation.UpdatedTimestamp;
import io.ebean.annotation.WhenCreated;
import io.ebean.annotation.WhenModified;
@@ -31,40 +29,40 @@ public class EGenProps {
@WhenModified
Timestamp whenModified;
@CreatedTimestamp
@WhenCreated
Timestamp tsCreated;
@UpdatedTimestamp
@WhenModified
Timestamp tsUpdated;
@CreatedTimestamp
@WhenCreated
LocalDateTime ldtCreated;
@UpdatedTimestamp
@WhenModified
LocalDateTime ldtUpdated;
@CreatedTimestamp
@WhenCreated
OffsetDateTime odtCreated;
@UpdatedTimestamp
@WhenModified
OffsetDateTime odtUpdated;
@CreatedTimestamp
@WhenCreated
ZonedDateTime zdtCreated;
@UpdatedTimestamp
@WhenModified
ZonedDateTime zdtUpdated;
@CreatedTimestamp
@WhenCreated
Instant instantCreated;
@UpdatedTimestamp
@WhenModified
Instant instantUpdated;
@CreatedTimestamp
@WhenCreated
long longCreated;
@UpdatedTimestamp
@WhenModified
long longUpdated;
public Long getId() {
@@ -40,7 +40,7 @@ public class Contact {
@OneToMany(cascade = CascadeType.ALL)
List<ContactNote> notes;
@CreatedTimestamp
@WhenCreated
Timestamp cretime;
@Version
@@ -33,7 +33,7 @@ public class Product implements Serializable {
String name;
@CreatedTimestamp
@WhenCreated
Timestamp cretime;
@Version
@@ -117,9 +117,9 @@ public class TestNatKeyCacheWithForeignKey extends BaseTestCase {
@Test
public void findSimple() {
setupData();
clearAllL2Cache();
appStats();
OCachedApp app0 = findAppByName("app0");
assertThat(app0).isNotNull();
@@ -1,6 +1,6 @@
package org.tests.model.interfaces;
import io.ebean.annotation.EntityImplements;
import io.ebean.annotation.ext.EntityImplements;
import javax.persistence.Entity;
import javax.persistence.Id;
@@ -1,7 +1,7 @@
package org.tests.model.interfaces;
import io.ebean.annotation.EntityImplements;
import io.ebean.annotation.EntityOverride;
import io.ebean.annotation.ext.EntityImplements;
import io.ebean.annotation.ext.EntityOverride;
import javax.persistence.Entity;
@@ -1,7 +1,7 @@
package org.tests.model.interfaces;
import io.ebean.annotation.EntityImplements;
import io.ebean.annotation.EntityOverride;
import io.ebean.annotation.ext.EntityImplements;
import io.ebean.annotation.ext.EntityOverride;
import javax.persistence.Entity;
import javax.persistence.Table;
@@ -1,7 +1,7 @@
package org.tests.model.interfaces;
import io.ebean.annotation.EntityImplements;
import io.ebean.annotation.EntityOverride;
import io.ebean.annotation.ext.EntityImplements;
import io.ebean.annotation.ext.EntityOverride;
import javax.persistence.Entity;
import javax.persistence.Table;
@@ -1,6 +1,6 @@
package org.tests.model.interfaces;
import io.ebean.annotation.EntityImplements;
import io.ebean.annotation.ext.EntityImplements;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
@@ -37,27 +37,6 @@ public class TestQueryFindStream extends BaseTestCase {
}
}
@Test
public void findLargeStream_basic() {
ResetBasicData.reset();
try (Stream<Customer> stream = DB.find(Customer.class)
.findLargeStream()) {
// bad example, don't use a stream like this when we can
// use findSingleAttributeList() instead
final List<String> namesStream = stream
.map(Customer::getName)
.collect(toList());
final List<String> namesQuery = DB.find(Customer.class)
.select("name")
.findSingleAttributeList();
assertThat(namesStream).hasSize(namesQuery.size());
assertThat(namesStream).containsAll(namesQuery);
}
}
@Test
public void manualTest_findSteam_when_closeWithResources() {
// confirm manually the stream is closed via try with resources block
@@ -13,6 +13,7 @@ import org.tests.model.basic.ResetBasicData;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -23,6 +24,54 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class SqlQueryTests extends BaseTestCase {
@ForPlatform(Platform.H2)
@Test
public void selectBindNull_byPos() {
String sql = "select nvl(cast(? as int), 42)";
final Long val = DB.sqlQuery(sql)
.setNullParameter(1, Types.INTEGER)
.mapToScalar(Long.class)
.findOne();
assertThat(val).isEqualTo(42);
}
@ForPlatform(Platform.H2)
@Test
public void selectBindNull_byName() {
String sql = "select nvl(cast(:val as int), 42)";
final Long val = DB.sqlQuery(sql)
.setNullParameter("val", Types.INTEGER)
.mapToScalar(Long.class)
.findOne();
assertThat(val).isEqualTo(42);
}
@ForPlatform(Platform.H2)
@Test
public void selectBindNull_usingSetParameter_ByPosition() {
String sql = "select nvl(cast(? as int), 42)";
final Long val = DB.sqlQuery(sql)
.setParameter(1, null)
.mapToScalar(Long.class)
.findOne();
assertThat(val).isEqualTo(42);
}
@ForPlatform(Platform.H2)
@Test
public void selectBindNull_usingSetParameter_byName() {
String sql = "select nvl(cast(:val as int), 42)";
final Long val = DB.sqlQuery(sql)
.setParameter("val", null)
.mapToScalar(Long.class)
.findOne();
assertThat(val).isEqualTo(42);
}
@ForPlatform(Platform.H2)
@Test
public void selectFunction() {
@@ -15,5 +15,5 @@ create table migtest_e_history7_history(
sys_period_end timestamp
);
create view migtest_e_history7_with_history as select * from migtest_e_history7 union all select * from migtest_e_history7_history;
create trigger migtest_e_history7_history_upd before update,delete on migtest_e_history7 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history7_history_upd before update,delete on migtest_e_history7 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
@@ -1,13 +1,13 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
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 generated by default as identity not null,
id integer auto_increment not null,
something varchar(255),
constraint pk_migtest_ckey_detail primary key (id)
);
@@ -21,48 +21,48 @@ create table migtest_ckey_parent (
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
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 generated by default as identity not null,
id bigint auto_increment 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,
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 generated by default as identity not null,
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 generated by default as identity not null,
id bigint auto_increment 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,
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 generated by default as identity not null,
id integer auto_increment not null,
status varchar(1),
status2 varchar(1) default 'N' not null,
name varchar(127),
description varchar(127),
description_file blob(64M),
json_list clob(16K) inline length 500 compact,
a_lob clob(16K) inline length 500 not logged default 'X' not null,
description_file blob,
json_list clob,
a_lob varchar(255) default 'X' not null,
some_date timestamp,
old_boolean boolean default false not null,
old_boolean2 boolean,
@@ -74,26 +74,28 @@ create table migtest_e_basic (
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 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)
) in TSTABLES index in INDEXTS long in TSTABLES;
);
create table migtest_e_enum (
id integer generated by default as identity not null,
id integer auto_increment not null,
test_status varchar(1),
constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I')),
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,
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history primary key (id)
) in MAIN index in MAIN long in MAIN;
);
create table migtest_e_history2 (
id integer generated by default as identity not null,
id integer auto_increment not null,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
@@ -101,25 +103,25 @@ create table migtest_e_history2 (
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
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 generated by default as identity not null,
id integer auto_increment 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,
id integer auto_increment 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,
id integer auto_increment not null,
test_number1 integer,
test_number2 integer not null,
constraint pk_migtest_e_history6 primary key (id)
@@ -129,19 +131,21 @@ create table "migtest_QuOtEd" (
id varchar(255) not null,
status1 varchar(1),
status2 varchar(1),
constraint ck_mgtst_qtd_stts1 check ( status1 in ('N','A','I')),
constraint ck_mgtst_qtd_stts2 check ( status2 in ('N','A','I')),
constraint ck_migtest_quoted_status1 check ( status1 in ('N','A','I')),
constraint ck_migtest_quoted_status2 check ( status2 in ('N','A','I')),
constraint uq_migtest_quoted_status2 unique (status2),
constraint pk_migtest_quoted primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
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 generated by default as identity not null,
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_softdelete primary key (id)
);
@@ -152,92 +156,50 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
create table migtest_mtm_c (
id integer generated by default as identity not null,
id integer auto_increment 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,
id bigint auto_increment 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,
id integer auto_increment 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,
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table "table" add column sys_period_start timestamp(12) not null generated always as row begin;
alter table "table" add column sys_period_end timestamp(12) not null generated always as row end;
alter table "table" add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table "table" add period system_time (sys_period_start,sys_period_end);
alter table migtest_e_history2 add column sys_period_start timestamp(12) not null generated always as row begin;
alter table migtest_e_history2 add column sys_period_end timestamp(12) not null generated always as row end;
alter table migtest_e_history2 add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table migtest_e_history2 add period system_time (sys_period_start,sys_period_end);
alter table migtest_e_history3 add column sys_period_start timestamp(12) not null generated always as row begin;
alter table migtest_e_history3 add column sys_period_end timestamp(12) not null generated always as row end;
alter table migtest_e_history3 add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table migtest_e_history3 add period system_time (sys_period_start,sys_period_end);
alter table migtest_e_history4 add column sys_period_start timestamp(12) not null generated always as row begin;
alter table migtest_e_history4 add column sys_period_end timestamp(12) not null generated always as row end;
alter table migtest_e_history4 add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table migtest_e_history4 add period system_time (sys_period_start,sys_period_end);
alter table migtest_e_history5 add column sys_period_start timestamp(12) not null generated always as row begin;
alter table migtest_e_history5 add column sys_period_end timestamp(12) not null generated always as row end;
alter table migtest_e_history5 add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table migtest_e_history5 add period system_time (sys_period_start,sys_period_end);
alter table migtest_e_history6 add column sys_period_start timestamp(12) not null generated always as row begin;
alter table migtest_e_history6 add column sys_period_end timestamp(12) not null generated always as row end;
alter table migtest_e_history6 add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table migtest_e_history6 add period system_time (sys_period_start,sys_period_end);
-- apply post alter
create unique index uq_mgtst__b_4aybzy on migtest_e_basic(indextest2) exclude null keys;
create unique index uq_mgtst__b_4ayc02 on migtest_e_basic(indextest6) exclude null keys;
create table migtest_e_history2_history as (select * from migtest_e_history2) with no data;
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
create table migtest_e_history3_history as (select * from migtest_e_history3) with no data;
alter table migtest_e_history3 add versioning use history table migtest_e_history3_history;
create table migtest_e_history4_history as (select * from migtest_e_history4) with no data;
alter table migtest_e_history4 add versioning use history table migtest_e_history4_history;
create table migtest_e_history5_history as (select * from migtest_e_history5) with no data;
alter table migtest_e_history5 add versioning use history table migtest_e_history5_history;
create table migtest_e_history6_history as (select * from migtest_e_history6) with no data;
alter table migtest_e_history6 add versioning use history table migtest_e_history6_history;
create unique index uq_mgtst_qtd_stts2 on "migtest_QuOtEd"(status2) exclude null keys;
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
create unique index uq_table_to on "table"("to") exclude null keys;
create unique index uq_table_varchar on "table"("varchar") exclude null keys;
create table table_history as (select * from "table") with no data;
alter table "table" add versioning use history table table_history;
-- foreign keys and indices
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 on update restrict;
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_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 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_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 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;
create index ix_table_foreign on "table" ("foreign");
alter table "table" add constraint fk_table_foreign foreign key ("foreign") references "table" ("index") on delete restrict on update restrict;
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_qtd_stts1 on "migtest_QuOtEd" (status1);
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_quoted_status1 on "migtest_QuOtEd" (status1);
create index ix_table_from on "table" ("from");
@@ -1,92 +1,18 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_FK_65KF6L' and ucase(tabname) = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_FK_WICX8X' and ucase(tabname) = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'CK_MGTST__BSC_STTS' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'CK_MGTST__B_Z543FG' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__B_4AYBZY' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__B_4AYBZY') then
prepare stmt from 'drop index uq_mgtst__b_4aybzy';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__B_4AYC02' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__B_4AYC02') then
prepare stmt from 'drop index uq_mgtst__b_4ayc02';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'CK_MGTST__N_773SOK' and ucase(tabname) = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_mgtst__n_773sok';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MGTST__B_EU8CSQ') then
prepare stmt from 'drop index ix_mgtst__b_eu8csq';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MGTST__B_EU8CSU') then
prepare stmt from 'drop index ix_mgtst__b_eu8csu';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MGTST_QTD_STTS1') then
prepare stmt from 'drop index ix_mgtst_qtd_stts1';
execute stmt;
end if;
end$$;
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest1;
drop index if exists ix_migtest_e_basic_indextest5;
drop index if exists ix_migtest_quoted_status1;
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
@@ -94,41 +20,31 @@ 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)
) in TESTTS index in TESTTS long in TESTTS;
);
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)
) in TSMASTER index in TSMASTER long in TSMASTER;
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
) in TSMASTER index in TSMASTER long in TSMASTER;
);
update migtest_e_basic set status = 'A' where status is null;
-- db2 does not support parial null indices :( - so we have to clean;
update migtest_e_basic set status = 'N' where id = 1;
-- rename all collisions;
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_E_BASIC','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
-- 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 drop versioning;
alter table migtest_e_history3 drop versioning;
alter table migtest_e_history4 drop versioning;
alter table migtest_e_history5 drop versioning;
-- 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 drop versioning;
alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
alter table "table" add column "select" varchar(255);
alter table migtest_ckey_detail add column one_key integer;
@@ -136,100 +52,71 @@ alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
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 alter column status2 set data type varchar(127);
alter table migtest_e_basic alter column status2 varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
alter table migtest_e_basic alter column status2 set null;
alter table migtest_e_basic alter column a_lob drop default;
alter table migtest_e_basic alter column a_lob drop not null;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic alter column a_lob set null;
alter table migtest_e_basic alter column user_id set 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;
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 column new_integer integer default 42 not null;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin;
alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end;
alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id;
alter table migtest_e_history add period system_time (sys_period_start,sys_period_end);
alter table migtest_e_history alter column test_string set data type bigint;
call sysproc.admin_cmd('reorg table migtest_e_history');
alter table migtest_e_history alter column test_string bigint;
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);
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history2_history alter column test_string set not null;
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' not null;
alter table migtest_e_history2_history add column new_column varchar(20);
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
alter table migtest_e_history4 alter column test_number set data type bigint;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history4_history alter column test_number set data type bigint;
call sysproc.admin_cmd('reorg table migtest_e_history4_history');
alter table migtest_e_history4 alter column 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 not 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;
call sysproc.admin_cmd('reorg table migtest_e_history6');
alter table migtest_e_history6_history alter column test_number1 set not null;
alter table migtest_e_history6_history alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
alter table migtest_e_history6 alter column test_number2 set null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history add column "select" varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I','?'));
create unique index uq_mgtst__b_vs45xo on migtest_e_basic(description) exclude null keys;
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 check ( progress in (0,1,2));
create unique index uq_mgtst__b_ucfcne on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_mgtst__bsc_nm on migtest_e_basic(name) exclude null keys;
create unique index uq_mgtst__b_4ayc00 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_mgtst__b_4ayc01 on migtest_e_basic(indextest5) exclude null keys;
create table migtest_e_history_history as (select * from migtest_e_history) with no data in MAIN index in MAIN long in MAIN;
alter table migtest_e_history add versioning use history table migtest_e_history_history;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
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);
comment on column migtest_e_history.test_string is 'Column altered to long now';
comment on table migtest_e_history is 'We have history now';
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
alter table migtest_e_history3 add versioning use history table migtest_e_history3_history;
alter table migtest_e_history4 add versioning use history table migtest_e_history4_history;
alter table migtest_e_history5 add versioning use history table migtest_e_history5_history;
alter table migtest_e_history6 add versioning use history table migtest_e_history6_history;
comment on column "table"."index" is 'this is an other comment';
alter table "table" add versioning use history table table_history;
create unique index uq_table_select on "table"("select") exclude null keys;
alter table "table" add constraint uq_table_select unique ("select");
-- foreign keys and indices
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 on update restrict;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
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 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_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 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_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 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_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 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;
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 on update 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 on update restrict;
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;
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_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update 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 on update 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 on update restrict;
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
alter table migtest_e_basic add constraint fk_mgtst__bsc_sr_d foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
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 add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
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_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;
create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3);
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -1,26 +1,11 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_history2 drop versioning;
-- apply alter tables
alter table migtest_e_basic drop column description_file;
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;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history2 drop column obsolete_string1;
alter table migtest_e_history2 drop column obsolete_string2;
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history2_history drop column obsolete_string1;
alter table migtest_e_history2_history drop column obsolete_string2;
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
-- apply post alter
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
drop table "migtest_QuOtEd";
drop table migtest_e_ref;
delimiter $$
begin
if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'MIGTEST_E_REF_SEQ') then
prepare stmt from 'drop sequence migtest_e_ref_seq';
execute stmt;
end if;
end$$;
drop table if exists "migtest_QuOtEd";
drop table if exists migtest_e_ref;
@@ -1,165 +1,36 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_CK_E1QKB5' and ucase(tabname) = 'MIGTEST_CKEY_DETAIL') then
prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_FK_65KF6L' and ucase(tabname) = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_FK_NN_N_D' and ucase(tabname) = 'MIGTEST_FK_NONE') then
prepare stmt from 'alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_FK_9TKNZJ' and ucase(tabname) = 'MIGTEST_FK_NONE_VIA_JOIN') then
prepare stmt from 'alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST_FK_WICX8X' and ucase(tabname) = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'CK_MGTST__BSC_STTS' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'CK_MGTST__B_Z543FG' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__B_VS45XO' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__B_VS45XO') then
prepare stmt from 'drop index uq_mgtst__b_vs45xo';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MGTST__BSC_SR_D' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__B_UCFCNE' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__B_UCFCNE') then
prepare stmt from 'drop index uq_mgtst__b_ucfcne';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__BSC_NM' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__BSC_NM') then
prepare stmt from 'drop index uq_mgtst__bsc_nm';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__B_4AYC00' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__B_4AYC00') then
prepare stmt from 'drop index uq_mgtst__b_4ayc00';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'UQ_MGTST__B_4AYC01' and ucase(tabname) = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'UQ_MGTST__B_4AYC01') then
prepare stmt from 'drop index uq_mgtst__b_4ayc01';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'CK_MGTST__N_773SOK' and ucase(tabname) = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_mgtst__n_773sok';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MGTST__B_EU8CSS') then
prepare stmt from 'drop index ix_mgtst__b_eu8css';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MGTST__B_EU8CSV') then
prepare stmt from 'drop index ix_mgtst__b_eu8csv';
execute stmt;
end if;
end$$;
alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id;
alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
alter table migtest_e_basic drop constraint if exists fk_migtest_e_basic_user_id;
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_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
status1 varchar(1),
status2 varchar(1),
constraint ck_mgtst_qtd_stts1 check ( status1 in ('N','A','I')),
constraint ck_mgtst_qtd_stts2 check ( status2 in ('N','A','I')),
constraint ck_migtest_quoted_status1 check ( status1 in ('N','A','I')),
constraint ck_migtest_quoted_status2 check ( status2 in ('N','A','I')),
constraint uq_migtest_quoted_status2 unique (status2),
constraint pk_migtest_quoted primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
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)
);
@@ -169,73 +40,48 @@ update migtest_e_basic set status2 = 'N' where status2 is null;
update migtest_e_basic set a_lob = 'X' where a_lob is null;
update migtest_e_basic set user_id = 23 where user_id is null;
alter table migtest_e_history2 drop versioning;
alter table migtest_e_history3 drop versioning;
alter table migtest_e_history4 drop versioning;
alter table migtest_e_history6 drop versioning;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
-- apply alter tables
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 alter column status2 set data type varchar(1);
alter table migtest_e_basic alter column status set null;
alter table migtest_e_basic alter column 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 alter column a_lob set data type clob(16K);
alter table migtest_e_basic alter column a_lob set inline length 500;
-- ignored options for migtest_e_basic.a_lob: compact=true, logged=true;
alter table migtest_e_basic alter column a_lob varchar(255);
alter table migtest_e_basic alter column a_lob set default 'X';
alter table migtest_e_basic alter column a_lob set not null;
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 description_file blob(64M);
alter table migtest_e_basic add column description_file blob;
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;
call sysproc.admin_cmd('reorg table migtest_e_basic');
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 alter column test_string set 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 alter column test_string drop not null;
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 set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history4_history alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4_history');
alter table migtest_e_history4 alter column 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;
alter table migtest_e_history6 alter column test_number1 set 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;
call sysproc.admin_cmd('reorg table migtest_e_history6');
alter table migtest_e_history6_history alter column test_number1 drop not null;
alter table migtest_e_history6_history alter column test_number2 set not null;
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
-- apply post alter
create unique index uq_mgtst_qtd_stts2 on "migtest_QuOtEd"(status2) exclude null keys;
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I'));
alter table migtest_e_basic add constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I'));
create unique index uq_mgtst__b_4aybzy on migtest_e_basic(indextest2) exclude null keys;
create unique index uq_mgtst__b_4ayc02 on migtest_e_basic(indextest6) exclude null keys;
alter table migtest_e_enum add constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I'));
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
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 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 add versioning use history table migtest_e_history2_history;
alter table migtest_e_history3 add versioning use history table migtest_e_history3_history;
alter table migtest_e_history4 add versioning use history table migtest_e_history4_history;
alter table migtest_e_history6 add versioning use history table migtest_e_history6_history;
comment on column "table"."index" is 'this is a comment';
-- foreign keys and indices
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
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 on update restrict;
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 on update restrict;
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_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;
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_qtd_stts1 on "migtest_QuOtEd" (status1);
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_quoted_status1 on "migtest_QuOtEd" (status1);
@@ -1,53 +1,21 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_history drop versioning;
alter table migtest_e_history drop period system_time;
alter table migtest_e_history2 drop versioning;
alter table migtest_e_history5 drop versioning;
-- apply alter tables
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
alter table migtest_ckey_parent drop column assoc_id;
call sysproc.admin_cmd('reorg table migtest_ckey_parent');
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;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history drop column sys_period_start;
alter table migtest_e_history drop column sys_period_end;
alter table migtest_e_history drop column sys_period_txn;
call sysproc.admin_cmd('reorg table migtest_e_history');
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;
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history2_history drop column test_string2;
alter table migtest_e_history2_history drop column test_string3;
alter table migtest_e_history2_history drop column new_column;
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
alter table migtest_e_history5 drop column test_boolean;
call sysproc.admin_cmd('reorg table migtest_e_history5');
alter table migtest_e_history5_history drop column test_boolean;
call sysproc.admin_cmd('reorg table migtest_e_history5_history');
alter table migtest_e_softdelete drop column deleted;
call sysproc.admin_cmd('reorg table migtest_e_softdelete');
alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
-- apply post alter
drop table migtest_e_history_history;
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
alter table migtest_e_history5 add versioning use history table migtest_e_history5_history;
drop table migtest_e_user;
delimiter $$
begin
if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'MIGTEST_E_USER_SEQ') then
prepare stmt from 'drop sequence migtest_e_user_seq';
execute stmt;
end if;
end$$;
drop table migtest_mtm_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers;
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;
@@ -1,7 +0,0 @@
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,6 @@
-710189690, 1.0__initial.sql
1626063176, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
2025934113, 1.3.sql
80209848, 1.4__dropsFor_1.3.sql
@@ -209,7 +209,7 @@ create table migtest_e_history2_history(
sys_period_end timestamp
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create table migtest_e_history3_history(
id integer,
@@ -218,7 +218,7 @@ create table migtest_e_history3_history(
sys_period_end timestamp
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create table migtest_e_history4_history(
id integer,
@@ -227,7 +227,7 @@ create table migtest_e_history4_history(
sys_period_end timestamp
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create table migtest_e_history5_history(
id integer,
@@ -236,7 +236,7 @@ create table migtest_e_history5_history(
sys_period_end timestamp
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create table migtest_e_history6_history(
id integer,
@@ -246,7 +246,7 @@ create table migtest_e_history6_history(
sys_period_end timestamp
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create table table_history(
"index" varchar(255),
@@ -258,7 +258,7 @@ create table table_history(
sys_period_end timestamp
);
create view table_with_history as select * from "table" union all select * from table_history;
create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.platform.h2.H2HistoryTrigger";
-- foreign keys and indices
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
@@ -115,23 +115,23 @@ create table migtest_e_history_history(
sys_period_end timestamp
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.platform.h2.H2HistoryTrigger";
comment on column migtest_e_history.test_string is 'Column altered to long now';
comment on table migtest_e_history is 'We have history now';
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
comment on column "table"."index" is 'this is an other comment';
create view table_with_history as select * from "table" union all select * from table_history;
create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.platform.h2.H2HistoryTrigger";
alter table "table" add constraint uq_table_select unique ("select");
-- foreign keys and indices
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
@@ -13,7 +13,7 @@ alter table migtest_e_history2_history drop column obsolete_string1;
alter table migtest_e_history2_history drop column obsolete_string2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
drop table if exists "migtest_QuOtEd";
drop table if exists migtest_e_ref;
drop sequence if exists migtest_e_ref_seq;
@@ -89,13 +89,13 @@ alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check (
comment on column migtest_e_history.test_string is '';
comment on table migtest_e_history is '';
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
comment on column "table"."index" is 'this is a comment';
-- foreign keys and indices
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;
@@ -32,9 +32,9 @@ alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
drop table if exists migtest_e_user;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m;
@@ -1,8 +1,8 @@
-1826073043, 1.0__initial.sql
-132538485, 1.1.sql
-2064267391, 1.2__dropsFor_1.1.sql
-94686510, 1.3.sql
-1382108238, 1.4__dropsFor_1.3.sql
-1806036603, 1.0__initial.sql
1830755650, 1.1.sql
1579867974, 1.2__dropsFor_1.1.sql
-877392737, 1.3.sql
116139207, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql