Moved DbMigrationtests test to "ebean-tests"

This commit is contained in:
Roland Praml committed 2022-02-07 11:55:41 +01:00
1 parent 05ad6da7e6
commit a93e2e05c5
210 files changed
+8956 -2590

No files matched your search

@@ -1,90 +0,0 @@
package io.ebeaninternal.dbmigration;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* This is the Migrationscript generator. It generates 3 migrationscript for the models
* @author Roland Praml, FOCONIS AG
*
*/
public class DbMigrationDropHistoryTest {
private static final Logger logger = LoggerFactory.getLogger(DbMigrationDropHistoryTest.class);
@Test
public void invokeTest() throws IOException {
main(null);
}
public static void main(String[] args) throws IOException {
logger.info("start");
DefaultDbMigration migration = new DefaultDbMigration();
// We use src/test/resources as output directory (so we see in GIT if files will change)
migration.setPathToResources("src/test/resources");
DatabaseConfig config = new DatabaseConfig();
config.setName("migrationtest-history");
config.loadFromProperties();
config.setRegister(false);
config.setDefaultServer(false);
config.setPackages(Arrays.asList("misc.migration.history.v1_0"));
Database server = DatabaseFactory.create(config);
migration.setServer(server);
// First, we clean up the output-directory
assertThat(migration.migrationDirectory().getAbsolutePath()).contains("migrationtest-history");
Files.walk(migration.migrationDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
// then we generate migration scripts for v1_0
assertThat(migration.generateMigration()).isEqualTo("1.0__initial");
// and we check repeatative calls
assertThat(migration.generateMigration()).isNull();
// and now for v1_1
config.setPackages(Arrays.asList("misc.migration.history.v1_1"));
server.shutdown();
server = DatabaseFactory.create(config);
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.1");
assertThat(migration.generateMigration()).isNull(); // subsequent call
List<String> pendingDrops = migration.getPendingDrops();
assertThat(pendingDrops).contains("1.1");
//System.setProperty("ddl.migration.pendingDropsFor", "1.1");
migration.setGeneratePendingDrop("1.1");
assertThat(migration.generateMigration()).isEqualTo("1.2__dropsFor_1.1");
assertThatThrownBy(()->migration.generateMigration())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("No 'pendingDrops'"); // subsequent call
System.clearProperty("ddl.migration.pendingDropsFor");
server.shutdown();
logger.info("end");
}
}
@@ -1,126 +0,0 @@
package io.ebeaninternal.dbmigration;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* This is the Migrationscript generator. It generates 3 migrationscript for the models
* @author Roland Praml, FOCONIS AG
*
*/
public class DbMigrationGenerateTest {
private static final Logger logger = LoggerFactory.getLogger(DbMigrationGenerateTest.class);
public static void main(String[] args) throws IOException {
run("ebean-ddl-generator/src/test/resources");
}
@Test
public void invokeTest() throws IOException {
run("src/test/resources");
}
public static void run(String pathToResources) throws IOException {
logger.info("start current directory: " + new File(".").getAbsolutePath());
DefaultDbMigration migration = new DefaultDbMigration();
migration.setIncludeIndex(true);
// We use src/test/resources as output directory (so we see in GIT if files will change)
migration.setPathToResources(pathToResources);
migration.setMigrationPath("db/migration");
migration.setMigrationPath(null); // use the default for this test
// migration.addPlatform(Platform.GENERIC, "generic"); there is no ddl handler for generic
// migration.addPlatform(Platform.SQLANYWHERE, "sqlanywhere"); and sqlanywhere
migration.addPlatform(Platform.DB2);
migration.addPlatform(Platform.H2);
migration.addPlatform(Platform.HSQLDB, "hsqldb");
migration.addPlatform(Platform.MYSQL, "mysql");
migration.addPlatform(Platform.MYSQL55, "mysql55");
migration.addPlatform(Platform.POSTGRES);
migration.addPlatform(Platform.ORACLE);
migration.addPlatform(Platform.SQLITE);
migration.addPlatform(Platform.SQLSERVER17, "sqlserver17");
migration.addPlatform(Platform.HANA);
DatabaseConfig config = new DatabaseConfig();
config.setName("migrationtest");
config.loadFromProperties();
config.setRegister(false);
config.setDefaultServer(false);
config.getProperties().put("ebean.hana.generateUniqueDdl", "true"); // need to generate unique statements to prevent them from being filtered out as duplicates by the DdlRunner
config.setPackages(Arrays.asList("misc.migration.v1_0"));
Database server = DatabaseFactory.create(config);
migration.setServer(server);
// First, we clean up the output-directory
assertThat(migration.migrationDirectory().getAbsolutePath()).contains("migrationtest");
Files.walk(migration.migrationDirectory().toPath())
.filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
// then we generate migration scripts for v1_0
assertThat(migration.generateMigration()).isEqualTo("1.0__initial");
// and we check repeatative calls
assertThat(migration.generateMigration()).isNull();
// and now for v1_1
config.setPackages(Arrays.asList("misc.migration.v1_1"));
server.shutdown();
server = DatabaseFactory.create(config);
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.1");
assertThat(migration.generateMigration()).isNull(); // subsequent call
System.setProperty("ddl.migration.pendingDropsFor", "1.1");
assertThat(migration.generateMigration()).isEqualTo("1.2__dropsFor_1.1");
assertThatThrownBy(()->migration.generateMigration())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("No 'pendingDrops'"); // subsequent call
System.clearProperty("ddl.migration.pendingDropsFor");
assertThat(migration.generateMigration()).isNull(); // subsequent call
// and now for v1_2 with
config.setPackages(Arrays.asList("misc.migration.v1_2"));
server.shutdown();
server = DatabaseFactory.create(config);
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.3");
assertThat(migration.generateMigration()).isNull(); // subsequent call
System.setProperty("ddl.migration.pendingDropsFor", "1.3");
assertThat(migration.generateMigration()).isEqualTo("1.4__dropsFor_1.3");
assertThatThrownBy(migration::generateMigration)
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("No 'pendingDrops'"); // subsequent call
System.clearProperty("ddl.migration.pendingDropsFor");
assertThat(migration.generateMigration()).isNull(); // subsequent call
server.shutdown();
logger.info("end");
}
}
@@ -1,191 +0,0 @@
package io.ebeaninternal.dbmigration;
import io.localtest.BaseTestCase;
import io.ebean.SqlRow;
import io.ebean.SqlUpdate;
import io.localtest.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import io.ebeaninternal.dbmigration.ddlgeneration.Helper;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class DbMigrationTest extends BaseTestCase {
private void runScript(boolean expectErrors, String scriptName) throws IOException {
String ddl = Helper.asText(this, "/dbmigration/migrationtest/" + server().platform().name().toLowerCase() + "/" + scriptName);
runScript(expectErrors, ddl, scriptName);
}
private void runScript(boolean useAutoCommit, String content, String scriptName) {
server().script().runScript(scriptName, content, useAutoCommit);
}
@IgnorePlatform({Platform.ORACLE, Platform.NUODB, Platform.MARIADB})
@Test
public void testRunMigration() throws IOException {
// first clean up previously created objects
cleanup("migtest_ckey_assoc",
"migtest_ckey_detail",
"migtest_ckey_parent",
"migtest_e_basic",
"migtest_e_enum",
"migtest_e_history",
"migtest_e_history2",
"migtest_e_history3",
"migtest_e_history4",
"migtest_e_history5",
"migtest_e_history6",
"migtest_e_ref",
"migtest_e_softdelete",
"migtest_e_user",
"migtest_fk_cascade",
"migtest_fk_cascade_one",
"migtest_fk_none",
"migtest_fk_none_via_join",
"migtest_fk_one",
"migtest_fk_set_null",
"migtest_mtm_c",
"migtest_mtm_m",
"migtest_mtm_c_migtest_mtm_m",
"migtest_mtm_m_migtest_mtm_c",
"migtest_oto_child",
"migtest_oto_master");
if (isSqlServer()) { // || isMySql()
runScript(false, "I__create_procs.sql");
}
runScript(false, "1.0__initial.sql");
if (isOracle() || isHana()) {
SqlUpdate update = server().sqlUpdate("insert into migtest_e_basic (id, old_boolean, user_id) values (1, :false, 1)");
update.setParameter("false", false);
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("insert into migtest_e_basic (id, old_boolean, user_id) values (2, :true, 1)");
update.setParameter("true", true);
assertThat(server().execute(update)).isEqualTo(1);
} else {
SqlUpdate update = server().sqlUpdate("insert into migtest_e_basic (id, old_boolean, user_id) values (1, :false, 1), (2, :true, 1)");
update.setParameter("false", false);
update.setParameter("true", true);
assertThat(server().execute(update)).isEqualTo(2);
}
createHistoryEntities();
// Run migration
runScript(false, "1.1.sql");
List<SqlRow> result = server().sqlQuery("select * from migtest_e_basic order by id").findList();
assertThat(result).hasSize(2);
SqlRow row = result.get(0);
assertThat(row.keySet()).contains("old_boolean", "old_boolean2");
assertThat(row.getInteger("id")).isEqualTo(1);
assertThat(row.getBoolean("old_boolean")).isFalse();
assertThat(row.getBoolean("new_boolean_field")).isFalse(); // test if update old_boolean -> new_boolean_field works well
assertThat(row.getString("new_string_field")).isEqualTo("foo'bar");
assertThat(row.getBoolean("new_boolean_field2")).isTrue();
//assertThat(row.getTimestamp("some_date")).isCloseTo(new Date(), 86_000); // allow 1 minute delta
row = result.get(1);
assertThat(row.getInteger("id")).isEqualTo(2);
assertThat(row.getBoolean("old_boolean")).isTrue();
assertThat(row.getBoolean("new_boolean_field")).isTrue(); // test if update old_boolean -> new_boolean_field works well
assertThat(row.getString("new_string_field")).isEqualTo("foo'bar");
assertThat(row.getBoolean("new_boolean_field2")).isTrue();
//assertThat(row.getTimestamp("some_date")).isCloseTo(new Date(), 60_000); // allow 1 minute delta
runScript(false, "1.2__dropsFor_1.1.sql");
// Oracle caches the statement and does not detect schema change. It fails with
// an ORA-01007
if (isOracle()) {
result = server().sqlQuery("select * from migtest_e_basic order by id,id").findList();
} else {
result = server().sqlQuery("select * from migtest_e_basic order by id").findList();
}
assertThat(result).hasSize(2);
row = result.get(0);
assertThat(row.keySet()).doesNotContain("old_boolean", "old_boolean2");
runScript(false, "1.3.sql");
runScript(false, "1.4__dropsFor_1.3.sql");
// now DB structure shoud be the same as v1_0
result = server().sqlQuery("select * from migtest_e_basic order by id").findList();
assertThat(result).hasSize(2);
row = result.get(0);
assertThat(row.keySet()).contains("old_boolean", "old_boolean2");
}
/**
*
*/
private void createHistoryEntities() {
SqlUpdate update = server().sqlUpdate("insert into migtest_e_history (id, test_string) values (1, '42')");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("update migtest_e_history set test_string = '45' where id = 1");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("insert into migtest_e_history2 (id, test_string, obsolete_string1, obsolete_string2) values (1, 'foo', 'bar', null)");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("update migtest_e_history2 set test_string = 'baz' where id = 1");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("insert into migtest_e_history3 (id, test_string) values (1, '42')");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("update migtest_e_history3 set test_string = '45' where id = 1");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("insert into migtest_e_history4 (id, test_number) values (1, 42)");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("update migtest_e_history4 set test_number = 45 where id = 1");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("insert into migtest_e_history5 (id, test_number) values (1, 42)");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("update migtest_e_history5 set test_number = 45 where id = 1");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("insert into migtest_e_history6 (id, test_number1, test_number2) values (1, 2, 7)");
assertThat(server().execute(update)).isEqualTo(1);
update = server().sqlUpdate("update migtest_e_history6 set test_number2 = 45 where id = 1");
assertThat(server().execute(update)).isEqualTo(1);
}
private void cleanup(String ... tables) {
final boolean sqlServer = isSqlServer();
final boolean postgres = isPostgres();
StringBuilder sb = new StringBuilder();
for (String table : tables) {
// simple and stupid try to execute all commands on all dialects.
if (sqlServer) {
sb.append("alter table ").append(table).append(" set ( system_versioning = OFF );\n");
sb.append("alter table ").append(table).append(" drop system versioning;\n");
}
if (postgres) {
sb.append("drop table ").append(table).append(" cascade;\n");
sb.append("drop table ").append(table).append("_history cascade;\n");
} else {
sb.append("drop table ").append(table).append(";\n");
sb.append("drop table ").append(table).append("_history;\n");
}
sb.append("drop view ").append(table).append("_with_history;\n");
sb.append("drop sequence ").append(table).append("_seq;\n");
}
runScript(true, sb.toString(), "cleanup");
runScript(true, sb.toString(), "cleanup");
}
}
@@ -1,85 +0,0 @@
package io.ebeaninternal.dbmigration;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.PlatformConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Class to test the alternative drop behaviour using stored procedures for MySql databases .
*
* @author Jonas P&ouml;hler, FOCONIS AG
*/
public class MysqlGenerateMigrationTest {
@AfterEach
public void resetPendingDropsProperty() {
System.clearProperty("ddl.migration.pendingDropsFor");
}
@Test
public void testMysqlStoredProcedures() throws Exception {
DefaultDbMigration migration = new DefaultDbMigration();
migration.setIncludeIndex(true);
// We use src/test/resources as output directory (so we see in GIT if files will change)
migration.setPathToResources("src/test/resources");
migration.addPlatform(Platform.MYSQL, "mysql");
final PlatformConfig platformConfig = new PlatformConfig();
platformConfig.setUseMigrationStoredProcedures(true);
DatabaseConfig config = new DatabaseConfig();
config.setName("migrationtest");
config.loadFromProperties();
config.setPlatformConfig(platformConfig);
config.setRegister(false);
config.setDefaultServer(false);
config.getProperties().put("ebean.migration.migrationPath", "db/migration/mysql");
config.setPackages(Arrays.asList("misc.migration.mysql_v1_0"));
Database server = DatabaseFactory.create(config);
migration.setServer(server);
migration.setMigrationPath("mysql/procedures");
// First, we clean up the output-directory
assertThat(migration.migrationDirectory().getAbsolutePath()).contains("procedures");
Files.walk(migration.migrationDirectory().toPath())
.filter(Files::isRegularFile)
.map(Path::toFile).forEach(File::delete);
// then we generate migration scripts for v1_0
assertThat(migration.generateMigration()).isEqualTo("1.0__initial");
config.setPackages(Arrays.asList("misc.migration.mysql_v1_1"));
server.shutdown();
server = DatabaseFactory.create(config);
migration.setServer(server);
migration.setMigrationPath("mysql/procedures");
assertThat(migration.generateMigration()).isEqualTo("1.1");
System.setProperty("ddl.migration.pendingDropsFor", "1.1");
assertThat(migration.generateMigration()).isEqualTo("1.2__dropsFor_1.1");
final Path sqlFile = migration.migrationDirectory().toPath()
.resolve("mysql/1.2__dropsFor_1.1.sql");
assertThat(sqlFile).isNotEmptyFile();
assertThat(Files.readAllLines(sqlFile, StandardCharsets.UTF_8))
.contains("CALL usp_ebean_drop_column('migtest_e_basic', 'status2');")
.contains("CALL usp_ebean_drop_column('migtest_e_basic', 'description');");
}
}
@@ -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,89 +0,0 @@
package misc.migration.mysql_v1_0;
import io.ebean.annotation.DbDefault;
import io.ebean.annotation.EnumValue;
import io.ebean.annotation.NotNull;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
@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;
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 Status getStatus2() {
return status2;
}
public void setStatus2(final Status status2) {
this.status2 = status2;
}
}
@@ -1,64 +0,0 @@
package misc.migration.mysql_v1_1;
import io.ebean.annotation.EnumValue;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
@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;
@Size(max=127)
String name;
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;
}
}
@@ -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,175 +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 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 = "-- 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;
}
}