mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge pull request #61 from FOCONIS/move-migrationtest
Move migrationtest
This commit is contained in:
+12
-14
@@ -1,33 +1,31 @@
|
||||
package io.ebeaninternal.dbmigration.run;
|
||||
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.migration.auto.AutoMigrationRunner;
|
||||
import io.ebean.migration.MigrationConfig;
|
||||
import io.ebean.migration.MigrationRunner;
|
||||
import io.ebean.plugin.Plugin;
|
||||
import io.ebean.plugin.SpiServer;
|
||||
import io.ebeaninternal.server.core.ServiceUtil;
|
||||
|
||||
public class DbRunMigrationPlugin implements Plugin {
|
||||
|
||||
private SpiServer server;
|
||||
private AutoMigrationRunner migrationRunner;
|
||||
private MigrationConfig migrationConfig;
|
||||
|
||||
@Override
|
||||
public void configure(SpiServer server) {
|
||||
this.server = server;
|
||||
DatabaseConfig config = server.config();
|
||||
if (config.isRunMigration()) {
|
||||
migrationRunner = ServiceUtil.service(AutoMigrationRunner.class);
|
||||
if (migrationRunner == null) {
|
||||
throw new IllegalStateException(
|
||||
"No AutoMigrationRunner found. Probably ebean-migration is not in the classpath?");
|
||||
}
|
||||
migrationConfig = new MigrationConfig();
|
||||
final String dbSchema = config.getDbSchema();
|
||||
if (dbSchema != null) {
|
||||
migrationRunner.setDefaultDbSchema(dbSchema);
|
||||
migrationConfig.setSetCurrentSchema(false);
|
||||
migrationConfig.setDbSchema(dbSchema);
|
||||
}
|
||||
migrationRunner.setName(config.getName());
|
||||
migrationRunner.setPlatform(config.getDatabasePlatform().getPlatform().base().name().toLowerCase());
|
||||
migrationRunner.loadProperties(config.getProperties());
|
||||
migrationConfig.setName(config.getName());
|
||||
migrationConfig.setPlatform(config.getDatabasePlatform().getPlatform().base().name().toLowerCase());
|
||||
migrationConfig.load(config.getProperties());
|
||||
migrationConfig.setRunPlaceholderMap(config.getDdlPlaceholderMap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +41,8 @@ public class DbRunMigrationPlugin implements Plugin {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (migrationRunner != null) {
|
||||
migrationRunner.run(server.dataSource());
|
||||
if (migrationConfig != null) {
|
||||
new MigrationRunner(migrationConfig).run(server.dataSource());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-22
@@ -180,41 +180,44 @@ public class DefaultDbMigration implements DbMigration {
|
||||
generate = props.getBoolean("migration.generate", generate);
|
||||
generateInit = props.getBoolean("migration.generateInit", generateInit);
|
||||
// header & strictMode must be configured at DatabaseConfig level
|
||||
parsePlatforms(props.get("migration.platforms"), config.getClassLoadConfig());
|
||||
parsePlatforms(props, config);
|
||||
}
|
||||
}
|
||||
|
||||
protected void parsePlatforms(String platforms, ClassLoadConfig loader) {
|
||||
protected void parsePlatforms(PropertiesWrapper props, DatabaseConfig config) {
|
||||
String platforms = props.get("migration.platforms");
|
||||
if (platforms == null || platforms.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String[] tmp = StringHelper.splitNames(platforms);
|
||||
for (String plat : tmp) {
|
||||
int pos = plat.indexOf('=');
|
||||
String platformName;
|
||||
String prefix;
|
||||
if (pos == -1) {
|
||||
prefix = null;
|
||||
platformName = plat;
|
||||
} else {
|
||||
platformName = plat.substring(0, pos);
|
||||
prefix = plat.substring(pos + 1);
|
||||
}
|
||||
for (String platformName : tmp) {
|
||||
DatabasePlatform dbPlatform;
|
||||
if (platformName.indexOf('.') == -1) {
|
||||
// parse platform as enum value
|
||||
Platform platform = Enum.valueOf(Platform.class, platformName.toUpperCase());
|
||||
if (prefix == null) {
|
||||
prefix = platform.name().toLowerCase();
|
||||
}
|
||||
addPlatform(platform, prefix);
|
||||
dbPlatform =platform(platform);
|
||||
} else {
|
||||
// parse platform as class
|
||||
DatabasePlatform dbPlatform = (DatabasePlatform) loader.newInstance(platformName);
|
||||
if (prefix == null) {
|
||||
prefix = dbPlatform.getPlatform().base().name().toLowerCase();
|
||||
}
|
||||
addDatabasePlatform(dbPlatform, prefix);
|
||||
dbPlatform = (DatabasePlatform) config.getClassLoadConfig().newInstance(platformName);
|
||||
}
|
||||
|
||||
// Special wrapper, that allows us to define properties like:
|
||||
// migration.SERVERNAME.PLATFORMNAME.key
|
||||
PropertiesWrapper platformProps = new PropertiesWrapper("migration", config.getName(), config.getProperties(), config.getClassLoadConfig()) {
|
||||
@Override
|
||||
public String get(String key, String defaultValue) {
|
||||
String ret = super.get(platformName + "." + key, null);
|
||||
if (ret == null) {
|
||||
ret = super.get(key, defaultValue);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
String platformPrefix = platformProps.get("prefix", dbPlatform.getPlatform().name().toLowerCase());
|
||||
PlatformConfig platformConfig = new PlatformConfig();
|
||||
platformConfig.loadSettings(platformProps);
|
||||
dbPlatform.configure(platformConfig);
|
||||
addDatabasePlatform(dbPlatform, platformPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class LastMigrationTest {
|
||||
|
||||
@Test
|
||||
public void lastVersion() {
|
||||
File d = new File("src/test/resources/dbmigration/migrationtest/h2");
|
||||
assertThat(LastMigration.lastVersion(d, null)).isEqualTo("1.4");
|
||||
assertThat(LastMigration.nextVersion(d, null, false)).isEqualTo("1.5");
|
||||
assertThat(LastMigration.nextVersion(d, null, true)).isEqualTo("1.4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lastVersion_no_v_Prefix() {
|
||||
File d = new File("src/test/resources/dbmigration/migrationtest-history");
|
||||
assertThat(LastMigration.lastVersion(d, null)).isEqualTo("1.2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lastVersion_test() {
|
||||
File d = new File("src/test/resources/test-dbmigration");
|
||||
|
||||
+14
@@ -2,6 +2,7 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.db2.DB2LuwPlatform;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
@@ -23,6 +24,7 @@ public class PlatformDdl_CreateIndexTest {
|
||||
private final PlatformDdl oraDdl = PlatformDdlBuilder.create(new OraclePlatform());
|
||||
private final PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServer17Platform());
|
||||
private final PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform());
|
||||
private final PlatformDdl db2LuwDdl = PlatformDdlBuilder.create(new DB2LuwPlatform());
|
||||
|
||||
{
|
||||
DatabaseConfig config = DB.getDefault().pluginApi().config();
|
||||
@@ -32,6 +34,7 @@ public class PlatformDdl_CreateIndexTest {
|
||||
oraDdl.configure(config);
|
||||
sqlServerDdl.configure(config);
|
||||
hanaDdl.configure(config);
|
||||
db2LuwDdl.configure(config);
|
||||
}
|
||||
|
||||
WriteCreateIndex writeCreateIndex() {
|
||||
@@ -71,6 +74,8 @@ public class PlatformDdl_CreateIndexTest {
|
||||
assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql);
|
||||
sql = hanaDdl.createIndex(createIndex);
|
||||
assertThat(sql).isEqualTo("-- explicit index \"ix_mytab_acol\" for single column \"acol\" of table \"mytab\" is not necessary");
|
||||
sql = db2LuwDdl.createIndex(createIndex);
|
||||
assertThat(sql).isEqualTo("create unique index ix_mytab_acol on mytab (acol)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,4 +100,13 @@ public class PlatformDdl_CreateIndexTest {
|
||||
assertEquals("create index ix_mytab_acol on mytab (acol)", sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void db2luw_fkeyCreateIndex() {
|
||||
String sql = db2LuwDdl.createIndex(fkeyCreateIndex(true));
|
||||
assertEquals("create unique index ix_mytab_acol on mytab (acol)", sql);
|
||||
|
||||
sql = db2LuwDdl.createIndex(fkeyCreateIndex(false));
|
||||
assertEquals("create index ix_mytab_acol on mytab (acol)", sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.sql.Types;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(PlatformCondition.class)
|
||||
public abstract class BaseTestCase {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(BaseTestCase.class);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package io.localtest;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.localtest.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PlatformCondition implements ExecutionCondition {
|
||||
|
||||
private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled("ForPlatform is not present");
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
Optional<AnnotatedElement> element = context.getElement();
|
||||
if (element.isPresent()) {
|
||||
final ForPlatform annotation = element.get().getAnnotation(ForPlatform.class);
|
||||
if (annotation != null && !platformMath(annotation.value())) {
|
||||
return ConditionEvaluationResult.disabled("@ForPlatform");
|
||||
}
|
||||
}
|
||||
return ENABLED;
|
||||
}
|
||||
|
||||
private boolean platformMath(Platform[] platforms) {
|
||||
Platform basePlatform = DB.getDefault().platform().base();
|
||||
for (Platform platform : platforms) {
|
||||
if (platform.equals(basePlatform)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package io.localtest.annotation;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation to run a test for a certain platform.
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
@Target(ElementType.METHOD )
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ForPlatform {
|
||||
Platform[] value();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package io.localtest.annotation;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation to ignore a test for a certain platform.
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
@Target(ElementType.METHOD )
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface IgnorePlatform {
|
||||
Platform[] value();
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package misc.migration.history.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
/**
|
||||
* detects a bug where dropHistoryTable is not applied correctly
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history7")
|
||||
@History
|
||||
public class EHistory7 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.history.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* detects a bug where dropHistoryTable is not applied correctly
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history7")
|
||||
public class EHistory7 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_assoc")
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_detail")
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_parent")
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
Integer oneKey;
|
||||
|
||||
@Size(max=127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_cascade")
|
||||
public class DfkCascade {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(onDelete = ConstraintMode.CASCADE)
|
||||
DfkCascadeOne one;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_cascade_one")
|
||||
public class DfkCascadeOne {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@OneToMany(mappedBy = "one", cascade = CascadeType.ALL)
|
||||
List<DfkCascade> details;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_none")
|
||||
public class DfkNone {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(noConstraint = true)
|
||||
DfkOne one;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_none_via_join")
|
||||
public class DfkNoneViaJoin {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "one_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
DfkOne one;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_one")
|
||||
public class DfkOne {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_set_null")
|
||||
public class DfkSetNull {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(onDelete = ConstraintMode.SET_NULL)
|
||||
DfkOne one;
|
||||
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.EnumValue;
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_basic")
|
||||
public class EBasic {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Status status;
|
||||
|
||||
@DbDefault("N")
|
||||
@NotNull
|
||||
Status status2;
|
||||
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@Size(max=127)
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
|
||||
boolean old_boolean;
|
||||
|
||||
Boolean old_boolean2;
|
||||
|
||||
@ManyToOne
|
||||
ERef eref;
|
||||
|
||||
|
||||
// test add & remove indices
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String indextest1;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest2;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest3;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest4;
|
||||
|
||||
@Index(unique = false)
|
||||
@Size(max=127)
|
||||
String indextest5;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest6;
|
||||
|
||||
@NotNull
|
||||
int user_id;
|
||||
|
||||
public EBasic() {
|
||||
|
||||
}
|
||||
|
||||
public EBasic(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getSomeDate() {
|
||||
return someDate;
|
||||
}
|
||||
|
||||
public void setSomeDate(Timestamp someDate) {
|
||||
this.someDate = someDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.EnumValue;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_enum")
|
||||
public class EEnum {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Status testStatus;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history")
|
||||
public class EHistory {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
String testString;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history2")
|
||||
@History
|
||||
public class EHistory2 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
String testString;
|
||||
|
||||
@HistoryExclude
|
||||
String obsoleteString1;
|
||||
|
||||
String obsoleteString2;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history3")
|
||||
@History
|
||||
public class EHistory3 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String testString;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history4")
|
||||
@History
|
||||
public class EHistory4 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history5")
|
||||
@History
|
||||
public class EHistory5 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history6")
|
||||
@History
|
||||
public class EHistory6 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber1;
|
||||
|
||||
@NotNull
|
||||
Integer testNumber2;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_ref")
|
||||
public class ERef {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@OneToMany
|
||||
List<EBasic> basics;
|
||||
|
||||
@NotNull
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_softdelete")
|
||||
public class ESoftdelete {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
String testString;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_c")
|
||||
public class MtmChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_m")
|
||||
public class MtmMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static io.ebean.annotation.Platform.POSTGRES;
|
||||
|
||||
@Index(platforms = POSTGRES, name = "idxd_migtest_0", definition = "create index idxd_migtest_0 on migtest_oto_child using hash (upper(name)) where upper(name) = 'JIM'")
|
||||
@Index(platforms = POSTGRES, columnNames = {"lower(name)","id"}, concurrent = true)
|
||||
@Index(platforms = POSTGRES, columnNames = "lower(name)")
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_child")
|
||||
public class OtoChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_master")
|
||||
public class OtoMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_assoc")
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_detail")
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
@ManyToOne
|
||||
// @JoinColumns({
|
||||
// @JoinColumn(name="parent_one_key", referencedColumnName="one_key"),
|
||||
// @JoinColumn(name="parent_two_key", referencedColumnName="two_key")
|
||||
// })
|
||||
CKeyParent parent;
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public CKeyParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(CKeyParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_parent")
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
CKeyAssoc assoc;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST, mappedBy = "parent")
|
||||
List<CKeyDetail> details;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public CKeyAssoc getAssoc() {
|
||||
return assoc;
|
||||
}
|
||||
|
||||
public void setAssoc(CKeyAssoc assoc) {
|
||||
this.assoc = assoc;
|
||||
}
|
||||
|
||||
public List<CKeyDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<CKeyDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void add(CKeyDetail detail) {
|
||||
if (details == null) {
|
||||
details = new ArrayList<>();
|
||||
}
|
||||
details.add(detail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
Integer oneKey;
|
||||
|
||||
@Size(max=127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_cascade")
|
||||
public class DfkCascade {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(onDelete = ConstraintMode.RESTRICT)
|
||||
DfkCascadeOne one;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_cascade_one")
|
||||
public class DfkCascadeOne {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@OneToMany(mappedBy = "one", cascade = CascadeType.ALL)
|
||||
List<DfkCascade> details;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_none")
|
||||
public class DfkNone {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(noConstraint = false)
|
||||
DfkOne one;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_none_via_join")
|
||||
public class DfkNoneViaJoin {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "one_id", foreignKey = @ForeignKey(ConstraintMode.CONSTRAINT))
|
||||
DfkOne one;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_one")
|
||||
public class DfkOne {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_set_null")
|
||||
public class DfkSetNull {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(onDelete = ConstraintMode.RESTRICT)
|
||||
DfkOne one;
|
||||
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.DbMigration;
|
||||
import io.ebean.annotation.EnumValue;
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
import io.ebean.annotation.Platform;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_basic")
|
||||
@Index(columnNames = { "status" , "indextest1"}, unique = true)
|
||||
public class EBasic {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
|
||||
@EnumValue("?")
|
||||
DONT_KNOW,
|
||||
}
|
||||
|
||||
public enum Progress {
|
||||
@EnumValue("0")
|
||||
START,
|
||||
|
||||
@EnumValue("1")
|
||||
RUN,
|
||||
|
||||
@EnumValue("2")
|
||||
END
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("A")
|
||||
Status status;
|
||||
|
||||
@Size(max=127)
|
||||
String status2;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@DbMigration(preAlter = { "-- db2 does not support parial null indices :( - so we have to clean",
|
||||
"update ${table} set status = 'N' where id = 1" }, platforms = Platform.DB2)
|
||||
@DbMigration(preAlter = "-- rename all collisions")
|
||||
@Column(unique = true)
|
||||
@Size(max = 127)
|
||||
String description;
|
||||
|
||||
//@NotNull
|
||||
//@DbDefault("2000-01-01T00:00:00") //- date time literals do not work for each platform yet
|
||||
//@DbDefault("now") //- now does not work for mariaDb
|
||||
// MariaDb requires: ALTER TABLE `migtest_e_basic` CHANGE `some_date` `some_date` DATETIME(6) NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
Timestamp someDate;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("foo'bar")
|
||||
String newStringField;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("true")
|
||||
@DbMigration(postAdd = "update ${table} set ${column} = old_boolean")
|
||||
Boolean newBooleanField;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("true")
|
||||
boolean newBooleanField2;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest1;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest2;
|
||||
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String indextest3;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest4;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest5;
|
||||
|
||||
@Index(unique = false)
|
||||
@Size(max=127)
|
||||
String indextest6;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("0")
|
||||
Progress progress;
|
||||
|
||||
@DbDefault("42")
|
||||
int newInteger;
|
||||
|
||||
@ManyToOne
|
||||
@DbMigration(preAlter= "insert into migtest_e_user (id) select distinct user_id from migtest_e_basic") // ensure all users exist
|
||||
EUser user;
|
||||
|
||||
public EBasic() {
|
||||
|
||||
}
|
||||
|
||||
public EBasic(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getSomeDate() {
|
||||
return someDate;
|
||||
}
|
||||
|
||||
public void setSomeDate(Timestamp someDate) {
|
||||
this.someDate = someDate;
|
||||
}
|
||||
|
||||
public String getNewStringField() {
|
||||
return newStringField;
|
||||
}
|
||||
|
||||
public void setNewStringField(String newStringField) {
|
||||
this.newStringField = newStringField;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_enum")
|
||||
public class EEnum {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Size (max = 1)
|
||||
String testStatus; // change to String from Enum Status
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.annotation.DbComment;
|
||||
import io.ebean.annotation.DbMigration;
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history")
|
||||
@History
|
||||
@DbComment("We have history now")
|
||||
public class EHistory {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@DbComment("Column altered to long now")
|
||||
@DbMigration(platforms = Platform.POSTGRES,
|
||||
preAlter = "alter table ${table} alter column ${column} TYPE bigint USING (${column}::integer)")
|
||||
Long testString;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history2")
|
||||
@History
|
||||
public class EHistory2 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("unknown")
|
||||
String testString;
|
||||
|
||||
@HistoryExclude
|
||||
String testString2;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("unknown")
|
||||
String testString3;
|
||||
|
||||
@Size(max = 20)
|
||||
String newColumn;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history3")
|
||||
@History
|
||||
public class EHistory3 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@HistoryExclude
|
||||
String testString;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history4")
|
||||
@History
|
||||
public class EHistory4 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Long testNumber;
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history5")
|
||||
@History
|
||||
public class EHistory5 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("false")
|
||||
Boolean testBoolean;
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history6")
|
||||
@History
|
||||
public class EHistory6 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("42")
|
||||
Integer testNumber1;
|
||||
|
||||
|
||||
Integer testNumber2;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_softdelete")
|
||||
public class ESoftdelete {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
String testString;
|
||||
|
||||
@SoftDelete
|
||||
boolean deleted;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_user")
|
||||
public class EUser {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_c")
|
||||
public class MtmChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany
|
||||
List<MtmMaster> masters;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<MtmMaster> getMasters() {
|
||||
return masters;
|
||||
}
|
||||
|
||||
public void setMasters(List<MtmMaster> masters) {
|
||||
this.masters = masters;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_m")
|
||||
public class MtmMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany
|
||||
List<MtmChild> children;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<MtmChild> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<MtmChild> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static io.ebean.annotation.Platform.POSTGRES;
|
||||
|
||||
@Index(columnNames = "name", platforms = POSTGRES)
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_child")
|
||||
public class OtoChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToOne
|
||||
OtoMaster master;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OtoMaster getMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public void setMaster(OtoMaster master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_master")
|
||||
public class OtoMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "master")
|
||||
OtoChild child;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OtoChild getChild() {
|
||||
return child;
|
||||
}
|
||||
|
||||
public void setChild(OtoChild child) {
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_assoc")
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_detail")
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_ckey_parent")
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
Integer oneKey;
|
||||
|
||||
@Size(max=127)
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_cascade")
|
||||
public class DfkCascade {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(onDelete = ConstraintMode.CASCADE)
|
||||
DfkCascadeOne one;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_cascade_one")
|
||||
public class DfkCascadeOne {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@OneToMany(mappedBy = "one", cascade = CascadeType.ALL)
|
||||
List<DfkCascade> details;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_none")
|
||||
public class DfkNone {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(noConstraint = true)
|
||||
DfkOne one;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.ConstraintMode;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_none_via_join")
|
||||
public class DfkNoneViaJoin {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "one_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
DfkOne one;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_one")
|
||||
public class DfkOne {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import io.ebean.annotation.ConstraintMode;
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_fk_set_null")
|
||||
public class DfkSetNull {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
@DbForeignKey(onDelete = ConstraintMode.SET_NULL)
|
||||
DfkOne one;
|
||||
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.EnumValue;
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_basic")
|
||||
public class EBasic {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Status status;
|
||||
|
||||
@DbDefault("N")
|
||||
@NotNull
|
||||
Status status2;
|
||||
|
||||
@Size(max=127)
|
||||
String name;
|
||||
|
||||
@Size(max=127)
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
|
||||
boolean old_boolean;
|
||||
|
||||
Boolean old_boolean2;
|
||||
|
||||
@ManyToOne
|
||||
ERef eref;
|
||||
|
||||
|
||||
// test add & remove indices
|
||||
@Index
|
||||
@Size(max=127)
|
||||
String indextest1;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest2;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest3;
|
||||
|
||||
@Size(max=127)
|
||||
String indextest4;
|
||||
|
||||
@Index(unique = false)
|
||||
@Size(max=127)
|
||||
String indextest5;
|
||||
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String indextest6;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("23")
|
||||
int user_id;
|
||||
|
||||
public EBasic() {
|
||||
|
||||
}
|
||||
|
||||
public EBasic(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getSomeDate() {
|
||||
return someDate;
|
||||
}
|
||||
|
||||
public void setSomeDate(Timestamp someDate) {
|
||||
this.someDate = someDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.EnumValue;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_enum")
|
||||
public class EEnum {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Status testStatus;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history")
|
||||
public class EHistory {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
Long testString; // keep it as long as history prevents altering
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history2")
|
||||
@History
|
||||
public class EHistory2 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
String testString;
|
||||
|
||||
@HistoryExclude
|
||||
String obsoleteString1;
|
||||
|
||||
String obsoleteString2;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history3")
|
||||
@History
|
||||
public class EHistory3 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String testString;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history4")
|
||||
@History
|
||||
public class EHistory4 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history5")
|
||||
@History
|
||||
public class EHistory5 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history6")
|
||||
@History
|
||||
public class EHistory6 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber1;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("7")
|
||||
Integer testNumber2;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_ref")
|
||||
public class ERef {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@OneToMany
|
||||
List<EBasic> basics;
|
||||
|
||||
@NotNull
|
||||
@Index(unique = true)
|
||||
@Size(max=127)
|
||||
String name;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_softdelete")
|
||||
public class ESoftdelete {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
String testString;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_c")
|
||||
public class MtmChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_mtm_m")
|
||||
public class MtmMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static io.ebean.annotation.Platform.MYSQL;
|
||||
import static io.ebean.annotation.Platform.POSTGRES;
|
||||
|
||||
@Index(name = "ix_m12_otoc71", columnNames = "name", platforms = {POSTGRES})
|
||||
@Index(name = "ix_m12_otoc72", columnNames = "name", platforms = {MYSQL})
|
||||
@Index(unique = true, name = "uq_m12_otoc71", columnNames = "lower(name)", platforms = {POSTGRES})
|
||||
@Index(unique = true, name = "uq_m12_otoc72", columnNames = "name", platforms = {MYSQL})
|
||||
@Index(columnNames = "name", platforms = POSTGRES)
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_child")
|
||||
public class OtoChild {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static io.ebean.annotation.Platform.MYSQL;
|
||||
import static io.ebean.annotation.Platform.POSTGRES;
|
||||
|
||||
@Index(columnNames = "name", platforms = {MYSQL})
|
||||
@Index(unique = true, columnNames = "lower(name)", platforms = {POSTGRES})
|
||||
@Index(unique = true, columnNames = "name", platforms = {MYSQL})
|
||||
@Entity
|
||||
@Table(name = "migtest_oto_master")
|
||||
public class OtoMaster {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ datasource.default=h2
|
||||
|
||||
datasource.h2.username=sa
|
||||
datasource.h2.password=
|
||||
datasource.h2.url=jdbc:h2:mem:h2AutoTune
|
||||
datasource.h2.url=jdbc:h2:mem:h2AutoTune;NON_KEYWORDS=KEY,VALUE
|
||||
|
||||
datasource.db2.username=migtest
|
||||
datasource.db2.password=migtest
|
||||
@@ -15,36 +15,4 @@ datasource.pg.username=sa
|
||||
datasource.pg.password=
|
||||
datasource.pg.url=jdbc:h2:mem:h2AutoTune
|
||||
|
||||
# parameters for migration test
|
||||
datasource.migrationtest.username=SA
|
||||
datasource.migrationtest.password=SA
|
||||
datasource.migrationtest.url=jdbc:h2:mem:migration
|
||||
ebean.migrationtest.applyPrefix=V
|
||||
ebean.migrationtest.ddl.generate=false
|
||||
ebean.migrationtest.ddl.run=false
|
||||
ebean.migrationtest.ddl.header=-- Migrationscripts for ebean unittest
|
||||
ebean.migrationtest.migration.appName=migrationtest
|
||||
ebean.migrationtest.migration.migrationPath=dbmigration/migrationtest
|
||||
ebean.migrationtest.migration.strict=true
|
||||
ebean.migrationtest.migration.generate=true
|
||||
ebean.migrationtest.migration.run=true
|
||||
ebean.migrationtest.migration.includeIndex=true
|
||||
ebean.migrationtest.migration.generateInit=true
|
||||
ebean.migrationtest.migration.generatePendingDrop=auto
|
||||
ebean.migrationtest.migration.platforms=db2,h2,hsqldb,mysql,mysql55=mysql55,postgres,oracle,sqlite,sqlserver17=sqlserver17,hana
|
||||
|
||||
# need to generate unique statements to prevent them from being filtered out as duplicates by the DdlRunner
|
||||
ebean.hana.generateUniqueDdl=true
|
||||
|
||||
|
||||
# parameters for migration test
|
||||
datasource.migrationtest-history.username=SA
|
||||
datasource.migrationtest-history.password=SA
|
||||
datasource.migrationtest-history.url=jdbc:h2:mem:migration
|
||||
ebean.migrationtest-history.applyPrefix=V
|
||||
ebean.migrationtest-history.ddl.generate=false
|
||||
ebean.migrationtest-history.ddl.run=false
|
||||
ebean.migrationtest-history.ddl.header=-- Migrationscripts for ebean unittest DbMigrationDropHistoryTest
|
||||
ebean.migrationtest-history.migration.appName=migrationtest-history
|
||||
ebean.migrationtest-history.migration.migrationPath=dbmigration/migrationtest-history
|
||||
ebean.migrationtest-history.migration.strict=true
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_user (
|
||||
id integer generated by default as identity not null,
|
||||
constraint pk_migtest_e_user primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_c_migtest_mtm_m (
|
||||
migtest_mtm_c_id integer not null,
|
||||
migtest_mtm_m_id bigint not null,
|
||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
||||
);
|
||||
|
||||
create table migtest_mtm_m_migtest_mtm_c (
|
||||
migtest_mtm_m_id bigint not null,
|
||||
migtest_mtm_c_id integer not null,
|
||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
||||
);
|
||||
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_mgtst_ck_e1qkb5 foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
|
||||
alter table migtest_ckey_parent add column assoc_id integer;
|
||||
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
|
||||
alter table migtest_fk_none add constraint fk_mgtst_fk_nn_n_d foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_9tknzj foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x;
|
||||
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts;
|
||||
alter table migtest_e_basic alter column status set default 'A';
|
||||
alter table migtest_e_basic alter column status set not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(127);
|
||||
alter table migtest_e_basic alter column status2 drop default;
|
||||
alter table migtest_e_basic alter column status2 drop not null;
|
||||
|
||||
-- rename all collisions;
|
||||
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_mgtst__bsc_sr_d foreign key (user_id) references migtest_e_user (id) on delete restrict;
|
||||
alter table migtest_e_basic alter column user_id drop not null;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02;
|
||||
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok;
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history alter column test_string set data type bigint;
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
||||
alter table migtest_e_history2 alter column test_string set not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
||||
alter table migtest_e_history2 add column new_column varchar(20);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 drop not null;
|
||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3);
|
||||
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
|
||||
drop index ix_mgtst__b_eu8csq;
|
||||
drop index ix_mgtst__b_eu8csu;
|
||||
create index ix_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
|
||||
|
||||
create index ix_mgtst_ck_x45o21 on migtest_ckey_parent (assoc_id);
|
||||
alter table migtest_ckey_parent add constraint fk_mgtst_ck_da00mr foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict;
|
||||
|
||||
alter table migtest_oto_child add constraint fk_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict;
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_ref (
|
||||
id integer generated by default as identity not null,
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
|
||||
|
||||
alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5;
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d;
|
||||
alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj;
|
||||
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x;
|
||||
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete set null;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts;
|
||||
alter table migtest_e_basic alter column status drop default;
|
||||
alter table migtest_e_basic alter column status drop not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I'));
|
||||
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(1);
|
||||
alter table migtest_e_basic alter column status2 set default 'N';
|
||||
alter table migtest_e_basic alter column status2 set not null;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo;
|
||||
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d;
|
||||
alter table migtest_e_basic alter column user_id set default 23;
|
||||
alter table migtest_e_basic alter column user_id set not null;
|
||||
alter table migtest_e_basic add column old_boolean boolean default false not null;
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01;
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok;
|
||||
alter table migtest_e_enum add constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 alter column test_string drop default;
|
||||
alter table migtest_e_history2 alter column test_string drop not null;
|
||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number set data type integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 drop not null;
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
|
||||
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
|
||||
drop index ix_mgtst__b_eu8css;
|
||||
drop index ix_mgtst__b_eu8csv;
|
||||
create index ix_mgtst__bsc_rf_d on migtest_e_basic (eref_id);
|
||||
alter table migtest_e_basic add constraint fk_mgtst__bsc_rf_d foreign key (eref_id) references migtest_e_ref (id) on delete restrict;
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
1580812656, 1.0__initial.sql
|
||||
312838996, 1.1.sql
|
||||
1091886546, 1.2__dropsFor_1.1.sql
|
||||
-1041850370, 1.3.sql
|
||||
2020621716, 1.4__dropsFor_1.3.sql
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
-745768926, 1.0__initial.sql
|
||||
39858255, 1.1.sql
|
||||
1616986842, 1.2__dropsFor_1.1.sql
|
||||
-1513154593, 1.3.sql
|
||||
374569329, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
-1536923954, 1.0__initial.sql
|
||||
1039838314, 1.1.sql
|
||||
562867593, 1.2__dropsFor_1.1.sql
|
||||
1566488731, 1.3.sql
|
||||
1030652294, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
2097980375, 1.0__initial.sql
|
||||
2086418403, 1.1.sql
|
||||
-1462014216, 1.2__dropsFor_1.1.sql
|
||||
-2039573992, 1.3.sql
|
||||
2106151405, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
1075178692, 1.0__initial.sql
|
||||
880212944, 1.1.sql
|
||||
1029390755, 1.2__dropsFor_1.1.sql
|
||||
-380371830, 1.3.sql
|
||||
1085680731, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
-1087663151, 1.0__initial.sql
|
||||
880212944, 1.1.sql
|
||||
1029390755, 1.2__dropsFor_1.1.sql
|
||||
-380371830, 1.3.sql
|
||||
1085680731, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
1164675950, 1.0__initial.sql
|
||||
-1916315387, 1.1.sql
|
||||
238598298, 1.2__dropsFor_1.1.sql
|
||||
483114276, 1.3.sql
|
||||
1213528478, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
1329543701, 1.0__initial.sql
|
||||
-1877647184, 1.1.sql
|
||||
-1861367028, 1.2__dropsFor_1.1.sql
|
||||
-1798982281, 1.3.sql
|
||||
1959776888, 1.4__dropsFor_1.3.sql
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
1429491518, 1.0__initial.sql
|
||||
-347121868, 1.1.sql
|
||||
1359055889, 1.2__dropsFor_1.1.sql
|
||||
-1764531063, 1.3.sql
|
||||
-1070218324, 1.4__dropsFor_1.3.sql
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<createTable name="migtest_e_basic" pkName="pk_migtest_e_basic">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="status" type="varchar(1)" checkConstraint="check ( status in ('N','A','I'))" checkConstraintName="ck_migtest_e_basic_status"/>
|
||||
<column name="status2" type="varchar(1)" defaultValue="'N'" notnull="true" checkConstraint="check ( status2 in ('N','A','I'))" checkConstraintName="ck_migtest_e_basic_status2"/>
|
||||
<column name="name" type="varchar(127)"/>
|
||||
<column name="description" type="varchar(127)"/>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@@ -1,11 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
create table migtest_e_basic (
|
||||
id integer auto_increment not null,
|
||||
status varchar(1),
|
||||
status2 varchar(1) default 'N' not null,
|
||||
name varchar(127),
|
||||
description varchar(127),
|
||||
constraint pk_migtest_e_basic primary key (id)
|
||||
);
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
-- Migrationscripts for ebean unittest
|
||||
-- apply changes
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'status2');
|
||||
|
||||
CALL usp_ebean_drop_column('migtest_e_basic', 'description');
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
-- Inital script to create stored procedures etc for mysql platform
|
||||
DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys;
|
||||
|
||||
delimiter $$
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
|
||||
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
|
||||
--
|
||||
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
|
||||
BEGIN
|
||||
DECLARE done INT DEFAULT FALSE;
|
||||
DECLARE c_fk_name CHAR(255);
|
||||
DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
|
||||
WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name
|
||||
AND REFERENCED_TABLE_NAME IS NOT NULL;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
|
||||
OPEN curs;
|
||||
|
||||
read_loop: LOOP
|
||||
FETCH curs INTO c_fk_name;
|
||||
IF done THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
END LOOP;
|
||||
|
||||
CLOSE curs;
|
||||
END
|
||||
$$
|
||||
|
||||
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
|
||||
|
||||
delimiter $$
|
||||
--
|
||||
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
|
||||
-- deletes the column and ensures that all indices and constraints are dropped first
|
||||
--
|
||||
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
|
||||
BEGIN
|
||||
CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
|
||||
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
END
|
||||
$$
|
||||
@@ -1,4 +0,0 @@
|
||||
1835064798, I__create_procs.sql
|
||||
1968521526, 1.0__initial.sql
|
||||
-728933533, 1.2__dropsFor_1.1.sql
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user