From 13f69b058de5102574473e924704bde27e169a5f Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 23 Nov 2023 08:01:52 +0100 Subject: [PATCH 01/18] removed old migration code --- .../ebean/migration/JdbcMigrationFactory.java | 5 +- .../io/ebean/migration/MigrationConfig.java | 15 +--- .../runner/LocalMigrationResources.java | 74 +++---------------- 3 files changed, 12 insertions(+), 82 deletions(-) diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java index a5eabe3..9dc8d42 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java @@ -7,8 +7,5 @@ */ public interface JdbcMigrationFactory { - /** - * Create a JDBC based migration given the class name. - */ - JdbcMigration createInstance(String className); + // will be reused later } diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java index d33696f..67a56e3 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java @@ -611,25 +611,12 @@ public void setFastMode(boolean fastMode) { } /** - * Default factory. Uses the migration's class loader and injects the config if necessary. + * Default factory. TBD * * @author Roland Praml, FOCONIS AG */ public class DefaultMigrationFactory implements JdbcMigrationFactory { - @Override - public JdbcMigration createInstance(String className) { - try { - Class clazz = Class.forName(className, true, MigrationConfig.this.getClassLoader()); - JdbcMigration migration = (JdbcMigration) clazz.getDeclaredConstructor().newInstance(); - if (migration instanceof ConfigurationAware) { - ((ConfigurationAware) migration).setMigrationConfig(MigrationConfig.this); - } - return migration; - } catch (Exception e) { - throw new IllegalArgumentException(className + " is not a valid JdbcMigration", e); - } - } } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index cd605bb..4761be5 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -2,7 +2,6 @@ import io.avaje.classpath.scanner.Resource; import io.avaje.classpath.scanner.core.Scanner; -import io.ebean.migration.JdbcMigration; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationVersion; @@ -11,7 +10,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.function.Predicate; import static java.lang.System.Logger.Level.DEBUG; @@ -25,7 +23,6 @@ final class LocalMigrationResources { private final List versions = new ArrayList<>(); private final MigrationConfig migrationConfig; private final ClassLoader classLoader; - private final boolean searchForJdbcMigrations; /** * Construct with configuration options. @@ -33,7 +30,6 @@ final class LocalMigrationResources { LocalMigrationResources(MigrationConfig migrationConfig) { this.migrationConfig = migrationConfig; this.classLoader = migrationConfig.getClassLoader(); - this.searchForJdbcMigrations = migrationConfig.getJdbcMigrationFactory() != null; } /** @@ -114,7 +110,7 @@ private boolean readResourcesForPath(String path) { if (platform != null && loadedFrom(path, platform)) { return true; } - addResources(scanForBoth(path)); + addResources(scanForMigrations(path)); Collections.sort(versions); return !versions.isEmpty(); } @@ -123,65 +119,41 @@ private boolean readResourcesForPath(String path) { * Return true if migrations were loaded from platform specific location. */ private boolean loadedFrom(String path, String platform) { - addResources(scanForBoth(path + "/" + platform)); + addResources(scanForMigrations(path + "/" + platform)); if (versions.isEmpty()) { return false; } log.log(DEBUG, "platform migrations for {0}", platform); - if (searchForJdbcMigrations) { - addResources(scanForJdbcOnly(path)); - } Collections.sort(versions); return true; } /** - * Scan only for JDBC migrations. + * Scan for SQL migrations. */ - private List scanForJdbcOnly(String path) { - return new Scanner(classLoader).scanForResources(path, new JdbcOnly()); + private List scanForMigrations(String path) { + return new Scanner(classLoader).scanForResources(path, name -> name.endsWith(".sql")); } /** - * Scan for both SQL and JDBC migrations. + * adds the script migrations found from classpath scan. */ - private List scanForBoth(String path) { - return new Scanner(classLoader).scanForResources(path, new Match(searchForJdbcMigrations)); - } - private void addResources(List resourceList) { if (!resourceList.isEmpty()) { log.log(DEBUG, "resources: {0}", resourceList); } for (Resource resource : resourceList) { String filename = resource.name(); - if (filename.endsWith(".sql")) { - versions.add(createScriptMigration(resource, filename)); - } else if (searchForJdbcMigrations && filename.endsWith(".class")) { - versions.add(createJdbcMigration(resource, filename)); - } + assert filename.endsWith(".sql"); + String mainName = filename.substring(0, filename.length() - 4); + versions.add(createScriptMigration(resource, mainName)); } } - /** - * Return a programmatic JDBC migration. - */ - private LocalMigrationResource createJdbcMigration(Resource resource, String filename) { - int pos = filename.lastIndexOf(".class"); - String mainName = filename.substring(0, pos); - MigrationVersion migrationVersion = MigrationVersion.parse(mainName); - String className = resource.location().replace('/', '.'); - className = className.substring(0, className.length() - 6); - JdbcMigration instance = migrationConfig.getJdbcMigrationFactory().createInstance(className); - return new LocalJdbcMigrationResource(migrationVersion, resource.location(), instance); - } - /** * Create a script based migration. */ - private LocalMigrationResource createScriptMigration(Resource resource, String filename) { - int pos = filename.lastIndexOf(".sql"); - String mainName = filename.substring(0, pos); + private LocalMigrationResource createScriptMigration(Resource resource, String mainName) { MigrationVersion migrationVersion = MigrationVersion.parse(mainName); return new LocalDdlMigrationResource(migrationVersion, resource.location(), resource); } @@ -193,30 +165,4 @@ List versions() { return versions; } - /** - * Filter used to find the migration scripts. - */ - private static final class Match implements Predicate { - - private final boolean searchJdbc; - - Match(boolean searchJdbc) { - this.searchJdbc = searchJdbc; - } - - @Override - public boolean test(String name) { - return name.endsWith(".sql") || (searchJdbc && name.endsWith(".class") && !name.contains("$")); - } - } - - /** - * Filter to find JDBC migrations only. - */ - private static final class JdbcOnly implements Predicate { - @Override - public boolean test(String name) { - return name.endsWith(".class") && !name.contains("$"); - } - } } From 4180c7b6ffd951d7836a4074515cb57a112bae1d Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 23 Nov 2023 09:03:28 +0100 Subject: [PATCH 02/18] JdbcMigrations are provided by a factory now --- .../io/ebean/migration/JdbcMigration.java | 19 +++++++ .../ebean/migration/JdbcMigrationFactory.java | 11 ---- .../io/ebean/migration/MigrationConfig.java | 54 ++++++++++++++----- .../runner/LocalJdbcMigrationResource.java | 4 +- .../runner/LocalMigrationResources.java | 47 ++++++++++++---- .../src/main/java/module-info.java | 1 + .../ebean/migration/MigrationRunnerTest.java | 5 ++ .../migration/runner/MigrationTable1Test.java | 2 + 8 files changed, 107 insertions(+), 36 deletions(-) delete mode 100644 ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java index 4e07bc3..371da1b 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java @@ -25,4 +25,23 @@ public interface JdbcMigration extends MigrationChecksumProvider { default int getChecksum() { return 0; } + + /** + * Returns the name of the JdbcMigration. Note, the value must follow the naming conventions, for MigrationVersions. + * (example: V1_2_1__comment) + *

+ * By default, the simple classname will be returned. + */ + default String getName() { + return getClass().getSimpleName(); + } + + /** + * Determines, if this migration can be used for that platform. + *

+ * By default, true is returned. + */ + default boolean isForPlatform(String platform) { + return true; + } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java deleted file mode 100644 index 9dc8d42..0000000 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigrationFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.ebean.migration; - -/** - * Factory to create and initialise a JdbcMigration. - * - * @author Roland Praml, FOCONIS AG - */ -public interface JdbcMigrationFactory { - - // will be reused later -} diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java index 67a56e3..31dd617 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java @@ -3,9 +3,12 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.ServiceLoader; import java.util.Set; /** @@ -32,7 +35,7 @@ public class MigrationConfig { private boolean setCurrentSchema = true; private boolean allowErrorInRepeatable; - private JdbcMigrationFactory jdbcMigrationFactory = new DefaultMigrationFactory(); + private Iterable jdbcMigrationFactory = ServiceLoader.load(JdbcMigration.class); /** * Versions that we want to insert into migration history without actually running. @@ -418,17 +421,32 @@ public void setClassLoader(ClassLoader classLoader) { /** * Return the jdbcMigrationFactory. */ - public JdbcMigrationFactory getJdbcMigrationFactory() { + public Iterable getJdbcMigrationFactory() { return jdbcMigrationFactory; } /** - * Set the jdbcMigrationFactory. + * Set the jdbcMigrationFactory. If not set, the ServiceLoader is used. + * JdbcMigrationFactory can be either defined with the property jdbcMigrationFactory + * to a fully qualified class name implementing Iterable<JdbcMigration> or by + * specifying a comma separated list of JdbcMigrations in the jdbcMigrations property. + * */ - public void setJdbcMigrationFactory(JdbcMigrationFactory jdbcMigrationFactory) { + public void setJdbcMigrationFactory(Iterable jdbcMigrationFactory) { this.jdbcMigrationFactory = jdbcMigrationFactory; } + /** + * Helper method to set migrations with the jdbcMigrations property. + */ + public void setJdbcMigrations(String ... classNames) { + List migrations = new ArrayList<>(classNames.length); + for (String className : classNames) { + migrations.add(newInstance(className.trim())); + } + setJdbcMigrationFactory(migrations); + } + /** * Return the minVersion. */ @@ -484,6 +502,16 @@ public void load(Properties props) { minVersion = property("minVersion", minVersion); minVersionFailMessage = property("minVersionFailMessage", minVersionFailMessage); + String jdbcMigrationFactory = property("jdbcMigrationFactory"); + if (jdbcMigrationFactory != null) { + setJdbcMigrationFactory(newInstance(jdbcMigrationFactory)); + } + + String jdbcMigrations = property("jdbcMigrations"); + if (jdbcMigrations != null) { + setJdbcMigrations(jdbcMigrations.split(",")); + } + String patchInsertOn = property("patchInsertOn"); if (patchInsertOn != null) { setPatchInsertOn(patchInsertOn); @@ -498,6 +526,15 @@ public void load(Properties props) { } } + public T newInstance(String className) { + try { + Class cls = Class.forName(name, true, classLoader); + return (T) cls.getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new IllegalArgumentException("Error constructing " + className, e); + } + } + private boolean property(String key, boolean value) { String val = property(key); return val != null ? Boolean.parseBoolean(val) : value; @@ -610,13 +647,4 @@ public void setFastMode(boolean fastMode) { this.fastMode = fastMode; } - /** - * Default factory. TBD - * - * @author Roland Praml, FOCONIS AG - */ - public class DefaultMigrationFactory implements JdbcMigrationFactory { - - } - } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java index 4acd928..36cadde 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java @@ -15,8 +15,8 @@ final class LocalJdbcMigrationResource extends LocalMigrationResource { /** * Construct with version and resource. */ - LocalJdbcMigrationResource(MigrationVersion version, String location, JdbcMigration migration) { - super(version, location); + LocalJdbcMigrationResource(MigrationVersion version, JdbcMigration migration) { + super(version, migration.getClass().getName()); this.migration = migration; } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index 4761be5..39d8ef6 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -2,6 +2,7 @@ import io.avaje.classpath.scanner.Resource; import io.avaje.classpath.scanner.core.Scanner; +import io.ebean.migration.JdbcMigration; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationVersion; @@ -9,6 +10,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import static java.lang.System.Logger.Level.DEBUG; @@ -23,6 +25,7 @@ final class LocalMigrationResources { private final List versions = new ArrayList<>(); private final MigrationConfig migrationConfig; private final ClassLoader classLoader; + private final Iterable jdbcMigrationFactory; /** * Construct with configuration options. @@ -30,6 +33,7 @@ final class LocalMigrationResources { LocalMigrationResources(MigrationConfig migrationConfig) { this.migrationConfig = migrationConfig; this.classLoader = migrationConfig.getClassLoader(); + this.jdbcMigrationFactory = migrationConfig.getJdbcMigrationFactory(); } /** @@ -46,36 +50,63 @@ boolean readResources() { if (readFromIndex()) { // automatically enable earlyChecksumMode when using index file with pre-computed checksums migrationConfig.setEarlyChecksumMode(true); - return true; + } else { + readResourcesForPath(migrationConfig.getMigrationPath()); } - return readResourcesForPath(migrationConfig.getMigrationPath()); + readJdbcMigrations(); + Collections.sort(versions); + return versions.isEmpty(); } + /** + * Returns true, if an index file was found. Although, if file was empty, so we do not fall back + * to classpath scan! + */ private boolean readFromIndex() { final var base = "/" + migrationConfig.getMigrationPath() + "/"; final var basePlatform = migrationConfig.getBasePlatform(); final var indexName = "idx_" + basePlatform + ".migrations"; URL idx = resource(base + indexName); if (idx != null) { - return loadFromIndexFile(idx, base); + loadFromIndexFile(idx, base); + return true; } idx = resource(base + basePlatform + '/' + indexName); if (idx != null) { - return loadFromIndexFile(idx, base + basePlatform + '/'); + loadFromIndexFile(idx, base + basePlatform + '/'); + return true; } final var platform = migrationConfig.getPlatform(); idx = resource(base + platform + indexName); if (idx != null) { - return loadFromIndexFile(idx, base + platform + '/'); + loadFromIndexFile(idx, base + platform + '/'); + return true; } return false; } + + private void readJdbcMigrations() { + if (jdbcMigrationFactory != null) { + Iterator iterator = jdbcMigrationFactory.iterator(); + while (iterator.hasNext()) { + JdbcMigration jdbcMigration = iterator.next(); + if (jdbcMigration.isForPlatform(migrationConfig.getBasePlatform()) + || (jdbcMigration.isForPlatform(migrationConfig.getPlatform()))) { + final var version = MigrationVersion.parse(jdbcMigration.getName()); + versions.add(new LocalJdbcMigrationResource(version, jdbcMigration)); + } + } + } + } + + private URL resource(String base) { return LocalMigrationResources.class.getResource(base); } - private boolean loadFromIndexFile(URL idx, String base) { + private void loadFromIndexFile(URL idx, String base) { + log.log(DEBUG, "Loading index from {0}", idx); try (var reader = new LineNumberReader(new InputStreamReader(idx.openStream()))) { String line; while ((line = reader.readLine()) != null) { @@ -91,9 +122,6 @@ private boolean loadFromIndexFile(URL idx, String base) { } } } - - return !versions.isEmpty(); - } catch (IOException e) { throw new UncheckedIOException("Error reading idx file", e); } @@ -111,7 +139,6 @@ private boolean readResourcesForPath(String path) { return true; } addResources(scanForMigrations(path)); - Collections.sort(versions); return !versions.isEmpty(); } diff --git a/ebean-migration/src/main/java/module-info.java b/ebean-migration/src/main/java/module-info.java index d20abf8..e0f8e22 100644 --- a/ebean-migration/src/main/java/module-info.java +++ b/ebean-migration/src/main/java/module-info.java @@ -8,5 +8,6 @@ requires transitive io.ebean.ddl.runner; requires io.ebean.migration.auto; + uses io.ebean.migration.JdbcMigration; provides io.ebean.migration.auto.AutoMigrationRunner with io.ebean.migration.AutoRunner; } diff --git a/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java b/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java index eb1df6f..a5969d8 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java @@ -1,5 +1,6 @@ package io.ebean.migration; +import dbmig.V1_2_1__test; import io.ebean.datasource.DataSourceConfig; import io.ebean.datasource.DataSourceFactory; import io.ebean.datasource.DataSourcePool; @@ -34,6 +35,7 @@ public void run_when_createConnection() { MigrationConfig config = createMigrationConfig(); config.setMigrationPath("dbmig"); + config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); MigrationRunner runner = new MigrationRunner(config); List check = runner.checkState(); @@ -211,6 +213,8 @@ public void run_with_min_version() { MigrationConfig config = createMigrationConfig(); config.setMigrationPath("dbmig"); + config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); + config.setMinVersion("1.3"); // dbmig must run, if DB is empty! new MigrationRunner(config).run(dataSource); @@ -276,6 +280,7 @@ public void run_with_skipMigration() throws SQLException { // not actually run the migrations but populate the migration table config.setSkipMigrationRun(true); config.setMigrationPath("dbmig"); + config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); DataSourcePool dataSource = DataSourceFactory.create("skipMigration", dataSourceConfig); new MigrationRunner(config).run(dataSource); diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java index 99723e6..808791e 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java @@ -1,5 +1,6 @@ package io.ebean.migration.runner; +import dbmig.V1_2_1__test; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationRunner; import io.ebean.datasource.DataSourceConfig; @@ -52,6 +53,7 @@ private MigrationTable migrationTable(Connection conn) { public void testMigrationTableBase() throws Exception { config.setMigrationPath("dbmig"); + config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); MigrationRunner runner = new MigrationRunner(config); runner.run(dataSource); From 4c0e7cfb72bd295d421827b68b0c243934b76685 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 23 Nov 2023 11:06:19 +0100 Subject: [PATCH 03/18] Added tests and fixes for serviceLoader --- ebean-migration/pom.xml | 1 + .../ebean/migration/ConfigurationAware.java | 18 ------------ .../io/ebean/migration/JdbcMigration.java | 29 ++++++++++++++----- .../io/ebean/migration/MigrationConfig.java | 23 ++++++++++++--- .../runner/LocalMigrationResources.java | 3 +- .../migration/runner/MigrationTable.java | 2 +- .../src/test/java/dbmig/V1_2_1__test.java | 13 ++------- .../ebean/migration/MigrationRunnerTest.java | 4 +-- .../migration/ServiceLoaderMigration.java | 24 +++++++++++++++ .../services/io.ebean.migration.JdbcMigration | 1 + 10 files changed, 71 insertions(+), 47 deletions(-) delete mode 100644 ebean-migration/src/main/java/io/ebean/migration/ConfigurationAware.java create mode 100644 ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java create mode 100644 ebean-migration/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration diff --git a/ebean-migration/pom.xml b/ebean-migration/pom.xml index a50d66b..1269f8a 100644 --- a/ebean-migration/pom.xml +++ b/ebean-migration/pom.xml @@ -19,6 +19,7 @@ true + false diff --git a/ebean-migration/src/main/java/io/ebean/migration/ConfigurationAware.java b/ebean-migration/src/main/java/io/ebean/migration/ConfigurationAware.java deleted file mode 100644 index 13dc622..0000000 --- a/ebean-migration/src/main/java/io/ebean/migration/ConfigurationAware.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.ebean.migration; - -/** - * Marks a class as configuration aware (JdbcMigrations) Configuration aware - * classes get the migration configuration injected upon creation. The - * implementer is responsible for correctly storing the provided - * MigrationConfig (usually in a field). - * - * @author Roland Praml, FOCONIS AG - * - */ -public interface ConfigurationAware { - - /** - * Set the configuration being used. - */ - void setMigrationConfig(MigrationConfig config); -} diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java index 371da1b..c8f6a32 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java @@ -5,12 +5,21 @@ /** * Interface to be implemented by Jdbc Java Migrations. By default the migration * version and description will be extracted from the class name. The checksum of this migration - * (for validation) will also be null, unless the migration also implements the - * MigrationChecksumProvider, in which case it can be returned programmatically. + * will be 0 by default *

- * When the JdbcMigration implements ConfigurationAware, the master - * {@link MigrationConfig} is automatically injected upon creation, which is - * useful for getting placeholder and schema information. + * Note: Instances of JdbcMigration should be stateless, as the migrate method may + * run multiple times in multi-tenant setups. + *

+ * There are several ways, how the JdbcMigrations are found. + *

    + *
  • ServiceLoader this is the default behaviour
    + * in this case add all your migration class names in META-INF/services/io.ebean.migration.JdbcMigration and/or in your + * module info.
  • + *
  • Using jdbcMigrations property
    + * you can specify all migrations in the jdbcMigrations property
  • + *
  • Using own jdbcMigrationFactory + * you can write your own jdbcMigrationFactory that provides JdbcMigrations
  • + *
* * @author Roland Praml, FOCONIS AG */ @@ -18,8 +27,11 @@ public interface JdbcMigration extends MigrationChecksumProvider { /** * Execute the migration using the connection. + *

+ * Note: This API has changed with ebean-migration 13.12, as the initialization has changed. + * See https://github.com/ebean-orm/ebean-migration/issues/90 for migration advice. */ - void migrate(Connection connection); + void migrate(Connection connection, MigrationConfig config); @Override default int getChecksum() { @@ -37,11 +49,12 @@ default String getName() { } /** - * Determines, if this migration can be used for that platform. + * Determines, if this migration can be used for that migrationConfig. + * Here, platform checks or other things can be implemented. *

* By default, true is returned. */ - default boolean isForPlatform(String platform) { + default boolean matches(MigrationConfig config) { return true; } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java index 31dd617..f95d3ed 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java @@ -1,10 +1,12 @@ package io.ebean.migration; +import java.lang.reflect.Constructor; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -35,7 +37,7 @@ public class MigrationConfig { private boolean setCurrentSchema = true; private boolean allowErrorInRepeatable; - private Iterable jdbcMigrationFactory = ServiceLoader.load(JdbcMigration.class); + private Iterable jdbcMigrationFactory = new DefaultMigrationFactory(); /** * Versions that we want to insert into migration history without actually running. @@ -430,7 +432,9 @@ public Iterable getJdbcMigrationFactory() { * JdbcMigrationFactory can be either defined with the property jdbcMigrationFactory * to a fully qualified class name implementing Iterable<JdbcMigration> or by * specifying a comma separated list of JdbcMigrations in the jdbcMigrations property. - * + *

+ * Note: If you plan to run migrations in multi-tenant env in multiple threads, the provided factory + * must be thread safe! */ public void setJdbcMigrationFactory(Iterable jdbcMigrationFactory) { this.jdbcMigrationFactory = jdbcMigrationFactory; @@ -439,7 +443,7 @@ public void setJdbcMigrationFactory(Iterable jdbcMigrationFactory /** * Helper method to set migrations with the jdbcMigrations property. */ - public void setJdbcMigrations(String ... classNames) { + public void setJdbcMigrations(String... classNames) { List migrations = new ArrayList<>(classNames.length); for (String className : classNames) { migrations.add(newInstance(className.trim())); @@ -528,7 +532,7 @@ public void load(Properties props) { public T newInstance(String className) { try { - Class cls = Class.forName(name, true, classLoader); + Class cls = Class.forName(className, true, getClassLoader()); return (T) cls.getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new IllegalArgumentException("Error constructing " + className, e); @@ -647,4 +651,15 @@ public void setFastMode(boolean fastMode) { this.fastMode = fastMode; } + /** + * Default implementation for service-loader. Note: ServiceLoader is not thread safe, + * so it is better to retrun a new iterator each time. + */ + private class DefaultMigrationFactory implements Iterable { + + @Override + public Iterator iterator() { + return ServiceLoader.load(JdbcMigration.class, getClassLoader()).iterator(); + } + } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index 39d8ef6..1320f42 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -91,8 +91,7 @@ private void readJdbcMigrations() { Iterator iterator = jdbcMigrationFactory.iterator(); while (iterator.hasNext()) { JdbcMigration jdbcMigration = iterator.next(); - if (jdbcMigration.isForPlatform(migrationConfig.getBasePlatform()) - || (jdbcMigration.isForPlatform(migrationConfig.getPlatform()))) { + if (jdbcMigration.matches(migrationConfig)) { final var version = MigrationVersion.parse(jdbcMigration.getName()); versions.add(new LocalJdbcMigrationResource(version, jdbcMigration)); } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java index 93550fe..a402547 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java @@ -424,7 +424,7 @@ private long executeMigration(LocalMigrationResource local, String script) throw if (local instanceof LocalJdbcMigrationResource) { JdbcMigration migration = ((LocalJdbcMigrationResource) local).migration(); log.log(INFO, "Executing jdbc migration version: {0} - {1}", local.version(), migration); - migration.migrate(connection); + migration.migrate(connection, config); } else { log.log(DEBUG, "run migration {0}", local.location()); scriptRunner.runScript(script, "run migration version: " + local.version()); diff --git a/ebean-migration/src/test/java/dbmig/V1_2_1__test.java b/ebean-migration/src/test/java/dbmig/V1_2_1__test.java index 9b917c2..12423d6 100644 --- a/ebean-migration/src/test/java/dbmig/V1_2_1__test.java +++ b/ebean-migration/src/test/java/dbmig/V1_2_1__test.java @@ -2,7 +2,6 @@ import java.sql.Connection; -import io.ebean.migration.ConfigurationAware; import io.ebean.migration.JdbcMigration; import io.ebean.migration.MigrationConfig; @@ -10,23 +9,15 @@ * Sample migration. * * @author Roland Praml, FOCONIS AG - * */ -public class V1_2_1__test implements JdbcMigration, ConfigurationAware{ - - private MigrationConfig config; +public class V1_2_1__test implements JdbcMigration { public static class MyDto { String id; } - - @Override - public void setMigrationConfig(MigrationConfig config) { - this.config = config; - } @Override - public void migrate(Connection connection) { + public void migrate(Connection connection, MigrationConfig config) { System.out.println("Executing migration on " + connection); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java b/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java index a5969d8..23f9143 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java @@ -35,7 +35,6 @@ public void run_when_createConnection() { MigrationConfig config = createMigrationConfig(); config.setMigrationPath("dbmig"); - config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); MigrationRunner runner = new MigrationRunner(config); List check = runner.checkState(); @@ -280,7 +279,6 @@ public void run_with_skipMigration() throws SQLException { // not actually run the migrations but populate the migration table config.setSkipMigrationRun(true); config.setMigrationPath("dbmig"); - config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); DataSourcePool dataSource = DataSourceFactory.create("skipMigration", dataSourceConfig); new MigrationRunner(config).run(dataSource); @@ -288,7 +286,7 @@ public void run_with_skipMigration() throws SQLException { // assert migrations are in the migration table try (final Connection connection = dataSource.getConnection()) { final List names = migrationNames(connection); - assertThat(names).contains("", "hello", "initial", "add_m3", "test", "m2_view"); + assertThat(names).containsExactly("", "hello", "initial", "add_m3", "serviceLoaded", "m2_view"); } // assert the migrations didn't actually run (create the tables etc) diff --git a/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java b/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java new file mode 100644 index 0000000..3768fd5 --- /dev/null +++ b/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java @@ -0,0 +1,24 @@ +package io.ebean.migration; + +import java.sql.Connection; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class ServiceLoaderMigration implements JdbcMigration { + + @Override + public String getName() { + return "1.4.1__serviceLoaded"; + } + + @Override + public void migrate(Connection connection, MigrationConfig config) { + + } + + @Override + public boolean matches(MigrationConfig config) { + return "dbmig".equals(config.getMigrationPath()); + } +} diff --git a/ebean-migration/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration b/ebean-migration/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration new file mode 100644 index 0000000..6615228 --- /dev/null +++ b/ebean-migration/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration @@ -0,0 +1 @@ +io.ebean.migration.ServiceLoaderMigration From 33a356cef30e8dac323be2e5fb2d24c2f46d2af1 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 23 Nov 2023 12:01:32 +0100 Subject: [PATCH 04/18] Fix return value of readResources --- .../io/ebean/migration/runner/LocalMigrationResources.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index 1320f42..6d7d741 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -44,7 +44,7 @@ boolean readInitResources() { } /** - * Read all the migration resources (SQL scripts) returning true if there are versions. + * Read all the migration resources (SQL scripts and JDBC migrations) returning true if there are versions. */ boolean readResources() { if (readFromIndex()) { @@ -55,7 +55,7 @@ boolean readResources() { } readJdbcMigrations(); Collections.sort(versions); - return versions.isEmpty(); + return !versions.isEmpty(); } /** From cb73cd97c8e2b679d69d39a58b26ebb01a1b35c6 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Fri, 8 Dec 2023 16:51:12 +0100 Subject: [PATCH 05/18] Changed to collection and added context --- .../io/ebean/migration/JdbcMigration.java | 12 ++- .../io/ebean/migration/MigrationConfig.java | 54 ++++++----- .../io/ebean/migration/MigrationContext.java | 15 +++ .../runner/DefaultMigrationContext.java | 35 +++++++ .../io/ebean/migration/runner/FirstCheck.java | 9 +- .../runner/LocalMigrationResources.java | 33 +++---- .../migration/runner/MigrationEngine.java | 92 +++++++++++-------- .../migration/runner/MigrationTable.java | 6 +- .../src/test/java/dbmig/V1_2_1__test.java | 5 +- .../ebean/migration/MigrationRunnerTest.java | 2 +- .../migration/ServiceLoaderMigration.java | 6 +- .../migration/runner/MigrationTable1Test.java | 4 +- .../runner/MigrationTableAsyncTest.java | 2 +- .../MigrationTableCreateTableRaceTest.java | 2 +- .../runner/MigrationTableTestDb2.java | 2 +- 15 files changed, 179 insertions(+), 100 deletions(-) create mode 100644 ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java create mode 100644 ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java index c8f6a32..a89c1d8 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java @@ -31,7 +31,7 @@ public interface JdbcMigration extends MigrationChecksumProvider { * Note: This API has changed with ebean-migration 13.12, as the initialization has changed. * See https://github.com/ebean-orm/ebean-migration/issues/90 for migration advice. */ - void migrate(Connection connection, MigrationConfig config); + void migrate(MigrationContext context); @Override default int getChecksum() { @@ -39,22 +39,24 @@ default int getChecksum() { } /** - * Returns the name of the JdbcMigration. Note, the value must follow the naming conventions, for MigrationVersions. + * Returns the name of the JdbcMigration. Note, the name is used to determine the version and comment, + * that is written to the migration table, so the returned value must be a parseable {@link MigrationVersion} * (example: V1_2_1__comment) *

- * By default, the simple classname will be returned. + * By default, the simple classname will be returned, so the file name can be used. */ default String getName() { return getClass().getSimpleName(); } /** - * Determines, if this migration can be used for that migrationConfig. + * Determines, if this migration can be used for that migrationContext. * Here, platform checks or other things can be implemented. + * You should not write to database at this stage. *

* By default, true is returned. */ - default boolean matches(MigrationConfig config) { + default boolean matches(MigrationContext context) { return true; } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java index f95d3ed..bb7dd8f 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java @@ -37,7 +37,12 @@ public class MigrationConfig { private boolean setCurrentSchema = true; private boolean allowErrorInRepeatable; - private Iterable jdbcMigrationFactory = new DefaultMigrationFactory(); + /** + * Holds a Collection/Iterable of JdbcMigrations. All migrations (JDBC and SQL) are + * extecuted in the order defined by their version numbers. + * By default, JdbcMigrations are loaded via ServiceLoader. + */ + private Iterable jdbcMigrations = new DefaultJdbcMigrations(); /** * Versions that we want to insert into migration history without actually running. @@ -421,34 +426,45 @@ public void setClassLoader(ClassLoader classLoader) { } /** - * Return the jdbcMigrationFactory. + * Return the jdbcMigrations. */ - public Iterable getJdbcMigrationFactory() { - return jdbcMigrationFactory; + public Iterable getJdbcMigrations() { + return jdbcMigrations; } /** - * Set the jdbcMigrationFactory. If not set, the ServiceLoader is used. - * JdbcMigrationFactory can be either defined with the property jdbcMigrationFactory + * Set the jdbcMigrations. If not set, the ServiceLoader is used. + * JdbcMigrations can be either defined with the property jdbcMigrations * to a fully qualified class name implementing Iterable<JdbcMigration> or by - * specifying a comma separated list of JdbcMigrations in the jdbcMigrations property. + * specifying a comma separated list of {@link JdbcMigration}s in the jdbcMigrations property. *

* Note: If you plan to run migrations in multi-tenant env in multiple threads, the provided factory * must be thread safe! */ - public void setJdbcMigrationFactory(Iterable jdbcMigrationFactory) { - this.jdbcMigrationFactory = jdbcMigrationFactory; + public void setJdbcMigrations(Iterable jdbcMigrationFactory) { + this.jdbcMigrations = jdbcMigrationFactory; } /** * Helper method to set migrations with the jdbcMigrations property. + * You can either pass ONE MigrationCollection or a list of JdbcMigrations. */ + @SuppressWarnings("unchecked") public void setJdbcMigrations(String... classNames) { - List migrations = new ArrayList<>(classNames.length); - for (String className : classNames) { - migrations.add(newInstance(className.trim())); + if (classNames.length == 1) { + Object candidate = newInstance(classNames[0].trim()); + if (candidate instanceof JdbcMigration) { + setJdbcMigrations(List.of((JdbcMigration) candidate)); + } else { + setJdbcMigrations((Iterable) candidate); + } + } else { + List migrations = new ArrayList<>(classNames.length); + for (String className : classNames) { + migrations.add(newInstance(className.trim())); + } + setJdbcMigrations(migrations); } - setJdbcMigrationFactory(migrations); } /** @@ -506,11 +522,6 @@ public void load(Properties props) { minVersion = property("minVersion", minVersion); minVersionFailMessage = property("minVersionFailMessage", minVersionFailMessage); - String jdbcMigrationFactory = property("jdbcMigrationFactory"); - if (jdbcMigrationFactory != null) { - setJdbcMigrationFactory(newInstance(jdbcMigrationFactory)); - } - String jdbcMigrations = property("jdbcMigrations"); if (jdbcMigrations != null) { setJdbcMigrations(jdbcMigrations.split(",")); @@ -530,6 +541,7 @@ public void load(Properties props) { } } + @SuppressWarnings("unchecked") public T newInstance(String className) { try { Class cls = Class.forName(className, true, getClassLoader()); @@ -652,10 +664,10 @@ public void setFastMode(boolean fastMode) { } /** - * Default implementation for service-loader. Note: ServiceLoader is not thread safe, - * so it is better to retrun a new iterator each time. + * Default implementation for service-loader. Note: As ServiceLoader is not thread safe, + * it is better to return a new iterator each time. */ - private class DefaultMigrationFactory implements Iterable { + private class DefaultJdbcMigrations implements Iterable { @Override public Iterator iterator() { diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java new file mode 100644 index 0000000..ad12d40 --- /dev/null +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java @@ -0,0 +1,15 @@ +package io.ebean.migration; + +import java.sql.Connection; + +/** + * @author Roland Praml, FOCONIS AG + */ +public interface MigrationContext { + Connection connection(); + + String migrationPath(); + + String platform(); + +} diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java new file mode 100644 index 0000000..b05ef0b --- /dev/null +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java @@ -0,0 +1,35 @@ +package io.ebean.migration.runner; + +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; + +import java.sql.Connection; + +/** + * + * @author Roland Praml, FOCONIS AG + */ +public class DefaultMigrationContext implements MigrationContext { + private final Connection connection; + private final String migrationPath; + private final String platform; + + public DefaultMigrationContext(MigrationConfig config, Connection connection) { + this.connection = connection; + this.migrationPath = config.getMigrationPath(); + this.platform = config.getPlatform(); + } + + public Connection connection() { + return connection; + } + + @Override + public String migrationPath() { + return migrationPath; + } + + public String platform() { + return platform; + } +} diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/FirstCheck.java b/ebean-migration/src/main/java/io/ebean/migration/runner/FirstCheck.java index 72becb1..ad18657 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/FirstCheck.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/FirstCheck.java @@ -1,6 +1,7 @@ package io.ebean.migration.runner; import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; import java.sql.Connection; import java.sql.SQLException; @@ -15,17 +16,17 @@ final class FirstCheck { final MigrationConfig config; final MigrationPlatform platform; - final Connection connection; + final MigrationContext context; final String schema; final String table; final String sqlTable; boolean tableKnownToExist; private int count; - FirstCheck(MigrationConfig config, Connection connection, MigrationPlatform platform) { + FirstCheck(MigrationConfig config, MigrationContext context, MigrationPlatform platform) { this.config = config; this.platform = platform; - this.connection = connection; + this.context = context; this.schema = config.getDbSchema(); this.table = config.getMetaTable(); this.sqlTable = schema != null ? schema + '.' + table : table; @@ -80,7 +81,7 @@ private int checksumFor(LocalMigrationResource local) { } List fastRead() throws SQLException { - return platform.fastReadMigrations(sqlTable, connection); + return platform.fastReadMigrations(sqlTable, context.connection()); } int count() { diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index 6d7d741..f7c0cf4 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -4,6 +4,7 @@ import io.avaje.classpath.scanner.core.Scanner; import io.ebean.migration.JdbcMigration; import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; import io.ebean.migration.MigrationVersion; import java.io.*; @@ -25,7 +26,7 @@ final class LocalMigrationResources { private final List versions = new ArrayList<>(); private final MigrationConfig migrationConfig; private final ClassLoader classLoader; - private final Iterable jdbcMigrationFactory; + private final Iterable jdbcMigrations; /** * Construct with configuration options. @@ -33,27 +34,29 @@ final class LocalMigrationResources { LocalMigrationResources(MigrationConfig migrationConfig) { this.migrationConfig = migrationConfig; this.classLoader = migrationConfig.getClassLoader(); - this.jdbcMigrationFactory = migrationConfig.getJdbcMigrationFactory(); + this.jdbcMigrations = migrationConfig.getJdbcMigrations(); } /** * Read the init migration resources (usually only 1) returning true if there are versions. */ boolean readInitResources() { - return readResourcesForPath(migrationConfig.getMigrationInitPath()); + readResourcesForPath(migrationConfig.getMigrationInitPath()); + Collections.sort(versions); + return !versions.isEmpty(); } /** * Read all the migration resources (SQL scripts and JDBC migrations) returning true if there are versions. */ - boolean readResources() { + boolean readResources(MigrationContext context) { if (readFromIndex()) { // automatically enable earlyChecksumMode when using index file with pre-computed checksums migrationConfig.setEarlyChecksumMode(true); } else { readResourcesForPath(migrationConfig.getMigrationPath()); } - readJdbcMigrations(); + readJdbcMigrations(context); Collections.sort(versions); return !versions.isEmpty(); } @@ -85,13 +88,10 @@ private boolean readFromIndex() { return false; } - - private void readJdbcMigrations() { - if (jdbcMigrationFactory != null) { - Iterator iterator = jdbcMigrationFactory.iterator(); - while (iterator.hasNext()) { - JdbcMigration jdbcMigration = iterator.next(); - if (jdbcMigration.matches(migrationConfig)) { + void readJdbcMigrations(MigrationContext context) { + if (jdbcMigrations != null) { + for (JdbcMigration jdbcMigration : jdbcMigrations) { + if (jdbcMigration.matches(context)) { final var version = MigrationVersion.parse(jdbcMigration.getName()); versions.add(new LocalJdbcMigrationResource(version, jdbcMigration)); } @@ -99,7 +99,6 @@ private void readJdbcMigrations() { } } - private URL resource(String base) { return LocalMigrationResources.class.getResource(base); } @@ -126,19 +125,18 @@ private void loadFromIndexFile(URL idx, String base) { } } - private boolean readResourcesForPath(String path) { + private void readResourcesForPath(String path) { // try to load from base platform first final String basePlatform = migrationConfig.getBasePlatform(); if (basePlatform != null && loadedFrom(path, basePlatform)) { - return true; + return; } // try to load from specific platform final String platform = migrationConfig.getPlatform(); if (platform != null && loadedFrom(path, platform)) { - return true; + return; } addResources(scanForMigrations(path)); - return !versions.isEmpty(); } /** @@ -150,7 +148,6 @@ private boolean loadedFrom(String path, String platform) { return false; } log.log(DEBUG, "platform migrations for {0}", platform); - Collections.sort(versions); return true; } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java index 55562aa..a1c38f3 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java @@ -2,6 +2,7 @@ import io.avaje.applog.AppLog; import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; import io.ebean.migration.MigrationException; import io.ebean.migration.MigrationResource; @@ -35,51 +36,64 @@ public MigrationEngine(MigrationConfig migrationConfig, boolean checkStateOnly) /** * Run the migrations if there are any that need running. + * + * @param connection the connection to run on. Note the connection will be closed. */ public List run(Connection connection) { try { - long startMs = System.currentTimeMillis(); - LocalMigrationResources resources = new LocalMigrationResources(migrationConfig); - if (!resources.readResources() && !resources.readInitResources()) { - log.log(DEBUG, "no migrations to check"); - return emptyList(); - } - long splitMs = System.currentTimeMillis() - startMs; - final var platform = derivePlatform(migrationConfig, connection); - final var firstCheck = new FirstCheck(migrationConfig, connection, platform); - if (fastMode && firstCheck.fastModeCheck(resources.versions())) { - long checkMs = System.currentTimeMillis() - startMs; - log.log(INFO, "DB migrations completed in {0}ms - totalMigrations:{1} readResources:{2}ms", checkMs, firstCheck.count(), splitMs); - return emptyList(); - } - // ensure running with autoCommit false - setAutoCommitFalse(connection); - - final MigrationTable table = initialiseMigrationTable(firstCheck, connection); - try { - List result = runMigrations(table, resources.versions()); - connection.commit(); - if (!checkStateOnly) { - long commitMs = System.currentTimeMillis(); - log.log(INFO, "DB migrations completed in {0}ms - executed:{1} totalMigrations:{2} mode:{3}", (commitMs - startMs), table.count(), table.size(), table.mode()); - int countNonTransactional = table.runNonTransactional(); - if (countNonTransactional > 0) { - log.log(INFO, "Non-transactional DB migrations completed in {0}ms - executed:{1}", (System.currentTimeMillis() - commitMs), countNonTransactional); - } + return run(new DefaultMigrationContext(migrationConfig, connection)); + } finally { + close(connection); + } + } + + /** + * Run the migrations if there are any that need running. (Does not close connection) + */ + public List run(MigrationContext context) { + + long startMs = System.currentTimeMillis(); + LocalMigrationResources resources = new LocalMigrationResources(migrationConfig); + resources.readJdbcMigrations(context); + if (!resources.readResources() && !resources.readInitResources()) { + log.log(DEBUG, "no migrations to check"); + return emptyList(); + } + + var connection = context.connection(); + long splitMs = System.currentTimeMillis() - startMs; + final var platform = derivePlatform(migrationConfig, connection); + final var firstCheck = new FirstCheck(migrationConfig, context, platform); + if (fastMode && firstCheck.fastModeCheck(resources.versions())) { + long checkMs = System.currentTimeMillis() - startMs; + log.log(INFO, "DB migrations completed in {0}ms - totalMigrations:{1} readResources:{2}ms", checkMs, firstCheck.count(), splitMs); + return emptyList(); + } + // ensure running with autoCommit false + setAutoCommitFalse(connection); + + final MigrationTable table = initialiseMigrationTable(firstCheck, connection); + try { + List result = runMigrations(table, resources.versions()); + connection.commit(); + if (!checkStateOnly) { + long commitMs = System.currentTimeMillis(); + log.log(INFO, "DB migrations completed in {0}ms - executed:{1} totalMigrations:{2} mode:{3}", (commitMs - startMs), table.count(), table.size(), table.mode()); + int countNonTransactional = table.runNonTransactional(); + if (countNonTransactional > 0) { + log.log(INFO, "Non-transactional DB migrations completed in {0}ms - executed:{1}", (System.currentTimeMillis() - commitMs), countNonTransactional); } - return result; - } catch (MigrationException e) { - rollback(connection); - throw e; - } catch (Throwable e) { - log.log(ERROR, "Perform rollback due to DB migration error", e); - rollback(connection); - throw new MigrationException("Error running DB migrations", e); - } finally { - table.unlockMigrationTable(); } + return result; + } catch (MigrationException e) { + rollback(connection); + throw e; + } catch (Throwable e) { + log.log(ERROR, "Perform rollback due to DB migration error", e); + rollback(connection); + throw new MigrationException("Error running DB migrations", e); } finally { - close(connection); + table.unlockMigrationTable(); } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java index a402547..97ed597 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java @@ -26,6 +26,7 @@ final class MigrationTable { private static final int AUTO_PATCH_CHECKSUM = -1; private final MigrationConfig config; + private final MigrationContext context; private final Connection connection; private final boolean checkStateOnly; private boolean earlyChecksumMode; @@ -77,7 +78,8 @@ final class MigrationTable { public MigrationTable(FirstCheck firstCheck, boolean checkStateOnly) { this.config = firstCheck.config; this.platform = firstCheck.platform; - this.connection = firstCheck.connection; + this.context = firstCheck.context; + this.connection = this.context.connection(); this.schema = firstCheck.schema; this.table = firstCheck.table; this.sqlTable = firstCheck.sqlTable; @@ -424,7 +426,7 @@ private long executeMigration(LocalMigrationResource local, String script) throw if (local instanceof LocalJdbcMigrationResource) { JdbcMigration migration = ((LocalJdbcMigrationResource) local).migration(); log.log(INFO, "Executing jdbc migration version: {0} - {1}", local.version(), migration); - migration.migrate(connection, config); + migration.migrate(context); } else { log.log(DEBUG, "run migration {0}", local.location()); scriptRunner.runScript(script, "run migration version: " + local.version()); diff --git a/ebean-migration/src/test/java/dbmig/V1_2_1__test.java b/ebean-migration/src/test/java/dbmig/V1_2_1__test.java index 12423d6..cc87495 100644 --- a/ebean-migration/src/test/java/dbmig/V1_2_1__test.java +++ b/ebean-migration/src/test/java/dbmig/V1_2_1__test.java @@ -4,6 +4,7 @@ import io.ebean.migration.JdbcMigration; import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; /** * Sample migration. @@ -17,8 +18,8 @@ public static class MyDto { } @Override - public void migrate(Connection connection, MigrationConfig config) { - System.out.println("Executing migration on " + connection); + public void migrate(MigrationContext context) { + System.out.println("Executing migration on " + context); } @Override diff --git a/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java b/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java index 23f9143..b0e4cb5 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/MigrationRunnerTest.java @@ -212,7 +212,7 @@ public void run_with_min_version() { MigrationConfig config = createMigrationConfig(); config.setMigrationPath("dbmig"); - config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); + config.setJdbcMigrations(List.of(new V1_2_1__test())); config.setMinVersion("1.3"); // dbmig must run, if DB is empty! new MigrationRunner(config).run(dataSource); diff --git a/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java b/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java index 3768fd5..c23dbc7 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java +++ b/ebean-migration/src/test/java/io/ebean/migration/ServiceLoaderMigration.java @@ -13,12 +13,12 @@ public String getName() { } @Override - public void migrate(Connection connection, MigrationConfig config) { + public void migrate(MigrationContext context) { } @Override - public boolean matches(MigrationConfig config) { - return "dbmig".equals(config.getMigrationPath()); + public boolean matches(MigrationContext context) { + return "dbmig".equals(context.migrationPath()); } } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java index 808791e..d7880c0 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java @@ -45,7 +45,7 @@ public void shutdown() { private MigrationTable migrationTable(Connection conn) { - var fc = new FirstCheck(config, conn, platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); return new MigrationTable(fc, false); } @@ -53,7 +53,7 @@ private MigrationTable migrationTable(Connection conn) { public void testMigrationTableBase() throws Exception { config.setMigrationPath("dbmig"); - config.setJdbcMigrationFactory(List.of(new V1_2_1__test())); + config.setJdbcMigrations(List.of(new V1_2_1__test())); MigrationRunner runner = new MigrationRunner(config); runner.run(dataSource); diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java index 38bc0b6..a6795d8 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java @@ -204,7 +204,7 @@ private void runTest(boolean withExisting) throws SQLException, InterruptedExcep } private static MigrationTable migrationTable(MigrationPlatform platform, Connection connection) { - var fc = new FirstCheck(config, connection, platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection), platform); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java index b5d226c..99b3d83 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java @@ -51,7 +51,7 @@ void testRaceCondition_expect_loserOfCreateTableCanPerformTableExistsCheck() thr try (Connection conn = dataSource.getConnection()) { dropTable(conn); - var fc = new FirstCheck(config, conn, platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); MigrationTable table = new MigrationTable(fc, false); table.createTable(); try { diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java index 4777ed4..5a35392 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java @@ -44,7 +44,7 @@ public void testMigrationTableBase() throws Exception { config.setMigrationPath("dbmig"); try (Connection conn = dataSource.getConnection()) { - var fc = new FirstCheck(config, conn, platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); MigrationTable table = new MigrationTable(fc, false); table.createIfNeededAndLock(); table.unlockMigrationTable(); From 58d893f594d5162f8e65e52cc84137c9217a1738 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Mon, 11 Dec 2023 09:47:25 +0100 Subject: [PATCH 06/18] Tests will run --- .../io/ebean/migration/runner/LocalMigrationResources.java | 4 +++- .../main/java/io/ebean/migration/runner/MigrationEngine.java | 3 +-- .../java/io/ebean/migration/runner/MigrationTable2Test.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index f7c0cf4..2d37174 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -56,6 +56,8 @@ boolean readResources(MigrationContext context) { } else { readResourcesForPath(migrationConfig.getMigrationPath()); } + // after we read the SQL migrations from index or classpath scan, we + // read jdbcMigrations and sort them. readJdbcMigrations(context); Collections.sort(versions); return !versions.isEmpty(); @@ -88,7 +90,7 @@ private boolean readFromIndex() { return false; } - void readJdbcMigrations(MigrationContext context) { + private void readJdbcMigrations(MigrationContext context) { if (jdbcMigrations != null) { for (JdbcMigration jdbcMigration : jdbcMigrations) { if (jdbcMigration.matches(context)) { diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java index a1c38f3..60e57df 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java @@ -54,8 +54,7 @@ public List run(MigrationContext context) { long startMs = System.currentTimeMillis(); LocalMigrationResources resources = new LocalMigrationResources(migrationConfig); - resources.readJdbcMigrations(context); - if (!resources.readResources() && !resources.readInitResources()) { + if (!resources.readResources(context) && !resources.readInitResources()) { log.log(DEBUG, "no migrations to check"); return emptyList(); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java index f916dd0..4b1e6bb 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java @@ -12,7 +12,7 @@ public class MigrationTable2Test { private static MigrationTable migrationTable(MigrationConfig config) { - var fc = new FirstCheck(config, null, new MigrationPlatform()); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, null), new MigrationPlatform()); return new MigrationTable(fc, false); } From 452a16e183c88fb666c4e00fa2cb02e5717abc4f Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 2 Jan 2024 08:09:29 +0100 Subject: [PATCH 07/18] formatting --- .../main/java/io/ebean/migration/auto/AutoMigrationRunner.java | 1 + ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java | 1 + 2 files changed, 2 insertions(+) diff --git a/ebean-migration-auto/src/main/java/io/ebean/migration/auto/AutoMigrationRunner.java b/ebean-migration-auto/src/main/java/io/ebean/migration/auto/AutoMigrationRunner.java index c8bdf2c..d3af70f 100644 --- a/ebean-migration-auto/src/main/java/io/ebean/migration/auto/AutoMigrationRunner.java +++ b/ebean-migration-auto/src/main/java/io/ebean/migration/auto/AutoMigrationRunner.java @@ -56,4 +56,5 @@ default void setBasePlatform(String basePlatform) { * Run DB migrations using the given DataSource. */ void run(DataSource dataSource); + } diff --git a/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java b/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java index 9383e2f..c6258a6 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java +++ b/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java @@ -44,4 +44,5 @@ public void setBasePlatform(String basePlatform) { public void run(DataSource dataSource) { new MigrationRunner(config).run(dataSource); } + } From f51f437dfba5b1d29906de27d4b9e8c6b3efd127 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 2 Jan 2024 08:20:52 +0100 Subject: [PATCH 08/18] fixed compile errors --- .../src/main/java/io/ebean/migration/JdbcMigration.java | 2 +- .../src/main/java/io/ebean/migration/runner/MigrationTable.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java index a89c1d8..4f44281 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java @@ -17,7 +17,7 @@ * module info. *

  • Using jdbcMigrations property
    * you can specify all migrations in the jdbcMigrations property
  • - *
  • Using own jdbcMigrationFactory + *
  • Using own jdbcMigrationFactory
    * you can write your own jdbcMigrationFactory that provides JdbcMigrations
  • * * diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java index 8dea179..090f4aa 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java @@ -426,7 +426,7 @@ private long executeMigration(LocalMigrationResource local, String script) throw if (local instanceof LocalJdbcMigrationResource) { JdbcMigration migration = ((LocalJdbcMigrationResource) local).migration(); log.log(INFO, "Executing jdbc migration version: {0} - {1}", local.version(), migration); - migration.migrate(context.connection()); + migration.migrate(context); } else { log.log(DEBUG, "run migration {0}", local.location()); scriptRunner.runScript(script, "run migration version: " + local.version()); From fbf4e5fd3aa95ee31717068b9024fac62ba4db61 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 2 Jan 2024 09:38:24 +0100 Subject: [PATCH 09/18] Provide access to Database --- ebean-migration/pom.xml | 7 +++++ .../io/ebean/migration/MigrationContext.java | 6 ++++ .../io/ebean/migration/MigrationRunner.java | 23 ++++++++++++--- .../runner/DefaultMigrationContext.java | 13 +++++++-- .../migration/runner/MigrationEngine.java | 29 +++++++++++++++++-- .../src/main/java/module-info.java | 1 + .../migration/runner/MigrationTable1Test.java | 2 +- .../migration/runner/MigrationTable2Test.java | 2 +- .../runner/MigrationTableAsyncTest.java | 2 +- .../MigrationTableCreateTableRaceTest.java | 2 +- .../runner/MigrationTableTestDb2.java | 2 +- 11 files changed, 76 insertions(+), 13 deletions(-) diff --git a/ebean-migration/pom.xml b/ebean-migration/pom.xml index 1269f8a..266aa0e 100644 --- a/ebean-migration/pom.xml +++ b/ebean-migration/pom.xml @@ -35,6 +35,13 @@ 2.3 + + io.ebean + ebean-api + 13.25.0 + provided + + io.ebean ebean-migration-auto diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java index a2417ad..43183bd 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java @@ -1,5 +1,7 @@ package io.ebean.migration; +import io.ebean.Database; + import java.sql.Connection; /** @@ -38,4 +40,8 @@ public interface MigrationContext { */ String basePlatform(); + /** + * The Ebean database. + */ + Database database(); } diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java index b3270f7..4f228b9 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java @@ -1,6 +1,7 @@ package io.ebean.migration; import io.avaje.applog.AppLog; +import io.ebean.Database; import io.ebean.migration.runner.MigrationEngine; import javax.sql.DataSource; @@ -41,7 +42,7 @@ public List checkState(DataSource dataSource) { * Return the migrations that would be applied if the migration is run. */ public List checkState(Connection connection) { - return run(connection, true); + return run(connection, null, true); } /** @@ -51,6 +52,13 @@ public List checkState(MigrationContext context) { return run(context, true); } + /** + * Return the migrations that would be applied if the migration is run. + */ + public List checkState(Database server) { + return run(connection(server.dataSource()), null, true); + } + /** * Run by creating a DB connection from driver, url, username defined in MigrationConfig. */ @@ -69,7 +77,7 @@ public void run(DataSource dataSource) { * Run the migrations if there are any that need running. */ public void run(Connection connection) { - run(connection, false); + run(connection, null, false); } /** @@ -79,6 +87,13 @@ public void run(MigrationContext context) { run(context, false); } + /** + * Run the migrations if there are any that need running. + */ + public void run(Database db) { + run(connection(db.dataSource()), db,false); + } + private Connection connection(DataSource dataSource) { String username = migrationConfig.getDbUsername(); try { @@ -94,9 +109,9 @@ private Connection connection(DataSource dataSource) { } /** - * Run the migrations if there are any that need running. + * Run the migrations if there are any that need running. Uses optionl DB as context */ - private List run(Connection connection, boolean checkStateOnly) { + private List run(Connection connection, Database db, boolean checkStateOnly) { return new MigrationEngine(migrationConfig, checkStateOnly).run(connection); } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java index 96bc4c0..4b559f1 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java @@ -1,5 +1,6 @@ package io.ebean.migration.runner; +import io.ebean.Database; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationContext; @@ -10,17 +11,20 @@ * * @author Roland Praml, FOCONIS AG */ -public class DefaultMigrationContext implements MigrationContext { +class DefaultMigrationContext implements MigrationContext { private final Connection connection; private final String migrationPath; private final String platform; private final String basePlatform; - public DefaultMigrationContext(MigrationConfig config, Connection connection) { + private final Database database; + + DefaultMigrationContext(MigrationConfig config, Connection connection, Database database) { this.connection = connection; this.migrationPath = config.getMigrationPath(); this.platform = config.getPlatform(); this.basePlatform = config.getBasePlatform(); + this.database = database; } @Override @@ -42,4 +46,9 @@ public String platform() { public String basePlatform() { return basePlatform; } + + @Override + public Database database() { + return database; + } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java index 60e57df..04cc543 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java @@ -1,11 +1,14 @@ package io.ebean.migration.runner; import io.avaje.applog.AppLog; +import io.ebean.TxScope; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationContext; import io.ebean.migration.MigrationException; import io.ebean.migration.MigrationResource; +import io.ebean.Database; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; import java.util.List; @@ -34,14 +37,18 @@ public MigrationEngine(MigrationConfig migrationConfig, boolean checkStateOnly) this.fastMode = !checkStateOnly && migrationConfig.isFastMode(); } + public List run(Connection connection) { + return run(connection, null); + } + /** * Run the migrations if there are any that need running. * * @param connection the connection to run on. Note the connection will be closed. */ - public List run(Connection connection) { + public List run(Connection connection, Database db) { try { - return run(new DefaultMigrationContext(migrationConfig, connection)); + return run(new DefaultMigrationContext(migrationConfig, connection, db)); } finally { close(connection); } @@ -72,6 +79,24 @@ public List run(MigrationContext context) { setAutoCommitFalse(connection); final MigrationTable table = initialiseMigrationTable(firstCheck, connection); + + + /*SpiEbeanServer defaultServer = (SpiEbeanServer)DB.get(); + + assert defaultServer != null; + + TransactionManager transactionManager = (TransactionManager)defaultServer.transactionManager(); + SpiTransaction txn = transactionManager.wrapExternalConnection(connection); + transactionManager.externalBeginTransaction(txn, TxScope.notSupported()); + + try { + this.migrate(defaultServer); + txn.flush(); + } finally { + transactionManager.externalRemoveTransaction(); + }*/ + + try { List result = runMigrations(table, resources.versions()); connection.commit(); diff --git a/ebean-migration/src/main/java/module-info.java b/ebean-migration/src/main/java/module-info.java index e0f8e22..d28c43d 100644 --- a/ebean-migration/src/main/java/module-info.java +++ b/ebean-migration/src/main/java/module-info.java @@ -6,6 +6,7 @@ requires transitive io.avaje.applog; requires transitive io.avaje.classpath.scanner; requires transitive io.ebean.ddl.runner; + requires transitive io.ebean.api; requires io.ebean.migration.auto; uses io.ebean.migration.JdbcMigration; diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java index d7880c0..5cd89bb 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java @@ -45,7 +45,7 @@ public void shutdown() { private MigrationTable migrationTable(Connection conn) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java index 4b1e6bb..f8130ce 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java @@ -12,7 +12,7 @@ public class MigrationTable2Test { private static MigrationTable migrationTable(MigrationConfig config) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, null), new MigrationPlatform()); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, null, null), new MigrationPlatform()); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java index a6795d8..e7e1235 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java @@ -204,7 +204,7 @@ private void runTest(boolean withExisting) throws SQLException, InterruptedExcep } private static MigrationTable migrationTable(MigrationPlatform platform, Connection connection) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection, null), platform); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java index 99b3d83..37b4167 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java @@ -51,7 +51,7 @@ void testRaceCondition_expect_loserOfCreateTableCanPerformTableExistsCheck() thr try (Connection conn = dataSource.getConnection()) { dropTable(conn); - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); MigrationTable table = new MigrationTable(fc, false); table.createTable(); try { diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java index 5a35392..4cd3907 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java @@ -44,7 +44,7 @@ public void testMigrationTableBase() throws Exception { config.setMigrationPath("dbmig"); try (Connection conn = dataSource.getConnection()) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); MigrationTable table = new MigrationTable(fc, false); table.createIfNeededAndLock(); table.unlockMigrationTable(); From a405ce0c72943358a693111949c618392bb06e7a Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 2 Jan 2024 09:51:28 +0100 Subject: [PATCH 10/18] add it-tests --- ebean-migration-it/pom.xml | 140 + .../src/main/java/module-info.java | 4 + .../src/main/resources/META-INF/MANIFEST.MF | 2 + .../resource-config.json | 10 + ...o.ebean.migration.auto.AutoMigrationRunner | 1 + .../default-create-table.sql | 13 + .../sqlserver-create-table.sql | 13 + .../src/test/java/dbmig/V1_2_1__test.java | 29 + .../dbplatform/h2/H2HistoryTrigger.java | 113 + .../io/ebean/migration/AutoRunnerTest.java | 49 + .../ebean/migration/MigrationConfigTest.java | 152 + .../ebean/migration/MigrationRunnerTest.java | 334 ++ .../MigrationRunner_FastCheckTest.java | 100 + .../MigrationRunner_MultiPlatformTest.java | 58 + .../MigrationRunner_PatchResetTest.java | 36 + .../migration/MigrationRunner_emptyTest.java | 29 + .../MigrationRunner_platform_Test.java | 281 + .../ebean/migration/MigrationVersionTest.java | 227 + .../migration/ServiceLoaderMigration.java | 24 + .../ebean/migration/runner/ChecksumTest.java | 18 + .../migration/runner/DbNameUtilTest.java | 62 + .../runner/MigrationEarlyModeTest.java | 86 + .../runner/MigrationMetaRowTest.java | 30 + .../runner/MigrationPlatformTest.java | 28 + .../migration/runner/MigrationSchemaTest.java | 30 + .../migration/runner/MigrationTable1Test.java | 159 + .../migration/runner/MigrationTable2Test.java | 94 + .../runner/MigrationTableAsyncTest.java | 237 + .../MigrationTableCreateTableRaceTest.java | 77 + .../runner/MigrationTableTestDb2.java | 56 + .../services/io.ebean.migration.JdbcMigration | 1 + .../resources/dbmig-roach/1.1__initial.sql | 3 + .../resources/dbmig-roach/1.2__add_m3.sql | 5 + .../test/resources/dbmig-roach/R__m2_view.sql | 2 + .../src/test/resources/dbmig/1.1__initial.sql | 5 + .../src/test/resources/dbmig/1.2__add_m3.sql | 5 + .../src/test/resources/dbmig/I__hello.sql | 1 + .../src/test/resources/dbmig/R__m2_view.sql | 1 + .../src/test/resources/dbmig2/1.3__m4.sql | 1 + .../src/test/resources/dbmig3/I__hello.sql | 1 + .../src/test/resources/dbmig3/R__m2_view.sql | 1 + .../test/resources/dbmig4/1.1__initial.sql | 5 + .../src/test/resources/dbmig4/1.2__add_m3.sql | 6 + .../src/test/resources/dbmig4/1.3__m4.sql | 1 + .../src/test/resources/dbmig4/R__m2_view.sql | 2 + .../resources/dbmig5_base/1.1__initial.sql | 5 + .../resources/dbmig5_base/1.2__add_m3.sql | 6 + .../test/resources/dbmig5_base/1.3__m4.sql | 1 + .../test/resources/dbmig5_base/I__some_i.sql | 1 + .../test/resources/dbmig5_base/R__some_r.sql | 1 + .../test/resources/dbmig5_init/1.3__m4.sql | 9 + .../test/resources/dbmig6_init/1.0__m4.sql | 9 + .../resources/dbmig_autorun/1.1__initial.sql | 3 + .../resources/dbmig_basic/1.1__initial.sql | 12 + .../resources/dbmig_basic/1.2__add_m3.sql | 9 + .../resources/dbmig_error/1.1__initial.sql | 1 + .../resources/dbmig_error/1.2__insert.sql | 1 + .../test/resources/dbmig_error/1.3__error.sql | 1 + .../dbmig_mysql/mysql-create-all.sql | 4730 ++++++++++++++++ .../resources/dbmig_mysql/mysql-drop-all.sql | 1730 ++++++ .../resources/dbmig_nuodb/1.1__initial.sql | 45 + .../resources/dbmig_oracle/1.1__initial.sql | 3 + .../resources/dbmig_oracle/1.2__add_m3.sql | 5 + .../test/resources/dbmig_oracle/I__hello.sql | 1 + .../resources/dbmig_oracle/R__m2_view.sql | 1 + .../src/test/resources/dbmig_postgres/ex1.sql | 14 + .../dbmig_postgres/pg-create-all.sql | 4745 +++++++++++++++++ .../dbmig_postgres_concurrently0/2.1__m5.sql | 3 + .../dbmig_postgres_concurrently1/2.2__m6.sql | 5 + .../dbmig_postgres_early/1.0__m0.sql | 3 + .../dbmig_postgres_early/1.1__m1.sql | 1 + .../dbmig_postgres_early1/1.0__m0.sql | 3 + .../dbmig_postgres_early1/1.1__m1.sql | 1 + .../dbmig_postgres_early1/2.0__m2.sql | 3 + .../dbmig_postgres_early1/2.1__m3.sql | 3 + .../dbmig_sqlserver/1.1__initial.sql | 12 + .../resources/dbmig_sqlserver/1.2__add_m3.sql | 9 + .../dbmig_sqlserver/I__create_procs.sql | 114 + .../test/resources/fastcheck/1.1__initial.sql | 3 + .../resources/fastcheck/idx_h2.migrations | 1 + .../test/resources/index0/1.0__initial.sql | 232 + .../src/test/resources/index0/1.1.sql | 152 + .../resources/index0/1.2__dropsFor_1.1.sql | 24 + .../src/test/resources/index0/1.3.sql | 90 + .../resources/index0/1.4__dropsFor_1.3.sql | 58 + .../test/resources/index0/idx_h2.migrations | 6 + .../test/resources/indexB_0/1.0__initial.sql | 6 + .../src/test/resources/indexB_0/1.1.sql | 1 + .../src/test/resources/indexB_0/1.2.sql | 1 + .../test/resources/indexB_1/1.0__initial.sql | 6 + .../src/test/resources/indexB_1/1.1.sql | 1 + .../src/test/resources/indexB_1/1.2.sql | 1 + .../test/resources/indexB_1/idx_h2.migrations | 4 + .../test/resources/indexB_2/1.0__initial.sql | 6 + .../src/test/resources/indexB_2/1.1.sql | 1 + .../src/test/resources/indexB_2/1.2.sql | 1 + .../src/test/resources/indexB_2/1.3.sql | 1 + .../test/resources/indexB_2/idx_h2.migrations | 5 + .../indexPatchReset_0/1.0__initial.sql | 6 + .../test/resources/indexPatchReset_0/1.1.sql | 1 + .../test/resources/indexPatchReset_0/1.2.sql | 1 + .../indexPatchReset_0/idx_h2.migrations | 4 + .../indexPatchReset_1/1.0__initial.sql | 6 + .../test/resources/indexPatchReset_1/1.1.sql | 1 + .../test/resources/indexPatchReset_1/1.2.sql | 1 + .../src/test/resources/logback-test.xml | 17 + .../multiplatform/h2/1.0__multi-initial.sql | 6 + .../multiplatform/mybase/1.0__one.sql | 4 + .../multiplatform/mybase/2.0__two.sql | 4 + .../noth2/2.0__notValidForH2.sql | 1 + .../resources/tabletest1/1.1__initial.sql | 3 + .../resources/tabletest2-err/1.1__initial.sql | 3 + .../resources/tabletest2-err/1.2__add_m3.sql | 5 + .../resources/tabletest2-err/R__m2_view.sql | 1 + .../resources/tabletest2/1.1__initial.sql | 3 + .../test/resources/tabletest2/1.2__add_m3.sql | 5 + .../test/resources/tabletest2/R__m2_view.sql | 1 + pom.xml | 1 + 118 files changed, 14696 insertions(+) create mode 100644 ebean-migration-it/pom.xml create mode 100644 ebean-migration-it/src/main/java/module-info.java create mode 100644 ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF create mode 100644 ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json create mode 100644 ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner create mode 100644 ebean-migration-it/src/main/resources/migration-support/default-create-table.sql create mode 100644 ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql create mode 100644 ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java create mode 100644 ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration create mode 100644 ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig/I__hello.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig3/I__hello.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql create mode 100644 ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations create mode 100644 ebean-migration-it/src/test/resources/index0/1.0__initial.sql create mode 100644 ebean-migration-it/src/test/resources/index0/1.1.sql create mode 100644 ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql create mode 100644 ebean-migration-it/src/test/resources/index0/1.3.sql create mode 100644 ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql create mode 100644 ebean-migration-it/src/test/resources/index0/idx_h2.migrations create mode 100644 ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_0/1.1.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_0/1.2.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_1/1.1.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_1/1.2.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations create mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.1.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.2.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.3.sql create mode 100644 ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql create mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql create mode 100644 ebean-migration-it/src/test/resources/logback-test.xml create mode 100644 ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql create mode 100644 ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql create mode 100644 ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql create mode 100644 ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql create mode 100644 ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql diff --git a/ebean-migration-it/pom.xml b/ebean-migration-it/pom.xml new file mode 100644 index 0000000..6492dfb --- /dev/null +++ b/ebean-migration-it/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + org.avaje + java11-oss + 3.12 + + + + io.ebean + ebean-migration-it + 13.11.2-SNAPSHOT + + + scm:git:git@github.com:ebean-orm/ebean-migration.git + HEAD + + + + true + false + + + + + io.ebean + ebean-migration + 13.11.2-SNAPSHOT + + + + + io.avaje + avaje-slf4j-jpl + 1.1 + test + + + + com.h2database + h2 + 2.2.220 + test + + + + com.microsoft.sqlserver + mssql-jdbc + 9.4.1.jre8 + test + + + + mysql + mysql-connector-java + 8.0.28 + test + + + + org.postgresql + postgresql + 42.4.3 + test + + + + com.nuodb.jdbc + nuodb-jdbc + 22.0.0 + test + + + + com.ibm.db2 + jcc + 11.5.6.0 + test + + + + org.mariadb.jdbc + mariadb-java-client + 3.0.6 + test + + + + com.oracle.database.jdbc + + ojdbc8 + 19.12.0.0 + test + + + + + + + + + + + + org.avaje.composite + logback + 1.1 + test + + + + io.ebean + ebean-test-containers + 7.1 + test + + + + io.avaje + junit + 1.3 + test + + + + io.ebean + ebean-datasource + 8.0 + test + + + + + diff --git a/ebean-migration-it/src/main/java/module-info.java b/ebean-migration-it/src/main/java/module-info.java new file mode 100644 index 0000000..1157961 --- /dev/null +++ b/ebean-migration-it/src/main/java/module-info.java @@ -0,0 +1,4 @@ +open module io.ebean.migration.it { + requires io.ebean.migration; + uses io.ebean.migration.JdbcMigration; +} diff --git a/ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF b/ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..8ad70ad --- /dev/null +++ b/ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: io.ebean.migration diff --git a/ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json b/ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json new file mode 100644 index 0000000..ae5a364 --- /dev/null +++ b/ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json @@ -0,0 +1,10 @@ +{ + "resources": [ + { + "pattern": ".*\\.sql" + }, + { + "pattern": ".*\\.migrations" + } + ] +} diff --git a/ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner b/ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner new file mode 100644 index 0000000..449863e --- /dev/null +++ b/ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner @@ -0,0 +1 @@ +io.ebean.migration.AutoRunner \ No newline at end of file diff --git a/ebean-migration-it/src/main/resources/migration-support/default-create-table.sql b/ebean-migration-it/src/main/resources/migration-support/default-create-table.sql new file mode 100644 index 0000000..d71224e --- /dev/null +++ b/ebean-migration-it/src/main/resources/migration-support/default-create-table.sql @@ -0,0 +1,13 @@ +create table ${table} ( + id integer not null, + mchecksum integer not null, + mtype varchar(1) not null, + mversion varchar(150) not null, + mcomment varchar(150) not null, + mstatus varchar(10) not null, + run_on timestamp not null, + run_by varchar(30) not null, + run_time integer not null, + constraint ${pk_table} primary key (id) +); + diff --git a/ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql b/ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql new file mode 100644 index 0000000..752e74c --- /dev/null +++ b/ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql @@ -0,0 +1,13 @@ +create table ${table} ( + id integer not null, + mchecksum integer not null, + mtype varchar(1) not null, + mversion varchar(150) not null, + mcomment varchar(150) not null, + mstatus varchar(10) not null, + run_on datetime2 not null, + run_by varchar(30) not null, + run_time integer not null, + constraint ${pk_table} primary key (id) +); + diff --git a/ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java b/ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java new file mode 100644 index 0000000..cc87495 --- /dev/null +++ b/ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java @@ -0,0 +1,29 @@ +package dbmig; + +import java.sql.Connection; + +import io.ebean.migration.JdbcMigration; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; + +/** + * Sample migration. + * + * @author Roland Praml, FOCONIS AG + */ +public class V1_2_1__test implements JdbcMigration { + + public static class MyDto { + String id; + } + + @Override + public void migrate(MigrationContext context) { + System.out.println("Executing migration on " + context); + } + + @Override + public String toString() { + return "Dummy jdbc migration"; + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java b/ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java new file mode 100644 index 0000000..323dd11 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java @@ -0,0 +1,113 @@ +package io.ebean.config.dbplatform.h2; + +import org.h2.api.Trigger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.*; +import java.util.Arrays; + +/** + * H2 database trigger used to populate history tables to support the @History feature. + */ +public class H2HistoryTrigger implements Trigger { + + private static final Logger logger = LoggerFactory.getLogger(H2HistoryTrigger.class); + + /** + * Hardcoding the column and history table suffix for now. Not sure how to get that + * configuration into the trigger instance nicely as it is instantiated by H2. + */ + private static final String SYS_PERIOD_START = "SYS_PERIOD_START"; + private static final String SYS_PERIOD_END = "SYS_PERIOD_END"; + private static final String HISTORY_SUFFIX = "_history"; + + /** + * SQL to insert into the history table. + */ + private String insertHistorySql; + + /** + * Position of SYS_PERIOD_START column in the Object[]. + */ + private int effectStartPosition; + + /** + * Position of SYS_PERIOD_END column in the Object[]. + */ + private int effectEndPosition; + + @Override + public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException { + // get the columns for the table + ResultSet rs = conn.getMetaData().getColumns(null, schemaName, tableName, null); + + // build the insert into history table SQL + StringBuilder insertSql = new StringBuilder(150); + insertSql.append("insert into ").append(schemaName).append(".").append(tableName).append(HISTORY_SUFFIX).append(" ("); + + int count = 0; + while (rs.next()) { + if (++count > 1) { + insertSql.append(","); + } + String columnName = rs.getString("COLUMN_NAME"); + if (columnName.equalsIgnoreCase(SYS_PERIOD_START)) { + this.effectStartPosition = count - 1; + } else if (columnName.equalsIgnoreCase(SYS_PERIOD_END)) { + this.effectEndPosition = count - 1; + } + insertSql.append(columnName); + } + insertSql.append(") values ("); + for (int i = 0; i < count; i++) { + if (i > 0) { + insertSql.append(","); + } + insertSql.append("?"); + } + insertSql.append(");"); + + this.insertHistorySql = insertSql.toString(); + logger.debug("History table insert sql: {}", insertHistorySql); + } + + @Override + public void fire(Connection connection, Object[] oldRow, Object[] newRow) throws SQLException { + if (oldRow != null) { + // a delete or update event + Timestamp now = new Timestamp(System.currentTimeMillis()); + oldRow[effectEndPosition] = now; + if (newRow != null) { + // update event. Set the effective start timestamp to now. + newRow[effectStartPosition] = now; + } + if (logger.isDebugEnabled()) { + logger.debug("History insert: {}", Arrays.toString(oldRow)); + } + insertIntoHistory(connection, oldRow); + } + } + + /** + * Insert the data into the history table. + */ + private void insertIntoHistory(Connection connection, Object[] oldRow) throws SQLException { + try (PreparedStatement stmt = connection.prepareStatement(insertHistorySql)) { + for (int i = 0; i < oldRow.length; i++) { + stmt.setObject(i + 1, oldRow[i]); + } + stmt.executeUpdate(); + } + } + + @Override + public void close() throws SQLException { + // do nothing + } + + @Override + public void remove() throws SQLException { + // do nothing + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java new file mode 100644 index 0000000..9f4db0f --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java @@ -0,0 +1,49 @@ +package io.ebean.migration; + +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.*; + +class AutoRunnerTest { + + @Test + void run() throws SQLException { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setUrl("jdbc:h2:mem:testsAutoRun"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + Properties properties = new Properties(); + properties.setProperty("dbmigration.migrationPath","dbmig_autorun"); + + AutoRunner autoRunner = new AutoRunner(); + autoRunner.setDefaultDbSchema("other"); + autoRunner.loadProperties(properties); + autoRunner.run(dataSource); + + + assertTrue(executeQuery(dataSource)); + } + + private boolean executeQuery(DataSourcePool dataSource) throws SQLException { + try (final Connection connection = dataSource.getConnection()) { + try (final PreparedStatement stmt = connection.prepareStatement("select * from m1")) { + try (final ResultSet resultSet = stmt.executeQuery()) { + return true; + } + } + } + } +} \ No newline at end of file diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java new file mode 100644 index 0000000..62c721b --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java @@ -0,0 +1,152 @@ +package io.ebean.migration; + +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.util.Properties; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class MigrationConfigTest { + + @Test + public void testDefaults() { + + MigrationConfig config = new MigrationConfig(); + + assertNull(config.getDbUrl()); + assertNull(config.getDbUsername()); + assertNull(config.getDbPassword()); + assertTrue(config.isCreateSchemaIfNotExists()); + assertTrue(config.isSetCurrentSchema()); + assertFalse(config.isSkipChecksum()); + assertFalse(config.isSkipMigrationRun()); + assertEquals(config.getMetaTable(), "db_migration"); + assertNull(config.getRunPlaceholders()); + assertEquals(config.getMigrationPath(), "dbmigration"); + assertNotNull(config.getClassLoader()); + assertNull(config.getRunPlaceholderMap()); + } + + @Test + public void loadProperties_ebean_migration() { + + Properties props = new Properties(); + props.setProperty("ebean.migration.username","username"); + props.setProperty("ebean.migration.password","password"); + props.setProperty("ebean.migration.schema","fooSchema"); + props.setProperty("ebean.migration.createSchemaIfNotExists","false"); + props.setProperty("ebean.migration.setCurrentSchema","false"); + props.setProperty("ebean.migration.skipMigrationRun","true"); + props.setProperty("ebean.migration.skipChecksum","true"); + props.setProperty("ebean.migration.driver","driver"); + props.setProperty("ebean.migration.url","url"); + props.setProperty("ebean.migration.metaTable","metaTable"); + props.setProperty("ebean.migration.placeholders","placeholders"); + props.setProperty("ebean.migration.migrationPath","migrationPath"); + props.setProperty("ebean.migration.patchResetChecksumOn", "1.1,1.2"); + + assertLoadedProperties(props); + } + + @Test + public void loadProperties() { + + Properties props = new Properties(); + props.setProperty("dbmigration.username","username"); + props.setProperty("dbmigration.password","password"); + props.setProperty("dbmigration.schema","fooSchema"); + props.setProperty("dbmigration.createSchemaIfNotExists","false"); + props.setProperty("dbmigration.setCurrentSchema","false"); + props.setProperty("dbmigration.skipMigrationRun","true"); + props.setProperty("dbmigration.skipChecksum","true"); + props.setProperty("dbmigration.driver","driver"); + props.setProperty("dbmigration.url","url"); + props.setProperty("dbmigration.metaTable","metaTable"); + props.setProperty("dbmigration.placeholders","placeholders"); + props.setProperty("dbmigration.migrationPath","migrationPath"); + props.setProperty("dbmigration.patchResetChecksumOn", "1.1,1.2"); + + assertLoadedProperties(props); + } + + private void assertLoadedProperties(Properties props) { + MigrationConfig config = new MigrationConfig(); + config.load(props); + + assertEquals(config.getDbUrl(), "url"); + assertEquals(config.getDbUsername(), "username"); + assertEquals(config.getDbPassword(), "password"); + assertEquals(config.getDbSchema(), "fooSchema"); + assertFalse(config.isCreateSchemaIfNotExists()); + assertFalse(config.isSetCurrentSchema()); + assertTrue(config.isSkipChecksum()); + assertTrue(config.isSkipMigrationRun()); + assertEquals(config.getMetaTable(), "metaTable"); + assertEquals(config.getRunPlaceholders(), "placeholders"); + assertEquals(config.getMigrationPath(), "migrationPath"); + assertThat(config.getPatchResetChecksumOn()).contains("1.1", "1.2"); + } + + @Test + public void loadProperties_withName() { + + Properties props = new Properties(); + props.setProperty("ebean.mydb.migration.username","username"); + props.setProperty("ebean.mydb.migration.migrationPath","migrationPath"); + props.setProperty("ebean.migration.password","password"); + props.setProperty("ebean.migration.schema","fooSchema"); + props.setProperty("dbmigration.url","url"); + props.setProperty("dbmigration.metaTable","metaTable"); + + MigrationConfig config = new MigrationConfig(); + config.setName("mydb"); + config.load(props); + + assertEquals(config.getDbUrl(), "url"); + assertEquals(config.getDbUsername(), "username"); + assertEquals(config.getDbPassword(), "password"); + assertEquals(config.getDbSchema(), "fooSchema"); + + assertEquals(config.getDbUrl(), "url"); + assertEquals(config.getMetaTable(), "metaTable"); + } + + @Test + public void createConnection() { + + Properties props = new Properties(); + props.setProperty("dbmigration.username","sa"); + props.setProperty("dbmigration.password",""); + props.setProperty("dbmigration.driver","org.h2.Driver"); + props.setProperty("dbmigration.url","jdbc:h2:mem:createConn"); + + MigrationConfig config = new MigrationConfig(); + config.load(props); + + Connection connection = config.createConnection(); + assertNotNull(connection); + } + + @Test + public void setResetChecksumVersionsOn() { + + MigrationConfig config = new MigrationConfig(); + config.setPatchResetChecksumOn("1.3,2.1,3.4.5,R__foo_bar"); + config.setPatchInsertOn("2.1,R__foo_bar"); + + Set resetVersions = config.getPatchResetChecksumOn(); + assertThat(resetVersions).contains("1.3", "2.1", "3.4.5", "foo_bar"); + assertThat(resetVersions).hasSize(4); + + Set insertVersions = config.getPatchInsertOn(); + assertThat(insertVersions).contains("2.1", "foo_bar"); + assertThat(insertVersions).hasSize(2); + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java new file mode 100644 index 0000000..b0e4cb5 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java @@ -0,0 +1,334 @@ +package io.ebean.migration; + +import dbmig.V1_2_1__test; +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.fail; + +public class MigrationRunnerTest { + + private MigrationConfig createMigrationConfig() { + MigrationConfig config = new MigrationConfig(); + config.setDbUsername("sa"); + config.setDbPassword(""); + config.setDbUrl("jdbc:h2:mem:dbMx1"); + + return config; + } + + @Test + public void run_when_createConnection() { + + MigrationConfig config = createMigrationConfig(); + + config.setMigrationPath("dbmig"); + MigrationRunner runner = new MigrationRunner(config); + + List check = runner.checkState(); + assertThat(check).hasSize(5); + + assertThat(check.get(0).content()).contains("-- do nothing"); + assertThat(check.get(1).content()).contains("create table m1"); + assertThat(check.get(2).content()).contains("create table m3"); + + runner.run(); + } + + @Test + public void run_when_fileSystemResources() { + + MigrationConfig config = createMigrationConfig(); + + config.setMigrationPath("filesystem:test-fs-resources/fsdbmig"); + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + } + + @Test + public void run_when_error() throws SQLException { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:err.db"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = createMigrationConfig(); + config.setMigrationPath("dbmig_error"); + MigrationRunner runner = new MigrationRunner(config); + try { + runner.run(dataSource); + } catch (Exception expected) { + try (Connection connection = dataSource.getConnection()) { + try (var pstmt = connection.prepareStatement("select count(*) from m1")) { + try (var resultSet = pstmt.executeQuery()) { + assertThat(resultSet.next()).isTrue(); + int val = resultSet.getInt(1); + assertThat(val).isEqualTo(0); + } + } catch (SQLException ex) { + fail(ex); + } + } + } + } + + @Test + public void run_when_suppliedConnection() { + + MigrationConfig config = createMigrationConfig(); + Connection connection = config.createConnection(); + + config.setMigrationPath("dbmig"); + MigrationRunner runner = new MigrationRunner(config); + runner.run(connection); + } + + @Test + public void run_when_suppliedDataSource() { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:tests"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = createMigrationConfig(); + config.setMigrationPath("dbmig"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + System.out.println("-- run second time --"); + runner.run(dataSource); + + // simulate change to repeatable migration + config.setMigrationPath("dbmig3"); + System.out.println("-- run third time --"); + runner.run(dataSource); + + config.setMigrationPath("dbmig4"); + + config.setPatchResetChecksumOn("m2_view,1.2"); + List checkState = runner.checkState(dataSource); + assertThat(checkState).hasSize(1); + assertThat(checkState.get(0).version().asString()).isEqualTo("1.3"); + + config.setPatchInsertOn("1.3"); + checkState = runner.checkState(dataSource); + assertThat(checkState).isEmpty(); + + System.out.println("-- run forth time --"); + runner.run(dataSource); + + System.out.println("-- run fifth time --"); + checkState = runner.checkState(dataSource); + assertThat(checkState).isEmpty(); + runner.run(dataSource); + + } + + @Test + public void run_with_dbinit() throws SQLException { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:testsDbInit"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = createMigrationConfig(); + config.setDbUrl("jdbc:h2:mem:testsDbInit"); + config.setMigrationPath("dbmig5_base"); + config.setMigrationInitPath("dbmig5_init"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + MigrationRunner runner2 = new MigrationRunner(config); + runner2.run(dataSource); + + try (final Connection connection = dataSource.getConnection()) { + final List names = migrationNames(connection); + assertThat(names).containsExactly("", "some_i", "m4", "some_r"); + } + } + + @Test + public void run_only_dbinit_available() throws SQLException { + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:testsDbInit2"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = createMigrationConfig(); + config.setDbUrl("jdbc:h2:mem:testsDbInit2"); + config.setMigrationPath("dbmig6_base"); + config.setMigrationInitPath("dbmig6_init"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + MigrationRunner runner2 = new MigrationRunner(config); + runner2.run(dataSource); + + try (final Connection connection = dataSource.getConnection()) { + final List names = migrationNames(connection); + assertThat(names).containsExactly("", "m4"); + } + } + + @Test + public void run_with_min_version() { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:testsMinV"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = createMigrationConfig(); + config.setMigrationPath("dbmig"); + config.setJdbcMigrations(List.of(new V1_2_1__test())); + + config.setMinVersion("1.3"); // dbmig must run, if DB is empty! + new MigrationRunner(config).run(dataSource); + + + config = createMigrationConfig(); + config.setMigrationPath("dbmig3"); + config.setMinVersion("1.3"); + config.setMinVersionFailMessage("Must run dbmig2 first."); + + MigrationRunner runner3 = new MigrationRunner(config); + assertThatThrownBy(() -> runner3.run(dataSource)) + .isInstanceOf(MigrationException.class) + .hasMessageContaining("Must run dbmig2 first. MigrationVersion mismatch: v1.2.1 < v1.3"); + + // now run dbmig2, as intended by error message + config = createMigrationConfig(); + config.setMigrationPath("dbmig2"); + new MigrationRunner(config).run(dataSource); + + // dbmig3 should pass now + runner3.run(dataSource); + } + + @Test + public void run_init_with_min_version() { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:testsMinVinit"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + // init + MigrationConfig config = createMigrationConfig(); + config.setMigrationPath("dbmig5_base"); + config.setMigrationInitPath("dbmig5_init"); + config.setMinVersion("2.0"); // init must run, although DB is empty! + new MigrationRunner(config).run(dataSource); + + // test if migration detects correct init-version (1.3) + config = createMigrationConfig(); + config.setMigrationPath("dbmig3"); + config.setMinVersion("2.0"); + + MigrationRunner runner = new MigrationRunner(config); + assertThatThrownBy(() -> runner.run(dataSource)) + .isInstanceOf(MigrationException.class) + .hasMessageContaining("MigrationVersion mismatch: v1.3 < v2.0"); + } + + @Test + public void run_with_skipMigration() throws SQLException { + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:testsSkipMigration"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + MigrationConfig config = createMigrationConfig(); + // not actually run the migrations but populate the migration table + config.setSkipMigrationRun(true); + config.setMigrationPath("dbmig"); + + DataSourcePool dataSource = DataSourceFactory.create("skipMigration", dataSourceConfig); + new MigrationRunner(config).run(dataSource); + + // assert migrations are in the migration table + try (final Connection connection = dataSource.getConnection()) { + final List names = migrationNames(connection); + assertThat(names).containsExactly("", "hello", "initial", "add_m3", "serviceLoaded", "m2_view"); + } + + // assert the migrations didn't actually run (create the tables etc) + try (final Connection connection = dataSource.getConnection()) { + singleQueryResult(connection, "select acol from m3"); + fail(); + } catch (SQLException e) { + assertThat(e.getMessage()).contains("Table \"M3\" not found;"); + } + } + + + /** + * Run this integration test manually against CockroachDB. + */ + @Disabled + @Test + public void cockroach_integrationTest() { + + MigrationConfig config = createMigrationConfig(); + config.setDbUsername("unit"); + config.setDbPassword("unit"); + config.setDbUrl("jdbc:postgresql://127.0.0.1:26257/unit"); + config.setMigrationPath("dbmig-roach"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + } + + private List migrationNames(Connection connection) throws SQLException { + return singleQueryResult(connection, "select mcomment from db_migration"); + } + + private List singleQueryResult(Connection connection, String sql) throws SQLException { + List names = new ArrayList<>(); + try (final PreparedStatement statement = connection.prepareStatement(sql)) { + try (final ResultSet resultSet = statement.executeQuery()) { + while (resultSet.next()) { + names.add(resultSet.getString(1)); + } + } + } + return names; + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java new file mode 100644 index 0000000..6c158c3 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java @@ -0,0 +1,100 @@ +package io.ebean.migration; + +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MigrationRunner_FastCheckTest { + + private MigrationConfig createMigrationConfig() { + MigrationConfig config = new MigrationConfig(); + config.setDbUsername("sa"); + config.setDbPassword(""); + config.setDbUrl("jdbc:h2:mem:dbMxFastCheck"); + + return config; + } + + @Test + public void run_when_createConnection() { + + MigrationConfig config = createMigrationConfig(); + + config.setPlatform("h2"); + config.setMigrationPath("fastcheck"); + + MigrationRunner runner = new MigrationRunner(config); + + runner.run(); + } + + @Test + public void run_when() { + + MigrationConfig config = createMigrationConfig(); + + config.setPlatform("h2"); + config.setMigrationPath("index0"); + + MigrationRunner runner = new MigrationRunner(config); + + runner.run(); + } + + @Test + public void autoEnableEarlyMode_when_indexFileAddedToExistingMigrations() { + + String url = "jdbc:h2:mem:autoEnableEarlyMode"; + DataSourceConfig dataSourceConfig = new DataSourceConfig() + .setUrl(url) + .setUsername("sa") + .setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = new MigrationConfig(); + config.setPlatform("h2"); + config.setRunPlaceholderMap(Map.of("my_table_name", "bar")); + + // initial traditional migration + config.setMigrationPath("indexB_0"); + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + assertThat(config.isEarlyChecksumMode()).isFalse(); + + // add an index file now, expect automatically go to early mode + patch checksums + config.setMigrationPath("indexB_1"); + new MigrationRunner(config).run(dataSource); + assertThat(config.isEarlyChecksumMode()).isTrue(); + + // early mode via row + add an extra migration + config.setMigrationPath("indexB_2"); + new MigrationRunner(config).run(dataSource); + + dataSource.shutdown(); + } + + @Test + public void autoEnableEarlyMode() { + + MigrationConfig config = createMigrationConfig(); + + config.setPlatform("h2"); + config.setMigrationPath("indexB_1"); + config.setDbUrl("jdbc:h2:mem:autoEnableEarlyMode_simple"); + config.setRunPlaceholderMap(Map.of("my_table_name", "bar")); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + assertThat(config.isEarlyChecksumMode()).isTrue(); + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java new file mode 100644 index 0000000..33c6958 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java @@ -0,0 +1,58 @@ +package io.ebean.migration; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class MigrationRunner_MultiPlatformTest { + + private MigrationConfig createMigrationConfig(String memName) { + MigrationConfig config = new MigrationConfig(); + config.setDbUsername("sa"); + config.setDbPassword(""); + config.setDbUrl("jdbc:h2:mem:" + memName); + return config; + } + + @Test + void run_withPlatformOnly() { + MigrationConfig config = createMigrationConfig("dbMxMultiPlatform0"); + + config.setPlatform("h2"); + config.setMigrationPath("multiplatform"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + assertThat(runner.checkState()).hasSize(1); + } + + @Test + void run_withBase_thatDoesNotExist() { + MigrationConfig config = createMigrationConfig("dbMxMultiPlatform1"); + + config.setBasePlatform("doesNotExist"); + config.setPlatform("h2"); + config.setMigrationPath("multiplatform"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + assertThat(runner.checkState()).hasSize(1); + } + + @Test + void run_withBase() { + MigrationConfig config = createMigrationConfig("dbMxBasePlatform"); + + config.setBasePlatform("mybase"); + config.setPlatform("h2"); + config.setMigrationPath("multiplatform"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + assertThat(runner.checkState()).hasSize(2); + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java new file mode 100644 index 0000000..d57ea4a --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java @@ -0,0 +1,36 @@ +package io.ebean.migration; + +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import org.junit.jupiter.api.Test; + +class MigrationRunner_PatchResetTest { + + @Test + void patchReset() { + + String url = "jdbc:h2:mem:patchReset"; + DataSourceConfig dataSourceConfig = new DataSourceConfig() + .setUrl(url) + .setUsername("sa") + .setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); + + MigrationConfig config = new MigrationConfig(); + config.setPlatform("h2"); + + config.setMigrationPath("indexPatchReset_0"); + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + // add an index file now, expect automatically go to early mode + patch checksums + config.setMigrationPath("indexPatchReset_1"); + config.setPatchResetChecksumOn("*"); + new MigrationRunner(config).run(dataSource); + + dataSource.shutdown(); + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java new file mode 100644 index 0000000..1b24355 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java @@ -0,0 +1,29 @@ +package io.ebean.migration; + +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import org.junit.jupiter.api.Test; + +class MigrationRunner_emptyTest { + + @Test + void run_withDatasource_expectNoLeak() { + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setDriver("org.h2.Driver"); + dataSourceConfig.setUrl("jdbc:h2:mem:dbEmpty1"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + + DataSourcePool dataSource = DataSourceFactory.create("test-empty", dataSourceConfig); + + MigrationConfig config = new MigrationConfig(); + config.setMigrationPath("empty-dbmig"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + dataSource.shutdown(); + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java new file mode 100644 index 0000000..8f6e6a9 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java @@ -0,0 +1,281 @@ +package io.ebean.migration; + +import io.ebean.ddlrunner.DdlRunner; +import io.ebean.test.containers.*; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MigrationRunner_platform_Test { + + private final NuoDBContainer nuoDBContainer = createNuoDB(); + private final PostgresContainer postgresContainer = createPostgres(); + private final SqlServerContainer sqlServerContainer = createSqlServer(); + private final MySqlContainer mysqlContainer = createMySqlContainer(); + private final OracleContainer oracleContainer = createOracleContainer(); + + private static void setContainerName(ContainerBuilderDb config, String suffix) { + config.containerName("test_ebean_migration_" + suffix); + config.user("mig_test"); + config.dbName("mig_test"); + } + + private static NuoDBContainer createNuoDB() { + return NuoDBContainer.builder("4.0") + .schema("mig_test") + .user("mig_test") + .password("test") + .build(); + } + + private static PostgresContainer createPostgres() { + PostgresContainer.Builder builder = PostgresContainer.builder("15") + .port(9823); + setContainerName(builder, "pg15"); + return builder.build(); + } + + private static SqlServerContainer createSqlServer() { + SqlServerContainer.Builder builder = SqlServerContainer.builder("2017-GA-ubuntu").port(2433); + setContainerName(builder, "sql17"); + return builder.build(); + } + + private static MySqlContainer createMySqlContainer() { + MySqlContainer.Builder builder = MySqlContainer.builder("8.0").port(14306); + setContainerName(builder, "mysql"); + return builder.build(); + } + + private static OracleContainer createOracleContainer() { + OracleContainer.Builder builder = OracleContainer.builder("latest"); + setContainerName(builder, "oracle"); + return builder + .dbName("XE") + .image("oracleinanutshell/oracle-xe-11g:latest") + .build(); + } + + private MigrationConfig newMigrationConfig() { + MigrationConfig config = new MigrationConfig(); + config.setDbUsername("mig_test"); + config.setDbPassword("test"); + return config; + } + + private MigrationConfig postgresMigrationConfig() { + MigrationConfig config = newMigrationConfig(); + config.setDbUrl(postgresContainer.jdbcUrl()); + return config; + } + + private MigrationConfig sqlServerMigrationConfig() { + MigrationConfig config = newMigrationConfig(); + config.setDbPassword("SqlS3rv#r"); + config.setDbUrl(sqlServerContainer.jdbcUrl()); + return config; + } + + private MigrationConfig nuodDbMigrationConfig() { + MigrationConfig config = newMigrationConfig(); + config.setDbUrl(nuoDBContainer.jdbcUrl()); + config.setDbSchema("mig_test"); + config.setDbUsername("mig_test"); + config.setDbPassword("test"); + return config; + } + + private MigrationConfig mysqlMigrationConfig() { + MigrationConfig config = newMigrationConfig(); + config.setDbUrl(mysqlContainer.jdbcUrl()); + return config; + } + + private MigrationConfig oracleMigrationConfig() { + MigrationConfig config = newMigrationConfig(); + config.setDbUrl(oracleContainer.jdbcUrl()); + return config; + } + + @Test + public void postgres_migration() throws SQLException { + + postgresContainer.startWithDropCreate(); + + MigrationConfig config = postgresMigrationConfig(); + + config.setMigrationPath("dbmig"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + System.out.println("-- run 2 --"); + runner.run(); + + System.out.println("-- run 3 --"); + config.setMigrationPath("dbmig2"); + runner.run(); + + try (Connection connection = postgresContainer.createConnection()) { + assertThat(readQuery(connection, "select * from m1")).isEqualTo(0); + readQuery(connection, "select * from m2"); + readQuery(connection, "select * from m3"); + } + + config.setMigrationPath("dbmig_postgres_concurrently0"); + runner.run(); + + config.setMigrationPath("dbmig_postgres_concurrently1"); + runner.run(); + + ddlRunnerBasic(); + ddlRunnerWithConcurrently(); + try (Connection connection = postgresContainer.createConnection()) { + assertThat(readQuery(connection, "select * from m1")).isEqualTo(6); + } + + postgresContainer.stopRemove(); + } + + private void ddlRunnerWithConcurrently() throws SQLException { + String content = + "insert into m1 (id, acol) values (2001, '2one');\n" + + "insert into m1 (id, acol) values (2002, '2two');\n" + + "insert into m1 (id, acol) values (2003, '2three');\n" + + "create index concurrently ix2_m1_acol0 on m1 (acol);\n" + + "create index concurrently ix2_m1_acol1 on m1 (lower(acol), id);\n"; + + try (Connection connection = postgresContainer.createConnection()) { + connection.setAutoCommit(false); + DdlRunner runner = new DdlRunner(false, "test", "postgres"); + runner.runAll(content, connection); + connection.commit(); + + assertThat(runner.runNonTransactional(connection)).isEqualTo(2).as("executed create index concurrently"); + } + } + + private void ddlRunnerBasic() throws SQLException { + + String content = + "insert into m1 (id, acol) values (1001, 'one');\n" + + "insert into m1 (id, acol) values (1002, 'two');\n" + + "insert into m1 (id, acol) values (1003, 'three');\n"; + + try (Connection connection = postgresContainer.createConnection()) { + connection.setAutoCommit(false); + DdlRunner runner = new DdlRunner(false, "test"); + runner.runAll(content, connection); + connection.commit(); + + assertThat(runner.runNonTransactional(connection)).isEqualTo(0).as("all transactional"); + } + } + + @Disabled + @Test + public void sqlServer_migration() throws SQLException { + + sqlServerContainer.startWithDropCreate(); + + MigrationConfig config = sqlServerMigrationConfig(); + + config.setMigrationPath("dbmig_sqlserver"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + try (Connection connection = sqlServerContainer.createConnection()) { + readQuery(connection, "select * from m1"); + readQuery(connection, "select * from m2"); + readQuery(connection, "select * from m3"); + } + +// sqlServerContainer.stopRemove(); + } + + @Test + public void mysql_migration() throws SQLException { + + mysqlContainer.stopRemove(); + mysqlContainer.startWithDropCreate(); + + MigrationConfig config = mysqlMigrationConfig(); + + config.setMigrationPath("dbmig_basic"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + try (Connection connection = mysqlContainer.createConnection()) { + readQuery(connection, "select * from m1"); + readQuery(connection, "select * from m2"); + readQuery(connection, "select * from m3"); + } + + mysqlContainer.stopRemove(); + } + + @Disabled + @Test + public void nuodb_migration() throws SQLException { + + //nuoDBContainer.stopRemove(); + nuoDBContainer.startWithDropCreate(); + + MigrationConfig config = nuodDbMigrationConfig(); + config.setMigrationPath("dbmig_nuodb"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + try (Connection connection = nuoDBContainer.createConnection()) { + readQuery(connection, "select * from m1"); + readQuery(connection, "select * from orp_master"); + readQuery(connection, "select * from orp_master_with_history"); + } + nuoDBContainer.stop(); + } + + @Disabled + @Test + public void oracle_migration() throws SQLException { + + oracleContainer.startWithDropCreate(); + + MigrationConfig config = oracleMigrationConfig(); + + config.setMigrationPath("dbmig_basic"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(); + + try (Connection connection = oracleContainer.createConnection()) { + readQuery(connection, "select * from m1"); + readQuery(connection, "select * from m2"); + readQuery(connection, "select * from m3"); + } + + //oracleContainer.stopRemove(); + } + + private int readQuery(Connection connection, String sql) throws SQLException { + int rowCount = 0; + try (PreparedStatement stmt = connection.prepareStatement(sql)) { + try (ResultSet rset = stmt.executeQuery()) { + while (rset.next()) { + rset.getObject(1); + rowCount++; + } + } + } + return rowCount; + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java new file mode 100644 index 0000000..ce65b8c --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java @@ -0,0 +1,227 @@ +package io.ebean.migration; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class MigrationVersionTest { + + + @Test + void sort() { + + List list = new ArrayList<>(); + list.add(MigrationVersion.parse("1.1__point")); + list.add(MigrationVersion.parse("3.0__three")); + list.add(MigrationVersion.parse("1.0__init")); + list.add(MigrationVersion.parse("R__beta")); + list.add(MigrationVersion.parse("R__alpha")); + + Collections.sort(list); + + assertThat(list.get(0).comment()).isEqualTo("init"); + assertThat(list.get(1).comment()).isEqualTo("point"); + assertThat(list.get(2).comment()).isEqualTo("three"); + assertThat(list.get(3).comment()).isEqualTo("alpha"); + assertThat(list.get(4).comment()).isEqualTo("beta"); + } + + @Test + void test_subversions() { + + MigrationVersion v141 = MigrationVersion.parse("V1.4.1__comment"); + MigrationVersion v14 = MigrationVersion.parse("V1.4__comment"); + assertThat(v141).isGreaterThan(v14); + assertThat(v14).isLessThan(v141); + } + + @Test + void test_parse_hyphenSnapshot() { + + MigrationVersion version = MigrationVersion.parse("0.1.1-SNAPSHOT"); + assertThat(version.normalised()).isEqualTo("0.1.1"); + assertThat(version.comment()).isEqualTo(""); + assertThat(version.type()).isEqualTo("V"); + } + + @Test + void test_parse_hyphenSnapshot_when_underscores() { + + MigrationVersion version = MigrationVersion.parse("0_1_1-SNAPSHOT__Foo"); + assertThat(version.normalised()).isEqualTo("0.1.1"); + assertThat(version.comment()).isEqualTo("Foo"); + } + + @Test + void test_parse_when_repeatable() { + + MigrationVersion version = MigrationVersion.parse("R__Foo"); + assertThat(version.comment()).isEqualTo("Foo"); + assertThat(version.isRepeatable()).isTrue(); + assertThat(version.normalised()).isEqualTo("R"); + assertThat(version.type()).isEqualTo("R"); + } + + @Test + void test_parse_when_init() { + + MigrationVersion version = MigrationVersion.parse("I__Foo"); + assertThat(version.comment()).isEqualTo("Foo"); + assertThat(version.isRepeatable()).isTrue(); + assertThat(version.normalised()).isEqualTo("I"); + assertThat(version.type()).isEqualTo("I"); + } + + @Test + void test_parse_when_repeatable_R1() { + + MigrationVersion version = MigrationVersion.parse("R1__Foo"); + assertThat(version.comment()).isEqualTo("Foo"); + assertThat(version.normalised()).isEqualTo("R"); + assertThat(version.isRepeatable()).isTrue(); + assertThat(version.type()).isEqualTo("R"); + } + + @Test + void test_parse_when_repeatable_case() { + + MigrationVersion version = MigrationVersion.parse("r__Foo"); + assertThat(version.isRepeatable()).isTrue(); + assertThat(version.comment()).isEqualTo("Foo"); + assertThat(version.normalised()).isEqualTo("R"); + assertThat(version.type()).isEqualTo("R"); + } + + @Test + void test_parse_when_v_prefix() { + + MigrationVersion version = MigrationVersion.parse("v1_0__Foo"); + assertThat(version.isRepeatable()).isFalse(); + assertThat(version.comment()).isEqualTo("Foo"); + assertThat(version.normalised()).isEqualTo("1.0"); + assertThat(version.asString()).isEqualTo("1_0"); + assertThat(version.raw()).isEqualTo("1_0__Foo"); + assertThat(version.type()).isEqualTo("V"); + } + + @Test + void test_parse_when_sql_suffix() { + + MigrationVersion version = MigrationVersion.parse("v1_0__Foo.sql"); + assertThat(version.isRepeatable()).isFalse(); + assertThat(version.comment()).isEqualTo("Foo"); + assertThat(version.normalised()).isEqualTo("1.0"); + assertThat(version.asString()).isEqualTo("1_0"); + assertThat(version.raw()).isEqualTo("1_0__Foo"); + assertThat(version.type()).isEqualTo("V"); + } + + @Test + void repeatable_compareTo() { + + MigrationVersion foo = MigrationVersion.parse("R__Foo"); + MigrationVersion bar = MigrationVersion.parse("R__Bar"); + assertThat(foo.compareTo(bar)).isGreaterThan(0); + assertThat(bar.compareTo(foo)).isLessThan(0); + + MigrationVersion bar2 = MigrationVersion.parse("R__Bar"); + assertThat(bar.compareTo(bar2)).isEqualTo(0); + } + + @Test + void repeatable_init_compareTo() { + + MigrationVersion foo = MigrationVersion.parse("R__Foo"); + MigrationVersion goo = MigrationVersion.parse("I__Goo"); + assertThat(foo.compareTo(goo)).isGreaterThan(0); + assertThat(goo.compareTo(foo)).isLessThan(0); + } + + @Test + void repeatable_compareTo_when_caseDifferent() { + + MigrationVersion none = MigrationVersion.parse("R__"); + MigrationVersion bar = MigrationVersion.parse("R__Bar"); + MigrationVersion bar2 = MigrationVersion.parse("R__bar"); + assertThat(none.compareTo(bar)).isLessThan(0); + assertThat(bar.compareTo(bar2)).isLessThan(0); + assertThat(none.compareTo(bar2)).isLessThan(0); + } + + @Test + void test_parse_getComment(){ + + assertThat(MigrationVersion.parse("1.1.1_2__Foo").comment()).isEqualTo("Foo"); + assertThat(MigrationVersion.parse("1.1.1.2__junk").comment()).isEqualTo("junk"); + assertThat(MigrationVersion.parse("1.1_1.2_foo").comment()).isEqualTo(""); + assertThat(MigrationVersion.parse("1.1_1.2_d").comment()).isEqualTo(""); + assertThat(MigrationVersion.parse("1.1_1.2_").comment()).isEqualTo(""); + assertThat(MigrationVersion.parse("1.1_1.2").comment()).isEqualTo(""); + } + + @Test + void test_nextVersion_expect_preserveUnderscores() { + + assertThat(MigrationVersion.parse("2").nextVersion()).isEqualTo("3"); + assertThat(MigrationVersion.parse("1.0").nextVersion()).isEqualTo("1.1"); + assertThat(MigrationVersion.parse("2.0.b34").nextVersion()).isEqualTo("2.1"); + assertThat(MigrationVersion.parse("1.1.1_2__Foo").nextVersion()).isEqualTo("1.1.1_3"); + assertThat(MigrationVersion.parse("1.1.1.2_junk").nextVersion()).isEqualTo("1.1.1.3"); + assertThat(MigrationVersion.parse("1_2.3_4__Foo").nextVersion()).isEqualTo("1_2.3_5"); + assertThat(MigrationVersion.parse("1_2.3_4_").nextVersion()).isEqualTo("1_2.3_5"); + assertThat(MigrationVersion.parse("1_2_3_4__Foo").nextVersion()).isEqualTo("1_2_3_5"); + } + + @Test + void test_normalised_expect_periods() { + + assertThat(MigrationVersion.parse("2").normalised()).isEqualTo("2"); + assertThat(MigrationVersion.parse("1.0").normalised()).isEqualTo("1.0"); + assertThat(MigrationVersion.parse("2.0.b34").normalised()).isEqualTo("2.0"); + assertThat(MigrationVersion.parse("1.1.1_2__Foo").normalised()).isEqualTo("1.1.1.2"); + assertThat(MigrationVersion.parse("1.1.1.2_junk").normalised()).isEqualTo("1.1.1.2"); + assertThat(MigrationVersion.parse("1_2.3_4__Foo").normalised()).isEqualTo("1.2.3.4"); + assertThat(MigrationVersion.parse("1_2.3_4_").normalised()).isEqualTo("1.2.3.4"); + assertThat(MigrationVersion.parse("1_2_3_4__Foo").normalised()).isEqualTo("1.2.3.4"); + } + + @Test + void test_compareTo_isEqual() { + + MigrationVersion v0 = MigrationVersion.parse("1.1.1_2__Foo"); + MigrationVersion v1 = MigrationVersion.parse("1.1.1.2_junk"); + MigrationVersion v2 = MigrationVersion.parse("1.1_1.2_foo"); + MigrationVersion v3 = MigrationVersion.parse("1.1_1.2__foo"); + + MigrationVersion v4 = MigrationVersion.parse("1.1_1.2"); + + assertThat(v0.compareTo(v1)).isEqualTo(0); + assertThat(v1.compareTo(v0)).isEqualTo(0); + assertThat(v1.compareTo(v2)).isEqualTo(0); + + assertThat(v0.compareTo(v3)).isEqualTo(0); + assertThat(v3.compareTo(v0)).isEqualTo(0); + + assertThat(v4.compareTo(v2)).isEqualTo(0); + } + + @Test + void test_compareTo() { + + MigrationVersion v0 = MigrationVersion.parse("1.1.1.1_junk"); + MigrationVersion v1 = MigrationVersion.parse("1.1.1.2_junk"); + MigrationVersion v2 = MigrationVersion.parse("1.1_1.3_junk"); + MigrationVersion v3 = MigrationVersion.parse("1.2_1.2_junk"); + MigrationVersion v4 = MigrationVersion.parse("2.1_1.2_junk"); + + assertThat(v1.compareTo(v0)).isEqualTo(1); + + assertThat(v1.compareTo(v2)).isEqualTo(-1); + assertThat(v1.compareTo(v3)).isEqualTo(-1); + assertThat(v1.compareTo(v4)).isEqualTo(-1); + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java b/ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java new file mode 100644 index 0000000..c23dbc7 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java @@ -0,0 +1,24 @@ +package io.ebean.migration; + +import java.sql.Connection; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class ServiceLoaderMigration implements JdbcMigration { + + @Override + public String getName() { + return "1.4.1__serviceLoaded"; + } + + @Override + public void migrate(MigrationContext context) { + + } + + @Override + public boolean matches(MigrationContext context) { + return "dbmig".equals(context.migrationPath()); + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java new file mode 100644 index 0000000..4010b94 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java @@ -0,0 +1,18 @@ +package io.ebean.migration.runner; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +public class ChecksumTest { + + @Test + void test_calculate() { + + int checkFoo = Checksum.calculate("foo"); + + assertThat(Checksum.calculate("foo")).isEqualTo(checkFoo); + assertThat(Checksum.calculate("Foo")).isNotEqualTo(checkFoo); + } + +} \ No newline at end of file diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java new file mode 100644 index 0000000..552c07c --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java @@ -0,0 +1,62 @@ +package io.ebean.migration.runner; + +import io.ebean.migration.MigrationConfig; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.sql.SQLException; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DbNameUtilTest { + + /** + * Run manually against Postgres database. + */ + @Disabled + @Test + public void normalise_when_realPostgres() throws SQLException { + + MigrationConfig config = createConfig(); + // assumes DB unit exists on our local postgres database + config.setDbUrl("jdbc:postgresql://127.0.0.1:5432/unit"); + + try (Connection connection = config.createConnection()) { + String platformName = DbNameUtil.normalise(connection); + + assertThat(platformName).isEqualTo("postgres"); + } catch (SQLException e) { + throw e; + } + } + + /** + * Run manually against cockroach database. + */ + @Disabled + @Test + public void normalise_when_cockroach() throws SQLException { + + MigrationConfig config = createConfig(); + // assumes DB unit exists on our local cockroach database + config.setDbUrl("jdbc:postgresql://127.0.0.1:26257/unit"); + + try (Connection connection = config.createConnection()) { + String platformName = DbNameUtil.normalise(connection); + assertThat(platformName).isEqualTo("cockroach"); + } catch (SQLException e) { + throw e; + } + } + + /** + * Assumes a DB user unit exists on the databases. + */ + private MigrationConfig createConfig() { + MigrationConfig config = new MigrationConfig(); + config.setDbUsername("unit"); + config.setDbPassword("unit"); + return config; + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java new file mode 100644 index 0000000..f88592b --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java @@ -0,0 +1,86 @@ +package io.ebean.migration.runner; + +import io.avaje.applog.AppLog; +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationRunner; +import io.ebean.test.containers.PostgresContainer; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Map; + +import static java.lang.System.Logger.Level.INFO; +import static org.assertj.core.api.Assertions.fail; + +class MigrationEarlyModeTest { + + private static final System.Logger log = AppLog.getLogger(MigrationEarlyModeTest.class); + + String un = "mig_early"; + String pw = "test"; + + private static PostgresContainer createPostgres() { + return PostgresContainer.builder("15") + .port(9823) + .containerName("pg15") + .user("mig_early") + .dbName("mig_early") + .build(); + } + + @Test + void testEarlyMode() { + createPostgres().startWithDropCreate(); + + String url = createPostgres().jdbcUrl(); + DataSourcePool dataSource = dataSource(url); + + MigrationConfig config = new MigrationConfig(); + config.setDbUrl(url); + config.setDbUsername(un); + config.setDbPassword(pw); + config.setMigrationPath("dbmig_postgres_early"); + config.setRunPlaceholderMap(Map.of("my_table_name", "my_table")); + config.setFastMode(true); + + // legacy mode + new MigrationRunner(config).run(dataSource); + + // early mode + log.log(INFO, "-- EARLY MODE -- "); + config.setEarlyChecksumMode(true); + new MigrationRunner(config).run(dataSource); + + log.log(INFO, "-- RE-RUN EARLY MODE -- "); + new MigrationRunner(config).run(dataSource); + + log.log(INFO, "-- LEGACY MODE AGAIN (will auto detect early mode) -- "); + config.setEarlyChecksumMode(false); + new MigrationRunner(config).run(dataSource); + + log.log(INFO, "-- LEGACY MODE with more migrations -- "); + + config.setRunPlaceholderMap(Map.of("my_table_name", "my_table", "other_table_name", "other")); + config.setMigrationPath("dbmig_postgres_early1"); + new MigrationRunner(config).run(dataSource); + + log.log(INFO, "-- EARLY MODE again -- "); + config.setEarlyChecksumMode(true); + new MigrationRunner(config).run(dataSource); + + } + + private DataSourcePool dataSource(String url) { + DataSourceConfig dataSourceConfig = new DataSourceConfig() + .setUrl(url) + .setUsername(un) + .setPassword(pw); + return DataSourceFactory.create("mig_early", dataSourceConfig); + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java new file mode 100644 index 0000000..d6054c8 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java @@ -0,0 +1,30 @@ +package io.ebean.migration.runner; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + + +class MigrationMetaRowTest { + + @Test + void testSelectSql() { + + final MigrationPlatform sqlServer = new MigrationPlatform.SqlServer(); + String sql = sqlServer.sqlSelectForReading("someTable"); + assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable with (updlock) order by id"); + + final MigrationPlatform noLocking = new MigrationPlatform.NoLocking(); + sql = noLocking.sqlSelectForReading("someTable"); + assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable order by id"); + + final MigrationPlatform postgres = new MigrationPlatform.Postgres(); + sql = postgres.sqlSelectForReading("someTable"); + assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable order by id for update"); + + final MigrationPlatform defaultPlatform = new MigrationPlatform(); + sql = defaultPlatform.sqlSelectForReading("someTable"); + assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable order by id for update"); + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java new file mode 100644 index 0000000..d5e1760 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java @@ -0,0 +1,28 @@ +package io.ebean.migration.runner; + +import io.ebean.ddlrunner.DdlDetect; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class MigrationPlatformTest { + + final DdlDetect pg = DdlDetect.POSTGRES; + + @Test + public void transaction_false() { + assertFalse(pg.transactional("create index concurrently foo")); + assertFalse(pg.transactional("drop index concurrently foo")); + assertFalse(pg.transactional("CREATE INDEX CONCURRENTLY foo")); + assertFalse(pg.transactional("DROP INDEX CONCURRENTLY foo")); + } + + @Test + public void transaction_true() { + assertTrue(pg.transactional("create index foo")); + assertTrue(pg.transactional("drop index foo")); + assertTrue(pg.transactional("CREATE INDEX foo")); + assertTrue(pg.transactional("DROP INDEX foo")); + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java new file mode 100644 index 0000000..82f9cdf --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java @@ -0,0 +1,30 @@ +package io.ebean.migration.runner; + +import io.ebean.migration.MigrationConfig; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; + +public class MigrationSchemaTest { + + @Test + void testCreateAndSetIfNeeded() throws Exception { + + MigrationConfig config = createMigrationConfig(); + config.setDbSchema("SOME_NEW_SCHEMA"); + config.setCreateSchemaIfNotExists(true); + + Connection connection = config.createConnection(); + + MigrationSchema.createIfNeeded(config, connection); + } + + private MigrationConfig createMigrationConfig() { + + MigrationConfig config = new MigrationConfig(); + config.setDbUsername("sa"); + config.setDbPassword(""); + config.setDbUrl("jdbc:h2:mem:db1"); + return config; + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java new file mode 100644 index 0000000..5cd89bb --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java @@ -0,0 +1,159 @@ +package io.ebean.migration.runner; + +import dbmig.V1_2_1__test; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationRunner; +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourcePool; +import io.ebean.datasource.DataSourceFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MigrationTable1Test { + + private static MigrationConfig config; + private static DataSourcePool dataSource; + private MigrationPlatform platform = new MigrationPlatform(); + + @BeforeEach + public void setUp() { + config = new MigrationConfig(); + config.setDbUsername("sa"); + config.setDbPassword(""); + config.setDbUrl("jdbc:h2:mem:db2"); + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setUrl("jdbc:h2:mem:db2"); + dataSourceConfig.setUsername("sa"); + dataSourceConfig.setPassword(""); + dataSource = DataSourceFactory.create("test", dataSourceConfig); + } + + @AfterEach + public void shutdown() { + dataSource.shutdown(); + } + + + private MigrationTable migrationTable(Connection conn) { + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); + return new MigrationTable(fc, false); + } + + @Test + public void testMigrationTableBase() throws Exception { + + config.setMigrationPath("dbmig"); + config.setJdbcMigrations(List.of(new V1_2_1__test())); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + try (Connection conn = dataSource.getConnection()) { + MigrationTable table = migrationTable(conn); + table.createIfNeededAndLock(); + assertThat(table.versions()).containsExactly("hello", "1.1", "1.2", "1.2.1", "m2_view"); + + List rawVersions = new ArrayList<>(); + try (PreparedStatement stmt = conn.prepareStatement("select mversion from db_migration order by id")) { + try (ResultSet rset = stmt.executeQuery()) { + while (rset.next()) { + rawVersions.add(rset.getString(1)); + } + } + } + assertThat(rawVersions).containsExactly("0", "hello", "1.1", "1.2", "1.2.1", "m2_view"); + table.unlockMigrationTable(); + conn.rollback(); + } + } + + + @Test + public void testMigrationTableRepeatableOk() throws Exception { + + config.setMigrationPath("tabletest1"); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + try (Connection conn = dataSource.getConnection()) { + MigrationTable table = migrationTable(conn); + table.createIfNeededAndLock(); + assertThat(table.versions()).containsExactly("1.1"); + table.unlockMigrationTable(); + conn.rollback(); + } + + config.setMigrationPath("tabletest2"); + + runner = new MigrationRunner(config); + runner.run(dataSource); + + try (Connection conn = dataSource.getConnection()) { + MigrationTable table = migrationTable(conn); + table.createIfNeededAndLock(); + assertThat(table.versions()).containsExactly("1.1", "1.2", "m2_view"); + table.unlockMigrationTable(); + conn.rollback(); + } + } + + @Test + public void testMigrationTableRepeatableFail() throws Exception { + + config.setMigrationPath("tabletest1"); + config.setAllowErrorInRepeatable(true); + + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + + try (Connection conn = dataSource.getConnection()) { + MigrationTable table = migrationTable(conn); + table.createIfNeededAndLock(); + assertThat(table.versions()).containsExactly("1.1"); + table.unlockMigrationTable(); + conn.rollback(); + } + + // now execute corrupt migration + config.setMigrationPath("tabletest2-err"); + + MigrationRunner runner2 = new MigrationRunner(config); + + runner2.run(dataSource); + + try (Connection conn = dataSource.getConnection()) { + + List m3Content = new ArrayList<>(); + try ( + // the next statement will fail, if "1.3__add_m3" is not executed + PreparedStatement stmt = conn.prepareStatement("select * from m3"); + ResultSet result = stmt.executeQuery()) { + while (result.next()) { + m3Content.add(result.getString(2)); + } + } + + // the next statement will fail, if "1.3__add_m3" is not executed + // + // BUT: currently, we will fail here. that means, the 1.3 script creates the table + // but does not insert the data. (there was not commit) This might be also a bug in H2 + assertThat(m3Content).contains("text with ; sign"); + + // we expect, that 1.1 and 1.2 is executed (but not the R__ script) + MigrationTable table = migrationTable(conn); + table.createIfNeededAndLock(); + assertThat(table.versions()).containsExactly("1.1", "1.2"); + conn.rollback(); + } + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java new file mode 100644 index 0000000..f8130ce --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java @@ -0,0 +1,94 @@ +package io.ebean.migration.runner; + +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationVersion; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class MigrationTable2Test { + + + private static MigrationTable migrationTable(MigrationConfig config) { + var fc = new FirstCheck(config, new DefaultMigrationContext(config, null, null), new MigrationPlatform()); + return new MigrationTable(fc, false); + } + + @Test + void testCreateTableDdl() throws Exception { + + MigrationConfig config = new MigrationConfig(); + config.setDbSchema("foo"); + + MigrationTable mt = migrationTable(config); + String tableSql = mt.createTableDdl(); + + assertThat(tableSql).contains("create table foo.db_migration "); + assertThat(tableSql).contains("constraint pk_db_migration primary key (id)"); + } + + @Test + void testCreateTableDdl_sqlserver() throws Exception { + + MigrationConfig config = new MigrationConfig(); + config.setDbSchema("bar"); + config.setPlatform(DbPlatformNames.SQLSERVER); + + MigrationTable mt = migrationTable(config); + String tableSql = mt.createTableDdl(); + + assertThat(tableSql).contains("datetime2 "); + assertThat(tableSql).contains("create table bar.db_migration "); + assertThat(tableSql).contains("constraint pk_db_migration primary key (id)"); + } + + @Test + void test_skipMigration_Repeatable() throws Exception { + + MigrationConfig config = new MigrationConfig(); + + LocalMigrationResource local = local("R__hello"); + MigrationMetaRow existing = new MigrationMetaRow(12, "R", "", "comment", 42, null, null, 0); + + MigrationTable mt = migrationTable(config); + // checksum different - no skip + assertFalse(mt.skipMigration(100, 100, local, existing)); + // checksum same - skip + assertTrue(mt.skipMigration(42, 42, local, existing)); + } + + @Test + void test_skipMigration_skipChecksum() throws Exception { + + MigrationConfig config = new MigrationConfig(); + config.setSkipChecksum(true); + + MigrationTable mt = migrationTable(config); + + // skip regardless of checksum difference + LocalMigrationResource local = local("R__hello"); + MigrationMetaRow existing = new MigrationMetaRow(12, "R", "", "comment", 42, null, null, 0); + + // repeatable checksum mismatch + assertFalse(mt.skipMigration(44, 44, local, existing)); + + // repeatable match checksum + assertTrue(mt.skipMigration(42, 42, local, existing)); + // assertTrue(mt.skipMigration(99, 42, local, existing)); + + LocalMigrationResource localVer = local("V1__hello"); + MigrationMetaRow localExisting = new MigrationMetaRow(12, "V", "1", "comment", 42, null, null, 0); + + // re-run on checksum mismatch and skipChecksum + assertFalse(mt.skipMigration(44, 44, localVer, localExisting)); + + // match checksum so skip + assertTrue(mt.skipMigration(42, 42, localVer, localExisting)); + } + + private LocalMigrationResource local(String raw) { + return new LocalDdlMigrationResource(MigrationVersion.parse(raw), "loc", null); + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java new file mode 100644 index 0000000..e7e1235 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java @@ -0,0 +1,237 @@ +package io.ebean.migration.runner; + +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationRunner; +import io.ebean.test.containers.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MigrationTableAsyncTest { + + private static MigrationConfig config; + private static DataSourcePool dataSource; + + @BeforeEach + public void setUp() { + config = new MigrationConfig(); + config.setMetaTable("migtable"); + config.setMigrationPath("dbmig"); + } + + @AfterEach + public void shutdown() { + dataSource.shutdown(); + } + + @Disabled + @Test + public void testDb2() throws Exception { + // Note: Holding any lock during "reorg table" does not work + // (checked row lock and 'lock table x in exclusive mode') + // as soon as reorg table is executed, all locks held by the current + // connection are dropped + // See comment in 1.1__initial.sql + + Db2Container container = Db2Container.builder("latest") + .port(50055) + .containerName("mig_async_db2") + .dbName("mig_test") + .user("test_ebean") + .password("test") + .build(); + + container.startWithDropCreate(); + + config.setMigrationPath("dbmig"); + config.setDbUsername("test_ebean"); + config.setDbPassword("test"); + config.setDbUrl(container.jdbcUrl()); + runTest(false); + runTest(true); + } + + @Disabled + @Test + public void testOracle() throws Exception { + // init oracle docker container + OracleContainer container = OracleContainer.builder("latest") + .dbName("XE") + .image("oracleinanutshell/oracle-xe-11g:latest") + .user("test_ebean") + .password("test") + .build(); + container.startWithDropCreate(); + + config.setMigrationPath("dbmig_oracle"); + config.setDbUsername("test_ebean"); + config.setDbPassword("test"); + config.setDbUrl(container.jdbcUrl()); + runTest(false); + runTest(true); + } + + @Test + public void testMySqlDb() throws Exception { + // init mysql docker container + MySqlContainer container = MySqlContainer.builder("8.0") + .port(14307) + .containerName("mig_async_mysql") + .dbName("test_ebean") + .user("test_ebean") + .password("test") + .build(); + + container.startWithDropCreate(); + + config.setMigrationPath("dbmig"); + config.setDbUsername("test_ebean"); + config.setDbPassword("test"); + config.setDbUrl("jdbc:mysql://localhost:14307/test_ebean"); + runTest(false); + runTest(true); + } + + @Test + public void testMariaDb() throws Exception { + // init mariadb docker container + MariaDBContainer container = MariaDBContainer.builder("10") + .port(14308) + .containerName("mig_async_mariadb") + .dbName("test_ebean") + .user("test_ebean") + .password("test") + .build(); + + container.startWithDropCreate(); + + config.setMigrationPath("dbmig"); + config.setDbUsername("test_ebean"); + config.setDbPassword("test"); + config.setDbUrl("jdbc:mariadb://localhost:14308/test_ebean"); + runTest(false); + runTest(true); + } + + //@Disabled + @Test + public void testSqlServer() throws Exception { + // init sqlserver docker container + SqlServerContainer container = SqlServerContainer.builder("2017-GA-ubuntu") + .port(9435) + .containerName("mig_async_sqlserver") + .dbName("test_ebean") + .user("test_ebean") + .build(); + //conf.setPassword("SqlS3rv#r"); + + container.startWithDropCreate(); + + config.setMigrationPath("dbmig_sqlserver"); + config.setDbUsername("test_ebean"); + config.setDbPassword("SqlS3rv#r"); + config.setDbUrl("jdbc:sqlserver://localhost:9435;databaseName=test_ebean;sendTimeAsDateTime=false"); + runTest(true); + runTest(false); + } + + + /** + * H2 using logical lock mechanism. + */ + @Test + public void testH2() throws Exception { + // thread A looses the lock while thread B runs the migrations. + config.setMigrationPath("dbmig"); + config.setDbUsername("sa"); + config.setDbPassword(""); + config.setDbUrl("jdbc:h2:mem:dbAsync;LOCK_TIMEOUT=100000"); + runTest(false); + runTest(true); + } + + private void runTest(boolean withExisting) throws SQLException, InterruptedException, ExecutionException, IOException { + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setUrl(config.getDbUrl()); + dataSourceConfig.setUsername(config.getDbUsername()); + dataSourceConfig.setPassword(config.getDbPassword()); + dataSource = DataSourceFactory.create("test", dataSourceConfig); + dropTable("migtable"); + dropTable("m1"); + dropTable("m2"); + dropTable("m3"); + + if (withExisting) { + // create empty migration table + try (Connection conn = dataSource.getConnection()) { + String derivedPlatformName = DbNameUtil.normalise(conn); + + config.setPlatform(derivedPlatformName); + MigrationPlatform platform = DbNameUtil.platform(derivedPlatformName); + MigrationTable table = migrationTable(platform, conn); + table.createIfNeededAndLock(); + table.unlockMigrationTable(); + conn.commit(); + } + } + + ExecutorService exec = Executors.newFixedThreadPool(8); + List> futures = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + Future future = exec.submit(this::runMigration); + futures.add(future); + } + for (Future future : futures) { + assertThat(future.get()).isEqualTo("OK"); + } + } + + private static MigrationTable migrationTable(MigrationPlatform platform, Connection connection) { + var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection, null), platform); + return new MigrationTable(fc, false); + } + + private void dropTable(String tableName) throws SQLException { + try (Connection conn = dataSource.getConnection(); + Statement stmt = conn.createStatement()) { + String dbProductName = conn.getMetaData().getDatabaseProductName().toLowerCase(); + if (dbProductName.contains("db2")) { + stmt.execute("begin\n" + + "if exists (select tabname from syscat.tables where lcase(tabname) = '" + tableName + "' and tabschema = current_schema) then\n" + + " prepare stmt from 'drop table " + tableName + "';\n" + + " execute stmt;\n" + + "end if;\n" + + "end"); + } else if (dbProductName.contains("oracle")) { + // do nothing, re-created via container.startWithDropCreate(); + } else { + stmt.execute("drop view if exists " + tableName + "_vw"); + stmt.execute("drop table if exists " + tableName); + } + conn.commit(); + } + } + + String runMigration() { + MigrationRunner runner = new MigrationRunner(config); + runner.run(dataSource); + return "OK"; + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java new file mode 100644 index 0000000..37b4167 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java @@ -0,0 +1,77 @@ +package io.ebean.migration.runner; + +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourceFactory; +import io.ebean.datasource.DataSourcePool; +import io.ebean.migration.MigrationConfig; +import io.ebean.test.containers.PostgresContainer; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import static org.assertj.core.api.Assertions.fail; + +class MigrationTableCreateTableRaceTest { + + private final MigrationPlatform platform = new MigrationPlatform(); + + private static PostgresContainer createPostgres() { + PostgresContainer.Builder builder = PostgresContainer.builder("15") + .port(9823); + builder.containerName("pg15"); + builder.user("mig_create_test"); + builder.dbName("mig_create_test"); + return builder.build(); + } + + // @Disabled + @Test + void testRaceCondition_expect_loserOfCreateTableCanPerformTableExistsCheck() throws SQLException, IOException { + PostgresContainer postgresContainer = createPostgres(); + postgresContainer.start(); + + String url = postgresContainer.jdbcUrl(); + String un = "mig_create_test"; + String pw = "test"; + + MigrationConfig config = new MigrationConfig(); + config.setDbUrl(url); + config.setDbUsername(un); + config.setDbPassword(pw); + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setUrl(url); + dataSourceConfig.setUsername(un); + dataSourceConfig.setPassword(pw); + DataSourcePool dataSource = DataSourceFactory.create("mig_create_test", dataSourceConfig); + + try (Connection conn = dataSource.getConnection()) { + dropTable(conn); + + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); + MigrationTable table = new MigrationTable(fc, false); + table.createTable(); + try { + // simulate losing the race, this createTable() will fail as the table exists + table.createTable(); + } catch (SQLException e) { + // need rollback to allow further use of the connection + if (!table.tableExists()) { + fail("Table should exist"); + } + } + // cleanup + dropTable(conn); + } + } + + private static void dropTable(Connection conn) throws SQLException { + try (PreparedStatement stmt = conn.prepareStatement("drop table if exists db_migration")) { + stmt.executeUpdate(); + } + } + +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java new file mode 100644 index 0000000..4cd3907 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java @@ -0,0 +1,56 @@ +package io.ebean.migration.runner; + +import io.ebean.migration.MigrationConfig; +import io.ebean.datasource.DataSourceConfig; +import io.ebean.datasource.DataSourcePool; +import io.ebean.datasource.DataSourceFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.sql.Connection; + +public class MigrationTableTestDb2 { + + private static MigrationConfig config; + private static DataSourcePool dataSource; + private final MigrationPlatform platform = new MigrationPlatform(); + + @BeforeEach + public void setUp() { + config = new MigrationConfig(); + config.setDbUsername("unit"); + config.setDbPassword("test"); + config.setMetaTable("bla"); + config.setDbUrl("jdbc:db2://localhost:50000/unit:currentSchema=Sch_2;"); // Sch2 will work + + DataSourceConfig dataSourceConfig = new DataSourceConfig(); + dataSourceConfig.setUrl("jdbc:db2://localhost:50000/unit:currentSchema=Sch_2;"); + dataSourceConfig.setUsername("unit"); + dataSourceConfig.setPassword("test"); + dataSource = DataSourceFactory.create("test", dataSourceConfig); + } + + @AfterEach + public void shutdown() { + dataSource.shutdown(); + } + + @Disabled // run test manually + @Test + public void testMigrationTableBase() throws Exception { + + config.setMigrationPath("dbmig"); + + try (Connection conn = dataSource.getConnection()) { + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); + MigrationTable table = new MigrationTable(fc, false); + table.createIfNeededAndLock(); + table.unlockMigrationTable(); + table.createIfNeededAndLock(); + table.unlockMigrationTable(); + conn.commit(); + } + } +} diff --git a/ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration b/ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration new file mode 100644 index 0000000..6615228 --- /dev/null +++ b/ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration @@ -0,0 +1 @@ +io.ebean.migration.ServiceLoaderMigration diff --git a/ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql new file mode 100644 index 0000000..3518305 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql @@ -0,0 +1,5 @@ +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql new file mode 100644 index 0000000..1a92845 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql @@ -0,0 +1,2 @@ +drop view if exists m2_vw; +create view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql new file mode 100644 index 0000000..c627009 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql @@ -0,0 +1,5 @@ +create table m1 (id integer, acol varchar(20)); +-- Check with DB2: +-- call sysproc.admin_cmd('reorg table m1'); +create table m2 (id integer, acol varchar(20), bcol timestamp); + diff --git a/ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql new file mode 100644 index 0000000..3518305 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql @@ -0,0 +1,5 @@ +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig/I__hello.sql b/ebean-migration-it/src/test/resources/dbmig/I__hello.sql new file mode 100644 index 0000000..63a4934 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig/I__hello.sql @@ -0,0 +1 @@ +-- do nothing diff --git a/ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql new file mode 100644 index 0000000..6a7c4df --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql @@ -0,0 +1 @@ +create or replace view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql new file mode 100644 index 0000000..c3ed0f1 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql @@ -0,0 +1 @@ +create table m4 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig3/I__hello.sql b/ebean-migration-it/src/test/resources/dbmig3/I__hello.sql new file mode 100644 index 0000000..a36d833 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig3/I__hello.sql @@ -0,0 +1 @@ +-- do nothing again diff --git a/ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql new file mode 100644 index 0000000..f6ca6ef --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql @@ -0,0 +1 @@ +create or replace view m2_vw as select id, acol, bcol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql new file mode 100644 index 0000000..c627009 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql @@ -0,0 +1,5 @@ +create table m1 (id integer, acol varchar(20)); +-- Check with DB2: +-- call sysproc.admin_cmd('reorg table m1'); +create table m2 (id integer, acol varchar(20), bcol timestamp); + diff --git a/ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql new file mode 100644 index 0000000..5b16f78 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql @@ -0,0 +1,6 @@ + +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql new file mode 100644 index 0000000..c3ed0f1 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql @@ -0,0 +1 @@ +create table m4 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql new file mode 100644 index 0000000..e8cb9a7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql @@ -0,0 +1,2 @@ +drop view m2_vw; +create view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql new file mode 100644 index 0000000..c627009 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql @@ -0,0 +1,5 @@ +create table m1 (id integer, acol varchar(20)); +-- Check with DB2: +-- call sysproc.admin_cmd('reorg table m1'); +create table m2 (id integer, acol varchar(20), bcol timestamp); + diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql new file mode 100644 index 0000000..5b16f78 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql @@ -0,0 +1,6 @@ + +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql new file mode 100644 index 0000000..c3ed0f1 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql @@ -0,0 +1 @@ +create table m4 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql b/ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql new file mode 100644 index 0000000..8e6b5aa --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql @@ -0,0 +1 @@ +create table i_tab (icol integer); diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql b/ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql new file mode 100644 index 0000000..3eede6b --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql @@ -0,0 +1 @@ +create table r_tab (rcol integer); diff --git a/ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql new file mode 100644 index 0000000..b479b18 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql @@ -0,0 +1,9 @@ +create table m1 (id integer, acol varchar(20), addcol varchar(10)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); + +create table m3 (id integer, acol varchar(20), bcol timestamp); + +create table m4 (id integer, acol varchar(20), bcol timestamp); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql b/ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql new file mode 100644 index 0000000..b479b18 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql @@ -0,0 +1,9 @@ +create table m1 (id integer, acol varchar(20), addcol varchar(10)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); + +create table m3 (id integer, acol varchar(20), bcol timestamp); + +create table m4 (id integer, acol varchar(20), bcol timestamp); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql new file mode 100644 index 0000000..c4aaa00 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql @@ -0,0 +1,12 @@ +create table m1 +( + id integer, + acol varchar(20) +); + +create table m2 +( + id integer, + acol varchar(20), + bcol timestamp +); diff --git a/ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql new file mode 100644 index 0000000..0b975c7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql @@ -0,0 +1,9 @@ +create table m3 +( + id integer, + acol varchar(20), + bcol timestamp +); + +insert into m3 (id, acol) +VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql new file mode 100644 index 0000000..7d68a2e --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql @@ -0,0 +1 @@ +create table m1 (id integer, acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql b/ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql new file mode 100644 index 0000000..3bedec8 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql @@ -0,0 +1 @@ +insert into m1 (id, acol) values (1,'hi'); diff --git a/ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql b/ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql new file mode 100644 index 0000000..8679eef --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql @@ -0,0 +1 @@ +not valid sql diff --git a/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql b/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql new file mode 100644 index 0000000..8686f99 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql @@ -0,0 +1,4730 @@ +-- Generated by ebean unknown at 2019-07-25T07:02:24.426Z +-- init script create procs +-- 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 +$$ +create table asimple_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id integer auto_increment not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer(31) not null, + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigint auto_increment not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigint auto_increment not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigint auto_increment not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id smallint auto_increment not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime datetime(6), + country_code varchar(2), + updtime datetime(6) not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigint auto_increment not null, + name varchar(255), + cover_id bigint, + deleted tinyint(1) default 0 not null, + created_at datetime(6) not null, + last_update datetime(6) not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigint auto_increment not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id integer auto_increment not null, + name varchar(255), + author varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer(31) not null, + id integer auto_increment not null, + attribute_holder_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id integer auto_increment not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigint auto_increment not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id integer auto_increment not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id integer auto_increment not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id integer auto_increment not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id varchar(40) not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null, + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site varchar(40) not null, + usr varchar(40) not null, + access_level integer, + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid varchar(40) not null, + user_uid varchar(40) not null, + access_level integer, + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer, + version bigint not null +); + +create table bsite_user_e ( + site_id varchar(40) not null, + user_id varchar(40) not null, + access_level integer +); + +create table buser ( + id varchar(40) not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id integer auto_increment not null, + `Name` varchar(191), + `CODE` varchar(255), + last_updated datetime(6) not null, + constraint uq_bwith_qident_name unique (`Name`), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigint auto_increment not null, + name varchar(255), + period varchar(50), + local_date date, + created datetime(6) not null, + updated datetime(6) not null, + version datetime(6) not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigint auto_increment not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint auto_increment not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); + +create table bw_bean ( + id bigint auto_increment not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table cinh_ref ( + id integer auto_increment not null, + ref_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id integer auto_increment not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id integer auto_increment not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table calculation_result ( + id integer auto_increment not null, + charge double not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint auto_increment not null, + version integer not null, + constraint pk_sa_car primary key (id) +); + +create table car_accessory ( + id integer auto_increment not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigint auto_increment not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigint auto_increment not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigint auto_increment not null, + parent_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigint auto_increment not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id integer auto_increment not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id integer auto_increment not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id integer auto_increment not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + customer_id integer not null, + group_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id integer auto_increment not null, + contact_id integer, + title varchar(255), + note longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigint auto_increment not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigint auto_increment not null, + title varchar(255), + isopen tinyint(1) default 0 not null, + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigint auto_increment not null, + s3_url varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id integer auto_increment not null, + status varchar(1) comment 'status of the customer', + name varchar(40) not null, + smallnote varchar(100) comment 'Short notes regarding the customer', + anniversary date comment 'Join date of the customer', + billing_address_id smallint, + shipping_address_id smallint, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_o_customer primary key (id) +) comment='Holds external customers'; + +create table dcredit ( + id bigint auto_increment not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigint auto_increment not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated datetime(6) not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dmachine ( + id bigint auto_increment not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigint auto_increment not null, + machine_id bigint not null, + name varchar(255), + date date, + use_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigint auto_increment not null, + machine_id bigint not null, + date date, + total_kms bigint not null, + hours bigint not null, + rate decimal(38), + cost decimal(38), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigint auto_increment not null, + machine_id bigint not null, + date date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigint auto_increment not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(38), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigint auto_increment not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id varchar(40) not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigint auto_increment not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table dfk_cascade ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigint auto_increment not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigint auto_increment not null, + title varchar(127), + body varchar(255), + when_publish datetime(6), + organisation_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigint auto_increment not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); + +create table earray_bean ( + id bigint auto_increment not null, + foo integer, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + statuses varchar(1000), + vc_enums varchar(1000), + int_enums varchar(1000), + status2 varchar(1000), + version bigint not null, + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigint auto_increment not null, + name varchar(255), + phone_numbers varchar(300), + uids varchar(1000), + other_ids varchar(1000), + doubs varchar(1000), + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id integer auto_increment not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigint auto_increment not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + description longtext, + last_update datetime(6) not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigint auto_increment not null, + name varchar(255), + description longtext, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id integer auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + last_update datetime(6), + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + data longblob, + some_time varbinary(255), + last_update datetime(6) not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigint auto_increment not null, + name varchar(255), + description varbinary(80), + dob varbinary(20), + status varbinary(20), + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id integer auto_increment not null, + status integer, + name varchar(255), + description varchar(255), + some_date datetime(6), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigint auto_increment not null, + name varchar(255), + map varchar(800), + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigint auto_increment not null, + name varchar(255), + value_set varchar(700), + value_list longtext, + value_map varchar(700), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigint auto_increment not null, + name varchar(255), + value_set varchar(700), + value_list longtext, + value_map varchar(700), + plain_value varchar(500), + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigint auto_increment not null, + name varchar(255), + bean_set varchar(700), + bean_list longtext, + bean_map varchar(700), + plain_bean varchar(500), + flags varchar(50), + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigint auto_increment not null, + owner_id bigint, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigint auto_increment not null, + name varchar(255), + content longtext, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigint auto_increment not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id integer auto_increment not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigint auto_increment not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigint auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update datetime(6) not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigint auto_increment not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id integer auto_increment not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update datetime(6) not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id varchar(40) not null, + name varchar(100), + root_id varchar(40) not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id varchar(40) not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigint auto_increment not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id integer auto_increment not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id integer auto_increment not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id integer auto_increment not null, + nome_outer varchar(255), + date1 datetime(6), + date2 datetime(6), + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + ts_created datetime(6) not null, + ts_updated datetime(6) not null, + ldt_created datetime(6) not null, + ldt_updated datetime(6) not null, + odt_created datetime(6) not null, + odt_updated datetime(6) not null, + zdt_created datetime(6) not null, + zdt_updated datetime(6) not null, + instant_created datetime(6) not null, + instant_updated datetime(6) not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table einvoice ( + id bigint auto_increment not null, + invoice_date datetime(6), + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id integer auto_increment not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id integer auto_increment not null, + name_for_a varchar(255), + b_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id integer auto_increment not null, + name_for_b varchar(255), + c_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id integer auto_increment not null, + name_for_c varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigint auto_increment not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigint auto_increment not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigint auto_increment not null, + email varchar(127), + online_status tinyint(1) default 0 not null, + when_updated datetime(6) not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid integer auto_increment not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigint auto_increment not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigint auto_increment not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigint auto_increment not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigint auto_increment not null, + name varchar(255), + oneb_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigint auto_increment not null, + role_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigint auto_increment not null, + up varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigint auto_increment not null, + user_name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigint auto_increment not null, + name varchar(255), + money decimal(38), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id integer auto_increment not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id integer auto_increment not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id integer auto_increment not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id integer auto_increment not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id integer auto_increment not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id integer auto_increment not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigint auto_increment not null, + name varchar(255), + inet_address varchar(50), + inet2 varchar(255), + cdir varchar(50), + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null +); + +create table ec_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ecbl_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecbm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecm_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + number varchar(10) not null +); + +create table ecmc_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value longtext not null +); + +create table ecs_person ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table td_child ( + child_id integer auto_increment not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id integer auto_increment not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table empl ( + id bigint auto_increment not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + deleted tinyint(1) default 0 not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id integer auto_increment not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); + +create table gen_key_table ( + id bigint auto_increment not null, + description varchar(255), + constraint pk_gen_key_table primary key (id) +); + +create table grand_parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigint auto_increment not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigint auto_increment not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigint auto_increment not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigint auto_increment not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigint auto_increment not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigint auto_increment not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigint auto_increment not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + title varchar(255), + when_title datetime(6), + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id varchar(40) not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigint auto_increment not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigint auto_increment not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint auto_increment not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified datetime(6), + date_created datetime(6), + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigint auto_increment not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigint auto_increment not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigint auto_increment not null, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + dirty tinyint(1) default 0 not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + deleted tinyint(1) default 0 not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigint auto_increment not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id varchar(40) not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id varchar(40), + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id varchar(40) not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id varchar(40) not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + shipping_address_id varchar(40), + billing_address_id varchar(40), + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigint auto_increment not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id integer auto_increment not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigint auto_increment not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigint auto_increment not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigint auto_increment not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid integer auto_increment not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid integer auto_increment not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id integer auto_increment not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id varchar(40) not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigint auto_increment not null, + name varchar(255), + when_created datetime(6) not null, + when_updated datetime(6) not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigint auto_increment not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id varchar(40) not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id varchar(40) not null, + special_needs_client_id varchar(40) not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id varchar(40) not null, + name varchar(255), + primary_id varchar(40), + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id varchar(40) not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id varchar(40) not null, + address_data_id varchar(40), + contract_data_id varchar(40) not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id integer auto_increment not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id integer auto_increment not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigint auto_increment not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigint auto_increment not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigint auto_increment not null, + name varchar(255), + ms_many_a_many_b tinyint(1) default 0 not null, + ms_many_b tinyint(1) default 0 not null, + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigint auto_increment not null, + name varchar(255), + deleted tinyint(1) default 0 not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id integer auto_increment not null, + name varchar(255), + my_count integer not null, + my_lob longtext, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id integer auto_increment not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created datetime(6) not null +); + +create table o_cached_bean ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigint auto_increment not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigint auto_increment not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigint auto_increment not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocar ( + id integer auto_increment not null, + vin varchar(255), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id integer auto_increment not null, + corp_id varchar(50), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id varchar(40) not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id varchar(40) not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table oroad_show_msg ( + id integer auto_increment not null, + company_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_ordered_detail ( + id bigint auto_increment not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id bigint auto_increment not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id integer auto_increment not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id integer auto_increment not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price double, + product_id integer, + cretime datetime(6), + updtime datetime(6) not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(38), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id integer auto_increment not null, + order_id integer, + ship_time datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table organisation ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigint auto_increment not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id integer auto_increment not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigint auto_increment not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigint auto_increment not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigint auto_increment not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigint auto_increment not null, + child varchar(255), + master_id bigint, + deleted tinyint(1) default 0 not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigint auto_increment not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigint auto_increment not null, + one tinyint(1) default 0 not null, + many_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigint auto_increment not null, + topp varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid varchar(40) not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigint auto_increment not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigint auto_increment not null, + optional varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id integer auto_increment not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id integer auto_increment not null, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id varchar(40), + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id integer auto_increment not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigint auto_increment not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigint auto_increment not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigint auto_increment not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier integer auto_increment not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigint auto_increment not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigint auto_increment not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 longtext, + enc4 varbinary(30), + enc5 varbinary(40), + enc6 longblob, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_password_store_model primary key (id) +); + +create table mt_permission ( + id varchar(40) not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id integer auto_increment not null, + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id integer auto_increment not null, + persistent_file_id integer, + content longblob, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigint auto_increment not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigint auto_increment not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigint auto_increment not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigint auto_increment not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id integer auto_increment not null, + sku varchar(20), + name varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id varchar(40) not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id varchar(40) not null, + ww_id varchar(40) not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigint auto_increment not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigint auto_increment not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id varchar(40) not null, + name varchar(50), + tenant_id varchar(40), + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id varchar(40) not null, + mt_permission_id varchar(40) not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table f_second ( + id bigint auto_increment not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id integer auto_increment not null, + article_id integer, + type integer, + content longtext, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigint auto_increment not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigint auto_increment not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigint auto_increment not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigint auto_increment not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigint auto_increment not null, + sibling_a_id bigint, + test_property tinyint(1) default 0 not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id varchar(40) not null, + name varchar(255), + parent_id varchar(40), + data_container_id varchar(40), + site_address_id varchar(40), + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id varchar(40) not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigint auto_increment not null, + some_enum integer, + name varchar(255), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigint auto_increment not null, + name varchar(255), + content longblob, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigint auto_increment not null, + dow integer(1), + mth integer(1), + yr integer, + yr_mth date, + month_day date, + local_date date, + local_date_time datetime(6), + offset_date_time datetime(6), + zoned_date_time datetime(6), + local_time time, + instant datetime(6), + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigint auto_increment not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigint auto_increment not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id integer auto_increment not null, + section_id integer, + title varchar(255), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id integer auto_increment not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id integer auto_increment not null, + content longblob, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigint auto_increment not null, + description varchar(255), + event_id bigint, + units integer not null, + amount double not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigint auto_increment not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer(3) not null, + id integer auto_increment not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id integer auto_increment not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id integer auto_increment not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active tinyint(1) default 0 not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); + +create table ts_detail_two ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + master_id integer, + constraint pk_ts_detail_two primary key (id) +); + +create table t_atable_thatisrelatively ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); + +create table ts_master_two ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + active tinyint(1) default 0 not null, + constraint pk_ts_master_two primary key (id) +); + +create table tuuid_entity ( + id varchar(40) not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigint auto_increment not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id integer auto_increment not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table mt_tenant ( + id varchar(40) not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint auto_increment not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); + +create table sa_tire ( + id bigint auto_increment not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); + +create table trip ( + id integer auto_increment not null, + vehicle_driver_id integer, + destination varchar(255), + address_id smallint, + star_date datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id integer auto_increment not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table `type` ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigint auto_increment not null, + moda varchar(255), + ts datetime(6), + tstz datetime(6), + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id varchar(40) not null, + parent_id bigint, + deleted tinyint(1) default 0 not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigint auto_increment not null, + child_id varchar(40), + deleted tinyint(1) default 0 not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigint auto_increment not null, + deleted tinyint(1) default 0 not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id integer auto_increment not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount double, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id integer auto_increment not null, + name varchar(255), + description varchar(255), + date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id varchar(40) not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id varchar(40) not null, + name varchar(255), + notes varchar(255), + master_id varchar(40), + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigint auto_increment not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigint auto_increment not null, + inactive tinyint(1) default 0 not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigint auto_increment not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id integer auto_increment not null, + license_number varchar(255), + registration_date datetime(6), + lease_id bigint, + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity double, + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id integer auto_increment not null, + name varchar(255), + vehicle_id integer, + address_id smallint, + license_issued_on datetime(6), + cretime datetime(6) not null, + updtime datetime(6) not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigint auto_increment not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(38), + min_duration integer not null, + day_rate decimal(38), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table warehouses ( + id integer auto_increment not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint auto_increment not null, + version integer not null, + constraint pk_wheel primary key (id) +); + +create table sa_wheel ( + id bigint auto_increment not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); + +create table sp_car_wheel ( + id bigint auto_increment not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); + +create table g_who_props_otm ( + id bigint auto_increment not null, + name varchar(255), + version bigint not null, + when_created datetime(6) not null, + when_modified datetime(6) not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigint auto_increment not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id integer auto_increment not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id varchar(40) not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id integer auto_increment not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_organization_node_kind on organization_node (kind); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references `type` (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ts_detail_two_master_id on ts_detail_two (master_id); +alter table ts_detail_two add constraint fk_ts_detail_two_master_id foreign key (master_id) references ts_master_two (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on `type` (sub_type_id); +alter table `type` add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add column sys_period_start datetime(6) default now(6); +alter table hx_link add column sys_period_end datetime(6); +update hx_link set sys_period_start = when_created; +create table hx_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period_start datetime(6) default now(6); +alter table hi_link add column sys_period_end datetime(6); +update hi_link set sys_period_start = when_created; +create table hi_link_history( + id bigint, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period_start datetime(6) default now(6); +alter table hi_link_doc add column sys_period_end datetime(6); +create table hi_link_doc_history( + hi_link_id bigint, + hi_doc_id bigint, + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period_start datetime(6) default now(6); +alter table hi_tone add column sys_period_end datetime(6); +update hi_tone set sys_period_start = when_created; +create table hi_tone_history( + id bigint, + name varchar(255), + comments varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period_start datetime(6) default now(6); +alter table hi_tthree add column sys_period_end datetime(6); +update hi_tthree set sys_period_start = when_created; +create table hi_tthree_history( + id bigint, + hi_ttwo_id bigint, + three varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period_start datetime(6) default now(6); +alter table hi_ttwo add column sys_period_end datetime(6); +update hi_ttwo set sys_period_start = when_created; +create table hi_ttwo_history( + id bigint, + hi_tone_id bigint, + two varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period_start datetime(6) default now(6); +alter table hsd_setting add column sys_period_end datetime(6); +update hsd_setting set sys_period_start = when_created; +create table hsd_setting_history( + id bigint, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period_start datetime(6) default now(6); +alter table hsd_user add column sys_period_end datetime(6); +update hsd_user set sys_period_start = when_created; +create table hsd_user_history( + id bigint, + name varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period_start datetime(6) default now(6); +alter table link add column sys_period_end datetime(6); +update link set sys_period_start = when_created; +create table link_history( + id bigint, + name varchar(255), + location varchar(255), + when_publish datetime(6), + link_comment varchar(255), + version bigint, + when_created datetime(6), + when_modified datetime(6), + deleted tinyint(1), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period_start datetime(6) default now(6); +alter table c_user add column sys_period_end datetime(6); +update c_user set sys_period_start = when_created; +create table c_user_history( + id bigint, + inactive tinyint(1), + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint, + when_created datetime(6), + when_modified datetime(6), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +delimiter $$ +create trigger hx_link_history_upd before update on hx_link for each row begin + insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hx_link_history_del before delete on hx_link for each row begin + insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger hi_link_history_upd before update on hi_link for each row begin + insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_link_history_del before delete on hi_link for each row begin + insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_link_doc_history_upd before update on hi_link_doc for each row begin + insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_link_doc_history_del before delete on hi_link_doc for each row begin + insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); +end$$ +delimiter $$ +create trigger hi_tone_history_upd before update on hi_tone for each row begin + insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_tone_history_del before delete on hi_tone for each row begin + insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_tthree_history_upd before update on hi_tthree for each row begin + insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_tthree_history_del before delete on hi_tthree for each row begin + insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hi_ttwo_history_upd before update on hi_ttwo for each row begin + insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hi_ttwo_history_del before delete on hi_ttwo for each row begin + insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); +end$$ +delimiter $$ +create trigger hsd_setting_history_upd before update on hsd_setting for each row begin + insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hsd_setting_history_del before delete on hsd_setting for each row begin + insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger hsd_user_history_upd before update on hsd_user for each row begin + insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger hsd_user_history_del before delete on hsd_user for each row begin + insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger link_history_upd before update on link for each row begin + insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger link_history_del before delete on link for each row begin + insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); +end$$ +delimiter $$ +create trigger c_user_history_upd before update on c_user for each row begin + insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger c_user_history_del before delete on c_user for each row begin + insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); +end$$ diff --git a/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql b/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql new file mode 100644 index 0000000..c3bcf7d --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql @@ -0,0 +1,1730 @@ +-- Generated by ebean unknown at 2019-07-25T07:02:24.426Z +alter table bar drop foreign key fk_bar_foo_id; +drop index ix_bar_foo_id on bar; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_container_id; +drop index ix_acl_container_relation_container_id on acl_container_relation; + +alter table acl_container_relation drop foreign key fk_acl_container_relation_acl_entry_id; +drop index ix_acl_container_relation_acl_entry_id on acl_container_relation; + +alter table addr drop foreign key fk_addr_employee_id; +drop index ix_addr_employee_id on addr; + +alter table o_address drop foreign key fk_o_address_country_code; +drop index ix_o_address_country_code on o_address; + +alter table album drop foreign key fk_album_cover_id; + +alter table animal drop foreign key fk_animal_shelter_id; +drop index ix_animal_shelter_id on animal; + +alter table attribute drop foreign key fk_attribute_attribute_holder_id; +drop index ix_attribute_attribute_holder_id on attribute; + +alter table bbookmark drop foreign key fk_bbookmark_user_id; +drop index ix_bbookmark_user_id on bbookmark; + +alter table bbookmark_user drop foreign key fk_bbookmark_user_org_id; +drop index ix_bbookmark_user_org_id on bbookmark_user; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_site_id; +drop index ix_bsite_user_a_site_id on bsite_user_a; + +alter table bsite_user_a drop foreign key fk_bsite_user_a_user_id; +drop index ix_bsite_user_a_user_id on bsite_user_a; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_site; +drop index ix_bsite_user_b_site on bsite_user_b; + +alter table bsite_user_b drop foreign key fk_bsite_user_b_usr; +drop index ix_bsite_user_b_usr on bsite_user_b; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_site_uid; +drop index ix_bsite_user_c_site_uid on bsite_user_c; + +alter table bsite_user_c drop foreign key fk_bsite_user_c_user_uid; +drop index ix_bsite_user_c_user_uid on bsite_user_c; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_site_id; +drop index ix_bsite_user_e_site_id on bsite_user_e; + +alter table bsite_user_e drop foreign key fk_bsite_user_e_user_id; +drop index ix_bsite_user_e_user_id on bsite_user_e; + +alter table basic_draftable_bean drop foreign key fk_basic_draftable_bean_id; + +alter table drel_booking drop foreign key fk_drel_booking_agent_invoice; + +alter table drel_booking drop foreign key fk_drel_booking_client_invoice; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_category_id; +drop index ix_cepproduct_category_category_id on cepproduct_category; + +alter table cepproduct_category drop foreign key fk_cepproduct_category_product_id; +drop index ix_cepproduct_category_product_id on cepproduct_category; + +alter table cinh_ref drop foreign key fk_cinh_ref_ref_id; +drop index ix_cinh_ref_ref_id on cinh_ref; + +alter table ckey_detail drop foreign key fk_ckey_detail_parent; +drop index ix_ckey_detail_parent on ckey_detail; + +alter table ckey_parent drop foreign key fk_ckey_parent_assoc_id; +drop index ix_ckey_parent_assoc_id on ckey_parent; + +alter table calculation_result drop foreign key fk_calculation_result_product_configuration_id; +drop index ix_calculation_result_product_configuration_id on calculation_result; + +alter table calculation_result drop foreign key fk_calculation_result_group_configuration_id; +drop index ix_calculation_result_group_configuration_id on calculation_result; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_car; +drop index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels; + +alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_wheel; +drop index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_car; +drop index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors; + +alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_door; +drop index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors; + +alter table car_accessory drop foreign key fk_car_accessory_fuse_id; +drop index ix_car_accessory_fuse_id on car_accessory; + +alter table car_accessory drop foreign key fk_car_accessory_car_id; +drop index ix_car_accessory_car_id on car_accessory; + +alter table category drop foreign key fk_category_surveyobjectid; +drop index ix_category_surveyobjectid on category; + +alter table e_save_test_d drop foreign key fk_e_save_test_d_parent_id; + +alter table child_person drop foreign key fk_child_person_some_bean_id; +drop index ix_child_person_some_bean_id on child_person; + +alter table child_person drop foreign key fk_child_person_parent_identifier; +drop index ix_child_person_parent_identifier on child_person; + +alter table cke_client drop foreign key fk_cke_client_user; +drop index ix_cke_client_user on cke_client; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_class_super; + +alter table class_super_monkey drop foreign key fk_class_super_monkey_monkey; + +alter table configuration drop foreign key fk_configuration_configurations_id; +drop index ix_configuration_configurations_id on configuration; + +alter table contact drop foreign key fk_contact_customer_id; +drop index ix_contact_customer_id on contact; + +alter table contact drop foreign key fk_contact_group_id; +drop index ix_contact_group_id on contact; + +alter table contact_note drop foreign key fk_contact_note_contact_id; +drop index ix_contact_note_contact_id on contact_note; + +alter table contract_costs drop foreign key fk_contract_costs_position_id; +drop index ix_contract_costs_position_id on contract_costs; + +alter table c_conversation drop foreign key fk_c_conversation_group_id; +drop index ix_c_conversation_group_id on c_conversation; + +alter table o_customer drop foreign key fk_o_customer_billing_address_id; +drop index ix_o_customer_billing_address_id on o_customer; + +alter table o_customer drop foreign key fk_o_customer_shipping_address_id; +drop index ix_o_customer_shipping_address_id on o_customer; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_dcredit; +drop index ix_dcredit_drol_dcredit on dcredit_drol; + +alter table dcredit_drol drop foreign key fk_dcredit_drol_drol; +drop index ix_dcredit_drol_drol on dcredit_drol; + +alter table dmachine drop foreign key fk_dmachine_organisation_id; +drop index ix_dmachine_organisation_id on dmachine; + +alter table d_machine_aux_use drop foreign key fk_d_machine_aux_use_machine_id; +drop index ix_d_machine_aux_use_machine_id on d_machine_aux_use; + +alter table d_machine_stats drop foreign key fk_d_machine_stats_machine_id; +drop index ix_d_machine_stats_machine_id on d_machine_stats; + +alter table d_machine_use drop foreign key fk_d_machine_use_machine_id; +drop index ix_d_machine_use_machine_id on d_machine_use; + +alter table drot_drol drop foreign key fk_drot_drol_drot; +drop index ix_drot_drol_drot on drot_drol; + +alter table drot_drol drop foreign key fk_drot_drol_drol; +drop index ix_drot_drol_drol on drot_drol; + +alter table dc_detail drop foreign key fk_dc_detail_master_id; +drop index ix_dc_detail_master_id on dc_detail; + +alter table dfk_cascade drop foreign key fk_dfk_cascade_one_id; +drop index ix_dfk_cascade_one_id on dfk_cascade; + +alter table dfk_set_null drop foreign key fk_dfk_set_null_one_id; +drop index ix_dfk_set_null_one_id on dfk_set_null; + +alter table doc drop foreign key fk_doc_id; + +alter table doc_link drop foreign key fk_doc_link_doc; +drop index ix_doc_link_doc on doc_link; + +alter table doc_link drop foreign key fk_doc_link_link; +drop index ix_doc_link_link on doc_link; + +alter table document drop foreign key fk_document_id; + +alter table document drop foreign key fk_document_organisation_id; +drop index ix_document_organisation_id on document; + +alter table document_draft drop foreign key fk_document_draft_organisation_id; +drop index ix_document_draft_organisation_id on document_draft; + +alter table document_media drop foreign key fk_document_media_document_id; +drop index ix_document_media_document_id on document_media; + +alter table document_media_draft drop foreign key fk_document_media_draft_document_id; +drop index ix_document_media_draft_document_id on document_media_draft; + +alter table ebasic_json_map_detail drop foreign key fk_ebasic_json_map_detail_owner_id; +drop index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail; + +alter table ebasic_no_sdchild drop foreign key fk_ebasic_no_sdchild_owner_id; +drop index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild; + +alter table ebasic_sdchild drop foreign key fk_ebasic_sdchild_owner_id; +drop index ix_ebasic_sdchild_owner_id on ebasic_sdchild; + +alter table ecache_child drop foreign key fk_ecache_child_root_id; +drop index ix_ecache_child_root_id on ecache_child; + +alter table edefault_prop drop foreign key fk_edefault_prop_e_simple_usertypeid; + +alter table eemb_inner drop foreign key fk_eemb_inner_outer_id; +drop index ix_eemb_inner_outer_id on eemb_inner; + +alter table einvoice drop foreign key fk_einvoice_person_id; +drop index ix_einvoice_person_id on einvoice; + +alter table enull_collection_detail drop foreign key fk_enull_collection_detail_enull_collection_id; +drop index ix_enull_collection_detail_enull_collection_id on enull_collection_detail; + +alter table eopt_one_a drop foreign key fk_eopt_one_a_b_id; +drop index ix_eopt_one_a_b_id on eopt_one_a; + +alter table eopt_one_b drop foreign key fk_eopt_one_b_c_id; +drop index ix_eopt_one_b_c_id on eopt_one_b; + +alter table eper_addr drop foreign key fk_eper_addr_ma_country_code; +drop index ix_eper_addr_ma_country_code on eper_addr; + +alter table esoft_del_book drop foreign key fk_esoft_del_book_lend_by_id; +drop index ix_esoft_del_book_lend_by_id on esoft_del_book; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_book; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user; + +alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user; + +alter table esoft_del_down drop foreign key fk_esoft_del_down_esoft_del_mid_id; +drop index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_top_id; +drop index ix_esoft_del_mid_top_id on esoft_del_mid; + +alter table esoft_del_mid drop foreign key fk_esoft_del_mid_up_id; +drop index ix_esoft_del_mid_up_id on esoft_del_mid; + +alter table esoft_del_one_a drop foreign key fk_esoft_del_one_a_oneb_id; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_role; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user; + +alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_user; +drop index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_user; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role; + +alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_role; +drop index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role; + +alter table rawinherit_uncle drop foreign key fk_rawinherit_uncle_parent_id; +drop index ix_rawinherit_uncle_parent_id on rawinherit_uncle; + +alter table evanilla_collection_detail drop foreign key fk_evanilla_collection_detail_evanilla_collection_id; +drop index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail; + +alter table ec_enum_person_tags drop foreign key fk_ec_enum_person_tags_ec_enum_person_id; +drop index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags; + +alter table ec_person_phone drop foreign key fk_ec_person_phone_owner_id; +drop index ix_ec_person_phone_owner_id on ec_person_phone; + +alter table ecbl_person_phone_numbers drop foreign key fk_ecbl_person_phone_numbers_person_id; +drop index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers; + +alter table ecbm_person_phone_numbers drop foreign key fk_ecbm_person_phone_numbers_person_id; +drop index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers; + +alter table ecm_person_phone_numbers drop foreign key fk_ecm_person_phone_numbers_ecm_person_id; +drop index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers; + +alter table ecmc_person_phone_numbers drop foreign key fk_ecmc_person_phone_numbers_ecmc_person_id; +drop index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers; + +alter table ecs_person_phone drop foreign key fk_ecs_person_phone_ecs_person_id; +drop index ix_ecs_person_phone_ecs_person_id on ecs_person_phone; + +alter table td_child drop foreign key fk_td_child_parent_id; +drop index ix_td_child_parent_id on td_child; + +alter table empl drop foreign key fk_empl_default_address_id; +drop index ix_empl_default_address_id on empl; + +alter table esd_detail drop foreign key fk_esd_detail_master_id; +drop index ix_esd_detail_master_id on esd_detail; + +alter table grand_parent_person drop foreign key fk_grand_parent_person_some_bean_id; +drop index ix_grand_parent_person_some_bean_id on grand_parent_person; + +alter table survey_group drop foreign key fk_survey_group_categoryobjectid; +drop index ix_survey_group_categoryobjectid on survey_group; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_hx_link; +drop index ix_hx_link_doc_hx_link on hx_link_doc; + +alter table hx_link_doc drop foreign key fk_hx_link_doc_he_doc; +drop index ix_hx_link_doc_he_doc on hx_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_link; +drop index ix_hi_link_doc_hi_link on hi_link_doc; + +alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_doc; +drop index ix_hi_link_doc_hi_doc on hi_link_doc; + +alter table hi_tthree drop foreign key fk_hi_tthree_hi_ttwo_id; +drop index ix_hi_tthree_hi_ttwo_id on hi_tthree; + +alter table hi_ttwo drop foreign key fk_hi_ttwo_hi_tone_id; +drop index ix_hi_ttwo_hi_tone_id on hi_ttwo; + +alter table hsd_setting drop foreign key fk_hsd_setting_user_id; + +alter table iaf_segment drop foreign key fk_iaf_segment_status_id; +drop index ix_iaf_segment_status_id on iaf_segment; + +alter table imrelated drop foreign key fk_imrelated_owner_id; +drop index ix_imrelated_owner_id on imrelated; + +alter table info_contact drop foreign key fk_info_contact_company_id; +drop index ix_info_contact_company_id on info_contact; + +alter table info_customer drop foreign key fk_info_customer_company_id; + +alter table inner_report drop foreign key fk_inner_report_forecast_id; + +alter table drel_invoice drop foreign key fk_drel_invoice_booking; +drop index ix_drel_invoice_booking on drel_invoice; + +alter table item drop foreign key fk_item_etype; +drop index ix_item_etype on item; + +alter table item drop foreign key fk_item_eregion; +drop index ix_item_eregion on item; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_mkeygroup; + +alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_monkey; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_trainer; + +alter table trainer_monkey drop foreign key fk_trainer_monkey_monkey; + +alter table troop_monkey drop foreign key fk_troop_monkey_troop; + +alter table troop_monkey drop foreign key fk_troop_monkey_monkey; + +alter table l2_cldf_reset_bean_child drop foreign key fk_l2_cldf_reset_bean_child_parent_id; +drop index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child; + +alter table level1_level4 drop foreign key fk_level1_level4_level1; +drop index ix_level1_level4_level1 on level1_level4; + +alter table level1_level4 drop foreign key fk_level1_level4_level4; +drop index ix_level1_level4_level4 on level1_level4; + +alter table level1_level2 drop foreign key fk_level1_level2_level1; +drop index ix_level1_level2_level1 on level1_level2; + +alter table level1_level2 drop foreign key fk_level1_level2_level2; +drop index ix_level1_level2_level2 on level1_level2; + +alter table level2_level3 drop foreign key fk_level2_level3_level2; +drop index ix_level2_level3_level2 on level2_level3; + +alter table level2_level3 drop foreign key fk_level2_level3_level3; +drop index ix_level2_level3_level3 on level2_level3; + +alter table link drop foreign key fk_link_id; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_la_attr_value; +drop index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute; + +alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_attribute; +drop index ix_la_attr_value_attribute_attribute on la_attr_value_attribute; + +alter table looney drop foreign key fk_looney_tune_id; +drop index ix_looney_tune_id on looney; + +alter table mcontact drop foreign key fk_mcontact_customer_id; +drop index ix_mcontact_customer_id on mcontact; + +alter table mcontact_message drop foreign key fk_mcontact_message_contact_id; +drop index ix_mcontact_message_contact_id on mcontact_message; + +alter table mcustomer drop foreign key fk_mcustomer_shipping_address_id; +drop index ix_mcustomer_shipping_address_id on mcustomer; + +alter table mcustomer drop foreign key fk_mcustomer_billing_address_id; +drop index ix_mcustomer_billing_address_id on mcustomer; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mmachine; +drop index ix_mmachine_mgroup_mmachine on mmachine_mgroup; + +alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mgroup; +drop index ix_mmachine_mgroup_mgroup on mmachine_mgroup; + +alter table mprinter drop foreign key fk_mprinter_current_state_id; +drop index ix_mprinter_current_state_id on mprinter; + +alter table mprinter drop foreign key fk_mprinter_last_swap_cyan_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_magenta_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_yellow_id; + +alter table mprinter drop foreign key fk_mprinter_last_swap_black_id; + +alter table mprinter_state drop foreign key fk_mprinter_state_printer_id; +drop index ix_mprinter_state_printer_id on mprinter_state; + +alter table mprofile drop foreign key fk_mprofile_picture_id; +drop index ix_mprofile_picture_id on mprofile; + +alter table mrole_muser drop foreign key fk_mrole_muser_mrole; +drop index ix_mrole_muser_mrole on mrole_muser; + +alter table mrole_muser drop foreign key fk_mrole_muser_muser; +drop index ix_mrole_muser_muser on mrole_muser; + +alter table muser drop foreign key fk_muser_user_type_id; +drop index ix_muser_user_type_id on muser; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_user; +drop index ix_mail_user_inbox_mail_user on mail_user_inbox; + +alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_box; +drop index ix_mail_user_inbox_mail_box on mail_user_inbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_user; +drop index ix_mail_user_outbox_mail_user on mail_user_outbox; + +alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_box; +drop index ix_mail_user_outbox_mail_box on mail_user_outbox; + +alter table c_message drop foreign key fk_c_message_conversation_id; +drop index ix_c_message_conversation_id on c_message; + +alter table c_message drop foreign key fk_c_message_user_id; +drop index ix_c_message_user_id on c_message; + +alter table meter_contract_data drop foreign key fk_meter_contract_data_special_needs_client_id; + +alter table meter_special_needs_client drop foreign key fk_meter_special_needs_client_primary_id; + +alter table meter_version drop foreign key fk_meter_version_address_data_id; + +alter table meter_version drop foreign key fk_meter_version_contract_data_id; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_user; +drop index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role; + +alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_role; +drop index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role; + +alter table mny_b drop foreign key fk_mny_b_a_id; +drop index ix_mny_b_a_id on mny_b; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_b; +drop index ix_mny_b_mny_c_mny_b on mny_b_mny_c; + +alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_c; +drop index ix_mny_b_mny_c_mny_c on mny_b_mny_c; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_1; +drop index ix_subtopics_mny_topic_1 on subtopics; + +alter table subtopics drop foreign key fk_subtopics_mny_topic_2; +drop index ix_subtopics_mny_topic_2 on subtopics; + +alter table mp_role drop foreign key fk_mp_role_mp_user_id; +drop index ix_mp_role_mp_user_id on mp_role; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_a; +drop index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b; + +alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_b; +drop index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_b; +drop index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a; + +alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_a; +drop index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a; + +alter table my_lob_size_join_many drop foreign key fk_my_lob_size_join_many_parent_id; +drop index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_cached_bean; +drop index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country; + +alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_country; +drop index ix_o_cached_bean_country_o_country on o_cached_bean_country; + +alter table o_cached_bean_child drop foreign key fk_o_cached_bean_child_cached_bean_id; +drop index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child; + +alter table oengine drop foreign key fk_oengine_car_id; + +alter table ogear_box drop foreign key fk_ogear_box_car_id; + +alter table oroad_show_msg drop foreign key fk_oroad_show_msg_company_id; + +alter table om_ordered_detail drop foreign key fk_om_ordered_detail_master_id; +drop index ix_om_ordered_detail_master_id on om_ordered_detail; + +alter table o_order drop foreign key fk_o_order_kcustomer_id; +drop index ix_o_order_kcustomer_id on o_order; + +alter table o_order_detail drop foreign key fk_o_order_detail_order_id; +drop index ix_o_order_detail_order_id on o_order_detail; + +alter table o_order_detail drop foreign key fk_o_order_detail_product_id; +drop index ix_o_order_detail_product_id on o_order_detail; + +alter table s_order_items drop foreign key fk_s_order_items_order_uuid; +drop index ix_s_order_items_order_uuid on s_order_items; + +alter table or_order_ship drop foreign key fk_or_order_ship_order_id; +drop index ix_or_order_ship_order_id on or_order_ship; + +alter table organization_node drop foreign key fk_organization_node_parent_tree_node_id; + +alter table orp_detail drop foreign key fk_orp_detail_master_id; +drop index ix_orp_detail_master_id on orp_detail; + +alter table orp_detail2 drop foreign key fk_orp_detail2_orp_master2_id; +drop index ix_orp_detail2_orp_master2_id on orp_detail2; + +alter table oto_atwo drop foreign key fk_oto_atwo_aone_id; + +alter table oto_bchild drop foreign key fk_oto_bchild_master_id; + +alter table oto_child drop foreign key fk_oto_child_master_id; + +alter table oto_cust_address drop foreign key fk_oto_cust_address_customer_cid; + +alter table oto_level_a drop foreign key fk_oto_level_a_b_id; + +alter table oto_level_b drop foreign key fk_oto_level_b_c_id; + +alter table oto_prime_extra drop foreign key fk_oto_prime_extra_eid; + +alter table oto_sd_child drop foreign key fk_oto_sd_child_master_id; + +alter table oto_th_many drop foreign key fk_oto_th_many_oto_th_top_id; +drop index ix_oto_th_many_oto_th_top_id on oto_th_many; + +alter table oto_th_one drop foreign key fk_oto_th_one_many_id; + +alter table oto_ubprime_extra drop foreign key fk_oto_ubprime_extra_eid; + +alter table oto_user_model drop foreign key fk_oto_user_model_user_optional_id; + +alter table pfile drop foreign key fk_pfile_file_content_id; + +alter table pfile drop foreign key fk_pfile_file_content2_id; + +alter table paggview drop foreign key fk_paggview_pview_id; + +alter table pallet_location drop foreign key fk_pallet_location_zone_sid; +drop index ix_pallet_location_zone_sid on pallet_location; + +alter table parcel_location drop foreign key fk_parcel_location_parcelid; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_parent; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data; + +alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_data; +drop index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data; + +alter table parent_person drop foreign key fk_parent_person_some_bean_id; +drop index ix_parent_person_some_bean_id on parent_person; + +alter table parent_person drop foreign key fk_parent_person_parent_identifier; +drop index ix_parent_person_parent_identifier on parent_person; + +alter table c_participation drop foreign key fk_c_participation_conversation_id; +drop index ix_c_participation_conversation_id on c_participation; + +alter table c_participation drop foreign key fk_c_participation_user_id; +drop index ix_c_participation_user_id on c_participation; + +alter table persistent_file_content drop foreign key fk_persistent_file_content_persistent_file_id; + +alter table person drop foreign key fk_person_default_address_oid; +drop index ix_person_default_address_oid on person; + +alter table person_cache_email drop foreign key fk_person_cache_email_person_info_person_id; +drop index ix_person_cache_email_person_info_person_id on person_cache_email; + +alter table phones drop foreign key fk_phones_person_id; +drop index ix_phones_person_id on phones; + +alter table e_position drop foreign key fk_e_position_contract_id; +drop index ix_e_position_contract_id on e_position; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_pp; +drop index ix_pp_to_ww_pp on pp_to_ww; + +alter table pp_to_ww drop foreign key fk_pp_to_ww_wview; +drop index ix_pp_to_ww_wview on pp_to_ww; + +alter table question drop foreign key fk_question_groupobjectid; +drop index ix_question_groupobjectid on question; + +alter table r_orders drop foreign key fk_r_orders_customer; +drop index ix_r_orders_customer on r_orders; + +alter table rel_master drop foreign key fk_rel_master_detail_id; +drop index ix_rel_master_detail_id on rel_master; + +alter table resourcefile drop foreign key fk_resourcefile_parentresourcefileid; +drop index ix_resourcefile_parentresourcefileid on resourcefile; + +alter table mt_role drop foreign key fk_mt_role_tenant_id; +drop index ix_mt_role_tenant_id on mt_role; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_role; +drop index ix_mt_role_permission_mt_role on mt_role_permission; + +alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_permission; +drop index ix_mt_role_permission_mt_permission on mt_role_permission; + +alter table f_second drop foreign key fk_f_second_first; + +alter table section drop foreign key fk_section_article_id; +drop index ix_section_article_id on section; + +alter table self_parent drop foreign key fk_self_parent_parent_id; +drop index ix_self_parent_parent_id on self_parent; + +alter table self_ref_customer drop foreign key fk_self_ref_customer_referred_by_id; +drop index ix_self_ref_customer_referred_by_id on self_ref_customer; + +alter table self_ref_example drop foreign key fk_self_ref_example_parent_id; +drop index ix_self_ref_example_parent_id on self_ref_example; + +alter table e_save_test_b drop foreign key fk_e_save_test_b_sibling_a_id; + +alter table site drop foreign key fk_site_parent_id; +drop index ix_site_parent_id on site; + +alter table site drop foreign key fk_site_data_container_id; + +alter table site drop foreign key fk_site_site_address_id; + +alter table stockforecast drop foreign key fk_stockforecast_inner_report_id; +drop index ix_stockforecast_inner_report_id on stockforecast; + +alter table sub_section drop foreign key fk_sub_section_section_id; +drop index ix_sub_section_section_id on sub_section; + +alter table tevent_many drop foreign key fk_tevent_many_event_id; +drop index ix_tevent_many_event_id on tevent_many; + +alter table tevent_one drop foreign key fk_tevent_one_event_id; + +alter table t_detail_with_other_namexxxyy drop foreign key fk_t_detail_with_other_namexxxyy_master_id; +drop index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy; + +alter table ts_detail_two drop foreign key fk_ts_detail_two_master_id; +drop index ix_ts_detail_two_master_id on ts_detail_two; + +alter table twheel drop foreign key fk_twheel_owner_plate_no; +drop index ix_twheel_owner_plate_no on twheel; + +alter table tire drop foreign key fk_tire_wheel; + +alter table trip drop foreign key fk_trip_vehicle_driver_id; +drop index ix_trip_vehicle_driver_id on trip; + +alter table trip drop foreign key fk_trip_address_id; +drop index ix_trip_address_id on trip; + +alter table `type` drop foreign key fk_type_sub_type_id; +drop index ix_type_sub_type_id on `type`; + +alter table usib_child drop foreign key fk_usib_child_parent_id; +drop index ix_usib_child_parent_id on usib_child; + +alter table usib_child_sibling drop foreign key fk_usib_child_sibling_child_id; + +alter table ut_detail drop foreign key fk_ut_detail_utmaster_id; +drop index ix_ut_detail_utmaster_id on ut_detail; + +alter table uutwo drop foreign key fk_uutwo_master_id; +drop index ix_uutwo_master_id on uutwo; + +alter table oto_user drop foreign key fk_oto_user_account_id; + +alter table c_user drop foreign key fk_c_user_group_id; +drop index ix_c_user_group_id on c_user; + +alter table em_user_role drop foreign key fk_em_user_role_user_id; +drop index ix_em_user_role_user_id on em_user_role; + +alter table em_user_role drop foreign key fk_em_user_role_role_id; +drop index ix_em_user_role_role_id on em_user_role; + +alter table vehicle drop foreign key fk_vehicle_lease_id; +drop index ix_vehicle_lease_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_car_ref_id; +drop index ix_vehicle_car_ref_id on vehicle; + +alter table vehicle drop foreign key fk_vehicle_truck_ref_id; +drop index ix_vehicle_truck_ref_id on vehicle; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_vehicle_id; +drop index ix_vehicle_driver_vehicle_id on vehicle_driver; + +alter table vehicle_driver drop foreign key fk_vehicle_driver_address_id; +drop index ix_vehicle_driver_address_id on vehicle_driver; + +alter table warehouses drop foreign key fk_warehouses_officezoneid; +drop index ix_warehouses_officezoneid on warehouses; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_warehouses; +drop index ix_warehousesshippingzones_warehouses on warehousesshippingzones; + +alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_zones; +drop index ix_warehousesshippingzones_zones on warehousesshippingzones; + +alter table sa_wheel drop foreign key fk_sa_wheel_tire; +drop index ix_sa_wheel_tire on sa_wheel; + +alter table sa_wheel drop foreign key fk_sa_wheel_car; +drop index ix_sa_wheel_car on sa_wheel; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_created_id; +drop index ix_g_who_props_otm_who_created_id on g_who_props_otm; + +alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_modified_id; +drop index ix_g_who_props_otm_who_modified_id on g_who_props_otm; + +alter table with_zero drop foreign key fk_with_zero_parent_id; +drop index ix_with_zero_parent_id on with_zero; + +drop table if exists asimple_bean; + +drop table if exists bar; + +drop table if exists block; + +drop table if exists oto_account; + +drop table if exists acl; + +drop table if exists acl_container_relation; + +drop table if exists addr; + +drop table if exists address; + +drop table if exists o_address; + +drop table if exists album; + +drop table if exists animal; + +drop table if exists animal_shelter; + +drop table if exists article; + +drop table if exists attribute; + +drop table if exists attribute_holder; + +drop table if exists audit_log; + +drop table if exists bbookmark; + +drop table if exists bbookmark_org; + +drop table if exists bbookmark_user; + +drop table if exists bsimple_with_gen; + +drop table if exists bsite; + +drop table if exists bsite_user_a; + +drop table if exists bsite_user_b; + +drop table if exists bsite_user_c; + +drop table if exists bsite_user_d; + +drop table if exists bsite_user_e; + +drop table if exists buser; + +drop table if exists bwith_qident; + +drop table if exists basic_draftable_bean; + +drop table if exists basic_draftable_bean_draft; + +drop table if exists basic_joda_entity; + +drop table if exists bean_with_time_zone; + +drop table if exists drel_booking; + +drop table if exists bw_bean; + +drop table if exists cepcategory; + +drop table if exists cepproduct; + +drop table if exists cepproduct_category; + +drop table if exists cinh_ref; + +drop table if exists cinh_root; + +drop table if exists ckey_assoc; + +drop table if exists ckey_detail; + +drop table if exists ckey_parent; + +drop table if exists calculation_result; + +drop table if exists cao_bean; + +drop table if exists sp_car_car; + +drop table if exists sp_car_car_wheels; + +drop table if exists sp_car_car_doors; + +drop table if exists sa_car; + +drop table if exists car_accessory; + +drop table if exists car_fuse; + +drop table if exists category; + +drop table if exists e_save_test_d; + +drop table if exists child_person; + +drop table if exists cke_client; + +drop table if exists cke_user; + +drop table if exists class_super; + +drop table if exists class_super_monkey; + +drop table if exists configuration; + +drop table if exists configurations; + +drop table if exists contact; + +drop table if exists contact_group; + +drop table if exists contact_note; + +drop table if exists contract; + +drop table if exists contract_costs; + +drop table if exists c_conversation; + +drop table if exists o_country; + +drop table if exists cover; + +drop table if exists o_customer; + +drop table if exists dcredit; + +drop table if exists dcredit_drol; + +drop table if exists dexh_entity; + +drop table if exists dmachine; + +drop table if exists d_machine_aux_use; + +drop table if exists d_machine_stats; + +drop table if exists d_machine_use; + +drop table if exists dorg; + +drop table if exists dperson; + +drop table if exists drol; + +drop table if exists drot; + +drop table if exists drot_drol; + +drop table if exists rawinherit_data; + +drop table if exists data_container; + +drop table if exists dc_detail; + +drop table if exists dc_master; + +drop table if exists dfk_cascade; + +drop table if exists dfk_cascade_one; + +drop table if exists dfk_none; + +drop table if exists dfk_none_via_join; + +drop table if exists dfk_none_via_mto_m; + +drop table if exists dfk_none_via_mto_m_dfk_one; + +drop table if exists dfk_one; + +drop table if exists dfk_set_null; + +drop table if exists doc; + +drop table if exists doc_link; + +drop table if exists doc_link_draft; + +drop table if exists doc_draft; + +drop table if exists document; + +drop table if exists document_draft; + +drop table if exists document_media; + +drop table if exists document_media_draft; + +drop table if exists sp_car_door; + +drop table if exists earray_bean; + +drop table if exists earray_set_bean; + +drop table if exists e_basic; + +drop table if exists ebasic_change_log; + +drop table if exists ebasic_clob; + +drop table if exists ebasic_clob_fetch_eager; + +drop table if exists ebasic_clob_no_ver; + +drop table if exists e_basicenc; + +drop table if exists e_basicenc_bin; + +drop table if exists e_basicenc_client; + +drop table if exists e_basic_enum_id; + +drop table if exists e_basic_eni; + +drop table if exists ebasic_hstore; + +drop table if exists ebasic_json_jackson; + +drop table if exists ebasic_json_jackson2; + +drop table if exists ebasic_json_list; + +drop table if exists ebasic_json_map; + +drop table if exists ebasic_json_map_blob; + +drop table if exists ebasic_json_map_clob; + +drop table if exists ebasic_json_map_detail; + +drop table if exists ebasic_json_map_json_b; + +drop table if exists ebasic_json_map_varchar; + +drop table if exists ebasic_json_node; + +drop table if exists ebasic_json_node_blob; + +drop table if exists ebasic_json_node_json_b; + +drop table if exists ebasic_json_node_varchar; + +drop table if exists ebasic_json_unmapped; + +drop table if exists e_basic_ndc; + +drop table if exists ebasic_no_sdchild; + +drop table if exists ebasic_sdchild; + +drop table if exists ebasic_soft_delete; + +drop table if exists e_basicver; + +drop table if exists e_basic_withlife; + +drop table if exists e_basic_with_ex; + +drop table if exists e_basicverucon; + +drop table if exists ecache_child; + +drop table if exists ecache_root; + +drop table if exists e_col_ab; + +drop table if exists ecustom_id; + +drop table if exists edefault_prop; + +drop table if exists eemb_inner; + +drop table if exists eemb_outer; + +drop table if exists efile2_no_fk; + +drop table if exists efile_no_fk; + +drop table if exists efile_no_fk_euser_no_fk; + +drop table if exists efile_no_fk_euser_no_fk_soft_del; + +drop table if exists egen_props; + +drop table if exists einvoice; + +drop table if exists e_main; + +drop table if exists enull_collection; + +drop table if exists enull_collection_detail; + +drop table if exists eopt_one_a; + +drop table if exists eopt_one_b; + +drop table if exists eopt_one_c; + +drop table if exists eper_addr; + +drop table if exists eperson; + +drop table if exists e_person_online; + +drop table if exists esimple; + +drop table if exists esoft_del_book; + +drop table if exists esoft_del_book_esoft_del_user; + +drop table if exists esoft_del_down; + +drop table if exists esoft_del_mid; + +drop table if exists esoft_del_one_a; + +drop table if exists esoft_del_one_b; + +drop table if exists esoft_del_role; + +drop table if exists esoft_del_role_esoft_del_user; + +drop table if exists esoft_del_top; + +drop table if exists esoft_del_up; + +drop table if exists esoft_del_user; + +drop table if exists esoft_del_user_esoft_del_role; + +drop table if exists esome_convert_type; + +drop table if exists esome_type; + +drop table if exists etrans_many; + +drop table if exists rawinherit_uncle; + +drop table if exists euser_no_fk; + +drop table if exists euser_no_fk_soft_del; + +drop table if exists evanilla_collection; + +drop table if exists evanilla_collection_detail; + +drop table if exists ewho_props; + +drop table if exists e_withinet; + +drop table if exists ec_enum_person; + +drop table if exists ec_enum_person_tags; + +drop table if exists ec_person; + +drop table if exists ec_person_phone; + +drop table if exists ecbl_person; + +drop table if exists ecbl_person_phone_numbers; + +drop table if exists ecbm_person; + +drop table if exists ecbm_person_phone_numbers; + +drop table if exists ecm_person; + +drop table if exists ecm_person_phone_numbers; + +drop table if exists ecmc_person; + +drop table if exists ecmc_person_phone_numbers; + +drop table if exists ecs_person; + +drop table if exists ecs_person_phone; + +drop table if exists td_child; + +drop table if exists td_parent; + +drop table if exists empl; + +drop table if exists esd_detail; + +drop table if exists esd_master; + +drop table if exists feature_desc; + +drop table if exists f_first; + +drop table if exists foo; + +drop table if exists gen_key_identity; + +drop table if exists gen_key_sequence; + +drop table if exists gen_key_table; + +drop table if exists grand_parent_person; + +drop table if exists survey_group; + +drop table if exists c_group; + +drop table if exists he_doc; + +drop trigger hx_link_history_upd; +drop trigger hx_link_history_del; +drop view hx_link_with_history; +CALL usp_ebean_drop_column('hx_link', 'sys_period_start'); +CALL usp_ebean_drop_column('hx_link', 'sys_period_end'); +drop table hx_link_history; + +drop table if exists hx_link; + +drop table if exists hx_link_doc; + +drop table if exists hi_doc; + +drop trigger hi_link_history_upd; +drop trigger hi_link_history_del; +drop view hi_link_with_history; +CALL usp_ebean_drop_column('hi_link', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_link', 'sys_period_end'); +drop table hi_link_history; + +drop table if exists hi_link; + +drop trigger hi_link_doc_history_upd; +drop trigger hi_link_doc_history_del; +drop view hi_link_doc_with_history; +CALL usp_ebean_drop_column('hi_link_doc', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_link_doc', 'sys_period_end'); +drop table hi_link_doc_history; + +drop table if exists hi_link_doc; + +drop trigger hi_tone_history_upd; +drop trigger hi_tone_history_del; +drop view hi_tone_with_history; +CALL usp_ebean_drop_column('hi_tone', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_tone', 'sys_period_end'); +drop table hi_tone_history; + +drop table if exists hi_tone; + +drop trigger hi_tthree_history_upd; +drop trigger hi_tthree_history_del; +drop view hi_tthree_with_history; +CALL usp_ebean_drop_column('hi_tthree', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_tthree', 'sys_period_end'); +drop table hi_tthree_history; + +drop table if exists hi_tthree; + +drop trigger hi_ttwo_history_upd; +drop trigger hi_ttwo_history_del; +drop view hi_ttwo_with_history; +CALL usp_ebean_drop_column('hi_ttwo', 'sys_period_start'); +CALL usp_ebean_drop_column('hi_ttwo', 'sys_period_end'); +drop table hi_ttwo_history; + +drop table if exists hi_ttwo; + +drop trigger hsd_setting_history_upd; +drop trigger hsd_setting_history_del; +drop view hsd_setting_with_history; +CALL usp_ebean_drop_column('hsd_setting', 'sys_period_start'); +CALL usp_ebean_drop_column('hsd_setting', 'sys_period_end'); +drop table hsd_setting_history; + +drop table if exists hsd_setting; + +drop trigger hsd_user_history_upd; +drop trigger hsd_user_history_del; +drop view hsd_user_with_history; +CALL usp_ebean_drop_column('hsd_user', 'sys_period_start'); +CALL usp_ebean_drop_column('hsd_user', 'sys_period_end'); +drop table hsd_user_history; + +drop table if exists hsd_user; + +drop table if exists iaf_segment; + +drop table if exists iaf_segment_status; + +drop table if exists imrelated; + +drop table if exists imroot; + +drop table if exists ixresource; + +drop table if exists info_company; + +drop table if exists info_contact; + +drop table if exists info_customer; + +drop table if exists inner_report; + +drop table if exists drel_invoice; + +drop table if exists item; + +drop table if exists monkey; + +drop table if exists mkeygroup; + +drop table if exists mkeygroup_monkey; + +drop table if exists trainer; + +drop table if exists trainer_monkey; + +drop table if exists troop; + +drop table if exists troop_monkey; + +drop table if exists l2_cldf_reset_bean; + +drop table if exists l2_cldf_reset_bean_child; + +drop table if exists level1; + +drop table if exists level1_level4; + +drop table if exists level1_level2; + +drop table if exists level2; + +drop table if exists level2_level3; + +drop table if exists level3; + +drop table if exists level4; + +drop trigger link_history_upd; +drop trigger link_history_del; +drop view link_with_history; +CALL usp_ebean_drop_column('link', 'sys_period_start'); +CALL usp_ebean_drop_column('link', 'sys_period_end'); +drop table link_history; + +drop table if exists link; + +drop table if exists link_draft; + +drop table if exists la_attr_value; + +drop table if exists la_attr_value_attribute; + +drop table if exists looney; + +drop table if exists maddress; + +drop table if exists mcontact; + +drop table if exists mcontact_message; + +drop table if exists mcustomer; + +drop table if exists mgroup; + +drop table if exists mmachine; + +drop table if exists mmachine_mgroup; + +drop table if exists mmedia; + +drop table if exists non_updateprop; + +drop table if exists mprinter; + +drop table if exists mprinter_state; + +drop table if exists mprofile; + +drop table if exists mprotected_construct_bean; + +drop table if exists mrole; + +drop table if exists mrole_muser; + +drop table if exists msome_other; + +drop table if exists muser; + +drop table if exists muser_type; + +drop table if exists mail_box; + +drop table if exists mail_user; + +drop table if exists mail_user_inbox; + +drop table if exists mail_user_outbox; + +drop table if exists main_entity; + +drop table if exists main_entity_relation; + +drop table if exists map_super_actual; + +drop table if exists c_message; + +drop table if exists meter_address_data; + +drop table if exists meter_contract_data; + +drop table if exists meter_special_needs_client; + +drop table if exists meter_special_needs_contact; + +drop table if exists meter_version; + +drop table if exists mnoc_role; + +drop table if exists mnoc_user; + +drop table if exists mnoc_user_mnoc_role; + +drop table if exists mny_a; + +drop table if exists mny_b; + +drop table if exists mny_b_mny_c; + +drop table if exists mny_c; + +drop table if exists mny_topic; + +drop table if exists subtopics; + +drop table if exists mp_role; + +drop table if exists mp_user; + +drop table if exists ms_many_a; + +drop table if exists ms_many_a_many_b; + +drop table if exists ms_many_b; + +drop table if exists ms_many_b_many_a; + +drop table if exists my_lob_size; + +drop table if exists my_lob_size_join_many; + +drop table if exists noidbean; + +drop table if exists o_cached_bean; + +drop table if exists o_cached_bean_country; + +drop table if exists o_cached_bean_child; + +drop table if exists o_cached_inherit; + +drop table if exists o_cached_natkey; + +drop table if exists o_cached_natkey3; + +drop table if exists ocar; + +drop table if exists ocompany; + +drop table if exists oengine; + +drop table if exists ogear_box; + +drop table if exists oroad_show_msg; + +drop table if exists om_ordered_detail; + +drop table if exists om_ordered_master; + +drop table if exists only_id_entity; + +drop table if exists o_order; + +drop table if exists o_order_detail; + +drop table if exists s_orders; + +drop table if exists s_order_items; + +drop table if exists or_order_ship; + +drop table if exists organisation; + +drop table if exists organization_node; + +drop table if exists organization_tree_node; + +drop table if exists orp_detail; + +drop table if exists orp_detail2; + +drop table if exists orp_master; + +drop table if exists orp_master2; + +drop table if exists oto_aone; + +drop table if exists oto_atwo; + +drop table if exists oto_bchild; + +drop table if exists oto_bmaster; + +drop table if exists oto_child; + +drop table if exists oto_cust; + +drop table if exists oto_cust_address; + +drop table if exists oto_level_a; + +drop table if exists oto_level_b; + +drop table if exists oto_level_c; + +drop table if exists oto_master; + +drop table if exists oto_prime; + +drop table if exists oto_prime_extra; + +drop table if exists oto_sd_child; + +drop table if exists oto_sd_master; + +drop table if exists oto_th_many; + +drop table if exists oto_th_one; + +drop table if exists oto_th_top; + +drop table if exists oto_ubprime; + +drop table if exists oto_ubprime_extra; + +drop table if exists oto_uprime; + +drop table if exists oto_uprime_extra; + +drop table if exists oto_user_model; + +drop table if exists oto_user_model_optional; + +drop table if exists pfile; + +drop table if exists pfile_content; + +drop table if exists paggview; + +drop table if exists pallet_location; + +drop table if exists parcel; + +drop table if exists parcel_location; + +drop table if exists rawinherit_parent; + +drop table if exists rawinherit_parent_rawinherit_data; + +drop table if exists e_save_test_c; + +drop table if exists parent_person; + +drop table if exists c_participation; + +drop table if exists password_store_model; + +drop table if exists mt_permission; + +drop table if exists persistent_file; + +drop table if exists persistent_file_content; + +drop table if exists person; + +drop table if exists persons; + +drop table if exists person_cache_email; + +drop table if exists person_cache_info; + +drop table if exists phones; + +drop table if exists e_position; + +drop table if exists primary_revision; + +drop table if exists o_product; + +drop table if exists pp; + +drop table if exists pp_to_ww; + +drop table if exists question; + +drop table if exists rcustomer; + +drop table if exists r_orders; + +drop table if exists region; + +drop table if exists rel_detail; + +drop table if exists rel_master; + +drop table if exists resourcefile; + +drop table if exists mt_role; + +drop table if exists mt_role_permission; + +drop table if exists em_role; + +drop table if exists f_second; + +drop table if exists section; + +drop table if exists self_parent; + +drop table if exists self_ref_customer; + +drop table if exists self_ref_example; + +drop table if exists e_save_test_a; + +drop table if exists e_save_test_b; + +drop table if exists site; + +drop table if exists site_address; + +drop table if exists some_enum_bean; + +drop table if exists some_file_bean; + +drop table if exists some_new_types_bean; + +drop table if exists some_period_bean; + +drop table if exists stockforecast; + +drop table if exists sub_section; + +drop table if exists sub_type; + +drop table if exists survey; + +drop table if exists tbytes_only; + +drop table if exists tcar; + +drop table if exists tevent; + +drop table if exists tevent_many; + +drop table if exists tevent_one; + +drop table if exists tint_root; + +drop table if exists tjoda_entity; + +drop table if exists t_mapsuper1; + +drop table if exists t_oneb; + +drop table if exists t_detail_with_other_namexxxyy; + +drop table if exists ts_detail_two; + +drop table if exists t_atable_thatisrelatively; + +drop table if exists ts_master_two; + +drop table if exists tuuid_entity; + +drop table if exists twheel; + +drop table if exists twith_pre_insert; + +drop table if exists mt_tenant; + +drop table if exists test_annotation_base_entity; + +drop table if exists tire; + +drop table if exists sa_tire; + +drop table if exists trip; + +drop table if exists truck_ref; + +drop table if exists tune; + +drop table if exists `type`; + +drop table if exists tz_bean; + +drop table if exists usib_child; + +drop table if exists usib_child_sibling; + +drop table if exists usib_parent; + +drop table if exists ut_detail; + +drop table if exists ut_master; + +drop table if exists uuone; + +drop table if exists uutwo; + +drop table if exists oto_user; + +drop trigger c_user_history_upd; +drop trigger c_user_history_del; +drop view c_user_with_history; +CALL usp_ebean_drop_column('c_user', 'sys_period_start'); +CALL usp_ebean_drop_column('c_user', 'sys_period_end'); +drop table c_user_history; + +drop table if exists c_user; + +drop table if exists tx_user; + +drop table if exists g_user; + +drop table if exists em_user; + +drop table if exists em_user_role; + +drop table if exists vehicle; + +drop table if exists vehicle_driver; + +drop table if exists vehicle_lease; + +drop table if exists warehouses; + +drop table if exists warehousesshippingzones; + +drop table if exists wheel; + +drop table if exists sa_wheel; + +drop table if exists sp_car_wheel; + +drop table if exists g_who_props_otm; + +drop table if exists with_zero; + +drop table if exists parent; + +drop table if exists wview; + +drop table if exists zones; + +drop index ix_contact_last_name_first_name on contact; +drop index ix_e_basic_name on e_basic; +drop index ix_efile2_no_fk_owner_id on efile2_no_fk; +drop index ix_organization_node_kind on organization_node; diff --git a/ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql new file mode 100644 index 0000000..cc4dc83 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql @@ -0,0 +1,45 @@ +create table m1 +( + id integer, + acol varchar(20) +); + +create table m2 +( + id integer, + acol varchar(20), + bcol timestamp +); + + +create table orp_master ( +id varchar(100) not null, +name varchar(255), +version bigint not null, +constraint pk_orp_master primary key (id) +); + +alter table orp_master add column sys_period_start datetime(6) default now(); +alter table orp_master add column sys_period_end datetime(6); + +create table orp_master_history ( +id varchar(100) not null, +name varchar(255), +version bigint not null, +sys_period_start datetime(6), +sys_period_end datetime(6) +); + +create view orp_master_with_history as + select * from orp_master union all + select * from orp_master_history; + +delimiter $$ +create or replace trigger orp_master_history_upd + for orp_master + before update for each row as + NEW.sys_period_start = greatest(current_timestamp , date_add(OLD.sys_period_start,interval 1 microsecond)); + insert into orp_master_history (sys_period_start,sys_period_end,id, name, version) + values (OLD.sys_period_start, NEW.sys_period_start, OLD.id, OLD.name, OLD.version); + end_trigger +$$ diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql new file mode 100644 index 0000000..76a6be8 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql @@ -0,0 +1,5 @@ +create table m3 (id integer, acol varchar(20)); + +alter table m1 add addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql new file mode 100644 index 0000000..63a4934 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql @@ -0,0 +1 @@ +-- do nothing diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql new file mode 100644 index 0000000..6a7c4df --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql @@ -0,0 +1 @@ +create or replace view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql b/ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql new file mode 100644 index 0000000..7bd7082 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql @@ -0,0 +1,14 @@ +create or replace function hx_link_history_version() returns trigger as $$ +begin + +end; +$$ LANGUAGE plpgsql; + +create trigger hx_link_history_upd + before update or delete on hx_link + for each row execute procedure hx_link_history_version(); + +create or replace function hi_link_history_version() returns trigger as $$ +begin +end; +$$ LANGUAGE plpgsql; diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql b/ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql new file mode 100644 index 0000000..30e9b2e --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql @@ -0,0 +1,4745 @@ +-- Generated by ebean unknown at 2019-07-24T11:42:58.489Z +create table asimple_bean ( + id bigserial not null, + name varchar(255), + constraint pk_asimple_bean primary key (id) +); + +create table bar ( + bar_type varchar(31) not null, + bar_id serial not null, + foo_id integer not null, + version integer not null, + constraint pk_bar primary key (bar_id) +); + +create table block ( + case_type integer not null, + id bigserial not null, + name varchar(255), + version bigint not null, + notes varchar(255), + constraint pk_block primary key (id) +); + +create table oto_account ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_account primary key (id) +); + +create table acl ( + id bigserial not null, + name varchar(255), + constraint pk_acl primary key (id) +); + +create table acl_container_relation ( + id bigserial not null, + container_id bigint not null, + acl_entry_id bigint not null, + constraint pk_acl_container_relation primary key (id) +); + +create table addr ( + id bigserial not null, + employee_id bigint, + name varchar(255), + address_line1 varchar(255), + address_line2 varchar(255), + city varchar(255), + version bigint not null, + constraint pk_addr primary key (id) +); + +create table address ( + oid bigserial not null, + street varchar(255), + version integer not null, + constraint pk_address primary key (oid) +); + +create table o_address ( + id smallserial not null, + line_1 varchar(100), + line_2 varchar(100), + city varchar(100), + cretime timestamptz, + country_code varchar(2), + updtime timestamptz not null, + constraint pk_o_address primary key (id) +); + +create table album ( + id bigserial not null, + name varchar(255), + cover_id bigint, + deleted boolean default false not null, + created_at timestamptz not null, + last_update timestamptz not null, + constraint uq_album_cover_id unique (cover_id), + constraint pk_album primary key (id) +); + +create table animal ( + species varchar(255) not null, + id bigserial not null, + shelter_id bigint, + version bigint not null, + name varchar(255), + registration_number varchar(255), + date_of_birth date, + dog_size varchar(255), + constraint pk_animal primary key (id) +); + +create table animal_shelter ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_animal_shelter primary key (id) +); + +create table article ( + id serial not null, + name varchar(255), + author varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_article primary key (id) +); + +create table attribute ( + option_type integer not null, + id serial not null, + attribute_holder_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_attribute primary key (id) +); + +create table attribute_holder ( + id serial not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_attribute_holder primary key (id) +); + +create table audit_log ( + id bigserial not null, + description varchar(255), + modified_description varchar(255), + constraint pk_audit_log primary key (id) +); + +create table bbookmark ( + id serial not null, + bookmark_reference varchar(255), + user_id integer, + constraint pk_bbookmark primary key (id) +); + +create table bbookmark_org ( + id serial not null, + name varchar(255), + constraint pk_bbookmark_org primary key (id) +); + +create table bbookmark_user ( + id serial not null, + name varchar(255), + password varchar(255), + email_address varchar(255), + country varchar(255), + org_id integer, + constraint pk_bbookmark_user primary key (id) +); + +create table bsimple_with_gen ( + id serial not null, + name varchar(255), + constraint pk_bsimple_with_gen primary key (id) +); + +create table bsite ( + id uuid not null, + name varchar(255), + constraint pk_bsite primary key (id) +); + +create table bsite_user_a ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_a primary key (site_id,user_id) +); + +create table bsite_user_b ( + site uuid not null, + usr uuid not null, + access_level integer, + constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_b primary key (site,usr) +); + +create table bsite_user_c ( + site_uid uuid not null, + user_uid uuid not null, + access_level integer, + constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), + constraint pk_bsite_user_c primary key (site_uid,user_uid) +); + +create table bsite_user_d ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + version bigint not null, + constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) +); + +create table bsite_user_e ( + site_id uuid not null, + user_id uuid not null, + access_level integer, + constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) +); + +create table buser ( + id uuid not null, + name varchar(255), + constraint pk_buser primary key (id) +); + +create table bwith_qident ( + id serial not null, + "Name" varchar(191), + "CODE" varchar(255), + last_updated timestamptz not null, + constraint uq_bwith_qident_name unique ("Name"), + constraint pk_bwith_qident primary key (id) +); + +create table basic_draftable_bean ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_basic_draftable_bean primary key (id) +); + +create table basic_draftable_bean_draft ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_basic_draftable_bean_draft primary key (id) +); + +create table basic_joda_entity ( + id bigserial not null, + name varchar(255), + period varchar(50), + local_date date, + created timestamptz not null, + updated timestamptz not null, + version timestamptz not null, + constraint pk_basic_joda_entity primary key (id) +); + +create table bean_with_time_zone ( + id bigserial not null, + name varchar(255), + timezone varchar(20), + constraint pk_bean_with_time_zone primary key (id) +); + +create table drel_booking ( + id bigint not null, + booking_uid bigint, + agent_invoice bigint, + client_invoice bigint, + version integer not null, + constraint uq_drel_booking_booking_uid unique (booking_uid), + constraint uq_drel_booking_agent_invoice unique (agent_invoice), + constraint uq_drel_booking_client_invoice unique (client_invoice), + constraint pk_drel_booking primary key (id) +); +create sequence drel_booking_seq; + +create table bw_bean ( + id bigserial not null, + name varchar(255), + flags integer not null, + version bigint not null, + constraint pk_bw_bean primary key (id) +); + +create table cepcategory ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_cepcategory primary key (id) +); + +create table cepproduct ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_cepproduct primary key (id) +); + +create table cepproduct_category ( + customer_id bigint not null, + address_id bigint not null, + category_id bigint not null, + product_id bigint not null, + priority integer +); + +create table cinh_ref ( + id serial not null, + ref_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_cinh_ref primary key (id) +); + +create table cinh_root ( + dtype varchar(3) not null, + id serial not null, + license_number varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + driver varchar(255), + notes varchar(255), + action varchar(255), + constraint pk_cinh_root primary key (id) +); + +create table ckey_assoc ( + id serial not null, + assoc_one varchar(255), + constraint pk_ckey_assoc primary key (id) +); + +create table ckey_detail ( + id serial not null, + something varchar(255), + one_key integer, + two_key varchar(127), + constraint pk_ckey_detail primary key (id) +); + +create table ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + assoc_id integer, + version integer not null, + constraint pk_ckey_parent primary key (one_key,two_key) +); + +create table calculation_result ( + id serial not null, + charge float not null, + product_configuration_id integer, + group_configuration_id integer, + constraint pk_calculation_result primary key (id) +); + +create table cao_bean ( + x_cust_id integer not null, + x_type_id integer not null, + description varchar(255), + version bigint not null, + constraint pk_cao_bean primary key (x_cust_id,x_type_id) +); + +create table sp_car_car ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_car primary key (id) +); +create sequence sp_car_car_seq; + +create table sp_car_car_wheels ( + car bigint not null, + wheel bigint not null, + constraint pk_sp_car_car_wheels primary key (car,wheel) +); + +create table sp_car_car_doors ( + car bigint not null, + door bigint not null, + constraint pk_sp_car_car_doors primary key (car,door) +); + +create table sa_car ( + id bigint not null, + version integer not null, + constraint pk_sa_car primary key (id) +); +create sequence sa_car_seq; + +create table car_accessory ( + id serial not null, + name varchar(255), + fuse_id bigint not null, + car_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_car_accessory primary key (id) +); + +create table car_fuse ( + id bigserial not null, + location_code varchar(255), + constraint pk_car_fuse primary key (id) +); + +create table category ( + id bigserial not null, + name varchar(255), + surveyobjectid bigint, + sequence_number integer not null, + constraint pk_category primary key (id) +); + +create table e_save_test_d ( + id bigserial not null, + parent_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_d_parent_id unique (parent_id), + constraint pk_e_save_test_d primary key (id) +); + +create table child_person ( + identifier serial not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_child_person primary key (identifier) +); + +create table cke_client ( + cod_cpny integer not null, + cod_client varchar(100) not null, + username varchar(100) not null, + notes varchar(255), + constraint pk_cke_client primary key (cod_cpny,cod_client) +); + +create table cke_user ( + username varchar(100) not null, + cod_cpny integer not null, + name varchar(255), + constraint pk_cke_user primary key (username,cod_cpny) +); + +create table class_super ( + dtype varchar(31) not null, + sid bigserial not null, + constraint pk_class_super primary key (sid) +); + +create table class_super_monkey ( + class_super_sid bigint not null, + monkey_mid bigint not null, + constraint uq_class_super_monkey_mid unique (monkey_mid), + constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) +); + +create table configuration ( + type varchar(21) not null, + id serial not null, + name varchar(255), + configurations_id integer, + group_name varchar(255), + product_name varchar(255), + constraint pk_configuration primary key (id) +); + +create table configurations ( + id serial not null, + name varchar(255), + constraint pk_configurations primary key (id) +); + +create table contact ( + id serial not null, + first_name varchar(127), + last_name varchar(127), + phone varchar(255), + mobile varchar(255), + email varchar(255), + customer_id integer not null, + group_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + constraint pk_contact primary key (id) +); + +create table contact_group ( + id serial not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_contact_group primary key (id) +); + +create table contact_note ( + id serial not null, + contact_id integer, + title varchar(255), + note text, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_contact_note primary key (id) +); + +create table contract ( + id bigserial not null, + name varchar(255), + constraint pk_contract primary key (id) +); + +create table contract_costs ( + id bigserial not null, + status varchar(255), + position_id bigint not null, + constraint pk_contract_costs primary key (id) +); + +create table c_conversation ( + id bigserial not null, + title varchar(255), + isopen boolean default false not null, + group_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_conversation primary key (id) +); + +create table o_country ( + code varchar(2) not null, + name varchar(60), + constraint pk_o_country primary key (code) +); + +create table cover ( + id bigserial not null, + s3_url varchar(255), + deleted boolean default false not null, + constraint pk_cover primary key (id) +); + +create table o_customer ( + id serial not null, + status varchar(1), + name varchar(40) not null, + smallnote varchar(100), + anniversary date, + billing_address_id smallint, + shipping_address_id smallint, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint ck_o_customer_status check ( status in ('N','A','I')), + constraint pk_o_customer primary key (id) +); +comment on table o_customer is 'Holds external customers'; +comment on column o_customer.status is 'status of the customer'; +comment on column o_customer.smallnote is 'Short notes regarding the customer'; +comment on column o_customer.anniversary is 'Join date of the customer'; + +create table dcredit ( + id bigserial not null, + credit varchar(255), + constraint pk_dcredit primary key (id) +); + +create table dcredit_drol ( + dcredit_id bigint not null, + drol_id bigint not null, + constraint pk_dcredit_drol primary key (dcredit_id,drol_id) +); + +create table dexh_entity ( + oid bigserial not null, + exhange varchar(255), + an_enum_type varchar(255), + last_updated timestamptz not null, + constraint pk_dexh_entity primary key (oid) +); + +create table dmachine ( + id bigserial not null, + name varchar(255), + organisation_id bigint, + version bigint not null, + constraint pk_dmachine primary key (id) +); + +create table d_machine_aux_use ( + id bigserial not null, + machine_id bigint not null, + name varchar(255), + date date, + use_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_aux_use primary key (id) +); + +create table d_machine_stats ( + id bigserial not null, + machine_id bigint not null, + date date, + total_kms bigint not null, + hours bigint not null, + rate decimal(38), + cost decimal(38), + version bigint not null, + constraint pk_d_machine_stats primary key (id) +); + +create table d_machine_use ( + id bigserial not null, + machine_id bigint not null, + date date, + distance_kms bigint not null, + time_secs bigint not null, + fuel decimal(38), + version bigint not null, + constraint pk_d_machine_use primary key (id) +); + +create table dorg ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_dorg primary key (id) +); + +create table dperson ( + id bigserial not null, + first_name varchar(255), + last_name varchar(255), + salary decimal(38), + constraint pk_dperson primary key (id) +); + +create table drol ( + id bigserial not null, + name varchar(255), + constraint pk_drol primary key (id) +); + +create table drot ( + id bigserial not null, + name varchar(255), + constraint pk_drot primary key (id) +); + +create table drot_drol ( + drot_id bigint not null, + drol_id bigint not null, + constraint pk_drot_drol primary key (drot_id,drol_id) +); + +create table rawinherit_data ( + id bigserial not null, + val integer, + constraint pk_rawinherit_data primary key (id) +); + +create table data_container ( + id uuid not null, + content varchar(255), + constraint pk_data_container primary key (id) +); + +create table dc_detail ( + id bigserial not null, + master_id bigint, + description varchar(255), + version bigint not null, + constraint pk_dc_detail primary key (id) +); + +create table dc_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_dc_master primary key (id) +); + +create table dfk_cascade ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_cascade primary key (id) +); + +create table dfk_cascade_one ( + id bigserial not null, + name varchar(255), + constraint pk_dfk_cascade_one primary key (id) +); + +create table dfk_none ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none primary key (id) +); + +create table dfk_none_via_join ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_none_via_join primary key (id) +); + +create table dfk_none_via_mto_m ( + id bigserial not null, + name varchar(255), + constraint pk_dfk_none_via_mto_m primary key (id) +); + +create table dfk_none_via_mto_m_dfk_one ( + dfk_none_via_mto_m_id bigint not null, + dfk_one_id bigint not null, + constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) +); + +create table dfk_one ( + id bigserial not null, + name varchar(255), + constraint pk_dfk_one primary key (id) +); + +create table dfk_set_null ( + id bigserial not null, + name varchar(255), + one_id bigint, + constraint pk_dfk_set_null primary key (id) +); + +create table doc ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_doc primary key (id) +); + +create table doc_link ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link primary key (doc_id,link_id) +); + +create table doc_link_draft ( + doc_id bigint not null, + link_id bigint not null, + constraint pk_doc_link_draft primary key (doc_id,link_id) +); + +create table doc_draft ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_doc_draft primary key (id) +); + +create table document ( + id bigserial not null, + title varchar(127), + body varchar(255), + organisation_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_document_title unique (title), + constraint pk_document primary key (id) +); + +create table document_draft ( + id bigserial not null, + title varchar(127), + body varchar(255), + when_publish timestamptz, + organisation_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_document_draft_title unique (title), + constraint pk_document_draft primary key (id) +); + +create table document_media ( + id bigserial not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_document_media primary key (id) +); + +create table document_media_draft ( + id bigserial not null, + document_id bigint, + name varchar(255), + description varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_document_media_draft primary key (id) +); + +create table sp_car_door ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_door primary key (id) +); +create sequence sp_car_door_seq; + +create table earray_bean ( + id bigserial not null, + foo integer, + name varchar(255), + phone_numbers varchar[], + uids uuid[], + other_ids bigint[], + doubs float[], + statuses integer[], + vc_enums varchar[], + int_enums integer[], + status2 integer[], + version bigint not null, + constraint ck_earray_bean_foo check ( foo in (100,101,102)), + constraint pk_earray_bean primary key (id) +); + +create table earray_set_bean ( + id bigserial not null, + name varchar(255), + phone_numbers varchar[], + uids uuid[], + other_ids bigint[], + doubs float[], + version bigint not null, + constraint pk_earray_set_bean primary key (id) +); + +create table e_basic ( + id serial not null, + status varchar(1), + name varchar(127), + description varchar(255), + some_date timestamptz, + constraint ck_e_basic_status check ( status in ('N','A','I')), + constraint pk_e_basic primary key (id) +); + +create table ebasic_change_log ( + id bigserial not null, + name varchar(20), + short_description varchar(50), + long_description varchar(100), + who_created varchar(255) not null, + who_modified varchar(255) not null, + when_created timestamptz not null, + when_modified timestamptz not null, + version bigint not null, + constraint pk_ebasic_change_log primary key (id) +); + +create table ebasic_clob ( + id bigserial not null, + name varchar(255), + title varchar(255), + description text, + last_update timestamptz not null, + constraint pk_ebasic_clob primary key (id) +); + +create table ebasic_clob_fetch_eager ( + id bigserial not null, + name varchar(255), + title varchar(255), + description text, + last_update timestamptz not null, + constraint pk_ebasic_clob_fetch_eager primary key (id) +); + +create table ebasic_clob_no_ver ( + id bigserial not null, + name varchar(255), + description text, + constraint pk_ebasic_clob_no_ver primary key (id) +); + +create table e_basicenc ( + id serial not null, + name varchar(255), + description bytea, + dob bytea, + status bytea, + last_update timestamptz, + constraint pk_e_basicenc primary key (id) +); + +create table e_basicenc_bin ( + id serial not null, + name varchar(255), + description varchar(255), + data bytea, + some_time bytea, + last_update timestamptz not null, + constraint pk_e_basicenc_bin primary key (id) +); + +create table e_basicenc_client ( + id bigserial not null, + name varchar(255), + description bytea, + dob bytea, + status bytea, + version bigint not null, + constraint pk_e_basicenc_client primary key (id) +); + +create table e_basic_enum_id ( + status varchar(1) not null, + name varchar(255), + description varchar(255), + constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), + constraint pk_e_basic_enum_id primary key (status) +); + +create table e_basic_eni ( + id serial not null, + status integer, + name varchar(255), + description varchar(255), + some_date timestamptz, + constraint ck_e_basic_eni_status check ( status in (1,2,3)), + constraint pk_e_basic_eni primary key (id) +); + +create table ebasic_hstore ( + id bigserial not null, + name varchar(255), + map hstore, + version bigint not null, + constraint pk_ebasic_hstore primary key (id) +); + +create table ebasic_json_jackson ( + id bigserial not null, + name varchar(255), + value_set json, + value_list jsonb, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson primary key (id) +); + +create table ebasic_json_jackson2 ( + id bigserial not null, + name varchar(255), + value_set json, + value_list jsonb, + value_map json, + plain_value json, + version bigint not null, + constraint pk_ebasic_json_jackson2 primary key (id) +); + +create table ebasic_json_list ( + id bigserial not null, + name varchar(255), + bean_set json, + bean_list jsonb, + bean_map json, + plain_bean json, + flags json, + tags varchar(100), + version bigint not null, + constraint pk_ebasic_json_list primary key (id) +); + +create table ebasic_json_map ( + id bigserial not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map primary key (id) +); + +create table ebasic_json_map_blob ( + id bigserial not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_ebasic_json_map_blob primary key (id) +); + +create table ebasic_json_map_clob ( + id bigserial not null, + name varchar(255), + content text, + version bigint not null, + constraint pk_ebasic_json_map_clob primary key (id) +); + +create table ebasic_json_map_detail ( + id bigserial not null, + owner_id bigint, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_map_detail primary key (id) +); + +create table ebasic_json_map_json_b ( + id bigserial not null, + name varchar(255), + content jsonb, + version bigint not null, + constraint pk_ebasic_json_map_json_b primary key (id) +); + +create table ebasic_json_map_varchar ( + id bigserial not null, + name varchar(255), + content varchar(3000), + version bigint not null, + constraint pk_ebasic_json_map_varchar primary key (id) +); + +create table ebasic_json_node ( + id bigserial not null, + name varchar(255), + content json, + version bigint not null, + constraint pk_ebasic_json_node primary key (id) +); + +create table ebasic_json_node_blob ( + id bigserial not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_ebasic_json_node_blob primary key (id) +); + +create table ebasic_json_node_json_b ( + id bigserial not null, + name varchar(255), + content jsonb, + version bigint not null, + constraint pk_ebasic_json_node_json_b primary key (id) +); + +create table ebasic_json_node_varchar ( + id bigserial not null, + name varchar(255), + content varchar(1000), + version bigint not null, + constraint pk_ebasic_json_node_varchar primary key (id) +); + +create table ebasic_json_unmapped ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ebasic_json_unmapped primary key (id) +); + +create table e_basic_ndc ( + id serial not null, + name varchar(255), + constraint pk_e_basic_ndc primary key (id) +); + +create table ebasic_no_sdchild ( + id bigserial not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + constraint pk_ebasic_no_sdchild primary key (id) +); + +create table ebasic_sdchild ( + id bigserial not null, + owner_id bigint not null, + child_name varchar(255), + amount bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_sdchild primary key (id) +); + +create table ebasic_soft_delete ( + id bigserial not null, + name varchar(255), + description varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_ebasic_soft_delete primary key (id) +); + +create table e_basicver ( + id serial not null, + name varchar(255), + description varchar(255), + other varchar(255), + last_update timestamptz not null, + constraint pk_e_basicver primary key (id) +); + +create table e_basic_withlife ( + id bigserial not null, + name varchar(255), + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_withlife primary key (id) +); + +create table e_basic_with_ex ( + id bigserial not null, + deleted boolean default false not null, + version bigint not null, + constraint pk_e_basic_with_ex primary key (id) +); + +create table e_basicverucon ( + id serial not null, + name varchar(127), + other varchar(127), + other_one varchar(127), + description varchar(255), + last_update timestamptz not null, + constraint uq_e_basicverucon_name unique (name), + constraint uq_e_basicverucon_other_other_one unique (other,other_one), + constraint pk_e_basicverucon primary key (id) +); + +create table ecache_child ( + id uuid not null, + name varchar(100), + root_id uuid not null, + constraint pk_ecache_child primary key (id) +); + +create table ecache_root ( + id uuid not null, + name varchar(100), + constraint pk_ecache_root primary key (id) +); + +create table e_col_ab ( + id bigserial not null, + column_a varchar(255), + column_b varchar(255), + constraint pk_e_col_ab primary key (id) +); + +create table ecustom_id ( + id varchar(127) not null, + name varchar(255), + constraint pk_ecustom_id primary key (id) +); + +create table edefault_prop ( + id serial not null, + e_simple_usertypeid integer, + name varchar(255), + constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), + constraint pk_edefault_prop primary key (id) +); + +create table eemb_inner ( + id serial not null, + nome_inner varchar(255), + outer_id integer, + update_count integer not null, + constraint pk_eemb_inner primary key (id) +); + +create table eemb_outer ( + id serial not null, + nome_outer varchar(255), + date1 timestamptz, + date2 timestamptz, + update_count integer not null, + constraint pk_eemb_outer primary key (id) +); + +create table efile2_no_fk ( + file_name varchar(64) not null, + owner_id integer not null, + constraint pk_efile2_no_fk primary key (file_name) +); + +create table efile_no_fk ( + file_name varchar(64) not null, + owner_user_id integer, + owner_soft_del_user_id integer, + constraint pk_efile_no_fk primary key (file_name) +); + +create table efile_no_fk_euser_no_fk ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) +); + +create table efile_no_fk_euser_no_fk_soft_del ( + efile_no_fk_file_name varchar(64) not null, + euser_no_fk_soft_del_user_id integer not null, + constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) +); + +create table egen_props ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + ts_created timestamptz not null, + ts_updated timestamptz not null, + ldt_created timestamptz not null, + ldt_updated timestamptz not null, + odt_created timestamptz not null, + odt_updated timestamptz not null, + zdt_created timestamptz not null, + zdt_updated timestamptz not null, + instant_created timestamptz not null, + instant_updated timestamptz not null, + long_created bigint not null, + long_updated bigint not null, + constraint pk_egen_props primary key (id) +); + +create table einvoice ( + id bigserial not null, + invoice_date timestamptz, + state integer, + person_id bigint, + ship_street varchar(255), + ship_suburb varchar(255), + ship_city varchar(255), + ship_status varchar(3), + bill_street varchar(255), + bill_suburb varchar(255), + bill_city varchar(255), + bill_status varchar(3), + version bigint not null, + constraint ck_einvoice_state check ( state in (0,1,2)), + constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), + constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), + constraint pk_einvoice primary key (id) +); + +create table e_main ( + id serial not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_e_main primary key (id) +); + +create table enull_collection ( + id serial not null, + name varchar(255), + constraint pk_enull_collection primary key (id) +); + +create table enull_collection_detail ( + id serial not null, + enull_collection_id integer not null, + something varchar(255), + constraint pk_enull_collection_detail primary key (id) +); + +create table eopt_one_a ( + id serial not null, + name_for_a varchar(255), + b_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_a primary key (id) +); + +create table eopt_one_b ( + id serial not null, + name_for_b varchar(255), + c_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_b primary key (id) +); + +create table eopt_one_c ( + id serial not null, + name_for_c varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_eopt_one_c primary key (id) +); + +create table eper_addr ( + id bigserial not null, + name varchar(255), + ma_street varchar(255), + ma_suburb varchar(255), + ma_city varchar(255), + ma_country_code varchar(2), + version bigint not null, + constraint pk_eper_addr primary key (id) +); + +create table eperson ( + id bigserial not null, + name varchar(255), + notes varchar(255), + street varchar(255), + suburb varchar(255), + addr_city varchar(255), + addr_status varchar(3), + version bigint not null, + constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), + constraint pk_eperson primary key (id) +); + +create table e_person_online ( + id bigserial not null, + email varchar(127), + online_status boolean default false not null, + when_updated timestamptz not null, + constraint uq_e_person_online_email unique (email), + constraint pk_e_person_online primary key (id) +); + +create table esimple ( + usertypeid serial not null, + name varchar(255), + constraint pk_esimple primary key (usertypeid) +); + +create table esoft_del_book ( + id bigserial not null, + book_title varchar(255), + lend_by_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_book primary key (id) +); + +create table esoft_del_book_esoft_del_user ( + esoft_del_book_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) +); + +create table esoft_del_down ( + id bigserial not null, + esoft_del_mid_id bigint not null, + down varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_down primary key (id) +); + +create table esoft_del_mid ( + id bigserial not null, + top_id bigint, + mid varchar(255), + up_id bigint, + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_mid primary key (id) +); + +create table esoft_del_one_a ( + id bigserial not null, + name varchar(255), + oneb_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), + constraint pk_esoft_del_one_a primary key (id) +); + +create table esoft_del_one_b ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_esoft_del_one_b primary key (id) +); + +create table esoft_del_role ( + id bigserial not null, + role_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_role primary key (id) +); + +create table esoft_del_role_esoft_del_user ( + esoft_del_role_id bigint not null, + esoft_del_user_id bigint not null, + constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) +); + +create table esoft_del_top ( + id bigserial not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_top primary key (id) +); + +create table esoft_del_up ( + id bigserial not null, + up varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_up primary key (id) +); + +create table esoft_del_user ( + id bigserial not null, + user_name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esoft_del_user primary key (id) +); + +create table esoft_del_user_esoft_del_role ( + esoft_del_user_id bigint not null, + esoft_del_role_id bigint not null, + constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) +); + +create table esome_convert_type ( + id bigserial not null, + name varchar(255), + money decimal(38), + constraint pk_esome_convert_type primary key (id) +); + +create table esome_type ( + id serial not null, + currency varchar(3), + locale varchar(20), + time_zone varchar(20), + constraint pk_esome_type primary key (id) +); + +create table etrans_many ( + id serial not null, + name varchar(255), + constraint pk_etrans_many primary key (id) +); + +create table rawinherit_uncle ( + id serial not null, + name varchar(255), + parent_id bigint not null, + version bigint not null, + constraint pk_rawinherit_uncle primary key (id) +); + +create table euser_no_fk ( + user_id serial not null, + user_name varchar(255), + constraint pk_euser_no_fk primary key (user_id) +); + +create table euser_no_fk_soft_del ( + user_id serial not null, + user_name varchar(255), + constraint pk_euser_no_fk_soft_del primary key (user_id) +); + +create table evanilla_collection ( + id serial not null, + name varchar(255), + constraint pk_evanilla_collection primary key (id) +); + +create table evanilla_collection_detail ( + id serial not null, + evanilla_collection_id integer not null, + something varchar(255), + constraint pk_evanilla_collection_detail primary key (id) +); + +create table ewho_props ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + who_created varchar(255) not null, + who_modified varchar(255) not null, + constraint pk_ewho_props primary key (id) +); + +create table e_withinet ( + id bigserial not null, + name varchar(255), + inet_address inet, + inet2 inet, + cdir inet, + version bigint not null, + constraint pk_e_withinet primary key (id) +); + +create table ec_enum_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ec_enum_person primary key (id) +); + +create table ec_enum_person_tags ( + ec_enum_person_id bigint not null, + value varchar(5) not null, + constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) +); + +create table ec_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ec_person primary key (id) +); + +create table ec_person_phone ( + owner_id bigint not null, + phone varchar(255) not null +); + +create table ecbl_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecbl_person primary key (id) +); + +create table ecbl_person_phone_numbers ( + person_id bigint not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecbm_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecbm_person primary key (id) +); + +create table ecbm_person_phone_numbers ( + person_id bigint not null, + mkey varchar(255) not null, + country_code varchar(2), + area varchar(6), + number varchar(20) +); + +create table ecm_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecm_person primary key (id) +); + +create table ecm_person_phone_numbers ( + ecm_person_id bigint not null, + type varchar(4) not null, + number varchar(10) not null +); + +create table ecmc_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecmc_person primary key (id) +); + +create table ecmc_person_phone_numbers ( + ecmc_person_id bigint not null, + type varchar(4) not null, + value text not null +); + +create table ecs_person ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_ecs_person primary key (id) +); + +create table ecs_person_phone ( + ecs_person_id bigint not null, + phone varchar(255) not null +); + +create table td_child ( + child_id serial not null, + child_name varchar(255), + parent_id integer not null, + constraint pk_td_child primary key (child_id) +); + +create table td_parent ( + parent_type varchar(31) not null, + parent_id serial not null, + parent_name varchar(255), + extended_name varchar(255), + constraint pk_td_parent primary key (parent_id) +); + +create table empl ( + id bigserial not null, + name varchar(255), + age integer, + default_address_id bigint, + constraint pk_empl primary key (id) +); + +create table esd_detail ( + id bigserial not null, + name varchar(255), + master_id bigint not null, + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_detail primary key (id) +); + +create table esd_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + deleted boolean default false not null, + constraint pk_esd_master primary key (id) +); + +create table feature_desc ( + id serial not null, + name varchar(255), + description varchar(255), + constraint pk_feature_desc primary key (id) +); + +create table f_first ( + id bigserial not null, + name varchar(255), + constraint pk_f_first primary key (id) +); + +create table foo ( + foo_id serial not null, + important_text varchar(255), + version integer not null, + constraint pk_foo primary key (foo_id) +); + +create table gen_key_identity ( + id bigserial not null, + description varchar(255), + constraint pk_gen_key_identity primary key (id) +); + +create table gen_key_sequence ( + id bigint not null, + description varchar(255), + constraint pk_gen_key_sequence primary key (id) +); +create sequence SEQ; + +create table gen_key_table ( + id bigserial not null, + description varchar(255), + constraint pk_gen_key_table primary key (id) +); + +create table grand_parent_person ( + identifier serial not null, + name varchar(255), + age integer, + some_bean_id integer, + family_name varchar(255), + address varchar(255), + constraint pk_grand_parent_person primary key (identifier) +); + +create table survey_group ( + id bigserial not null, + name varchar(255), + categoryobjectid bigint, + sequence_number integer not null, + constraint pk_survey_group primary key (id) +); + +create table c_group ( + id bigserial not null, + inactive boolean default false not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_group primary key (id) +); + +create table he_doc ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_he_doc primary key (id) +); + +create table hx_link ( + id bigserial not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_hx_link primary key (id) +); + +create table hx_link_doc ( + hx_link_id bigint not null, + he_doc_id bigint not null, + constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) +); + +create table hi_doc ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_doc primary key (id) +); + +create table hi_link ( + id bigserial not null, + name varchar(255), + location varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_link primary key (id) +); + +create table hi_link_doc ( + hi_link_id bigint not null, + hi_doc_id bigint not null, + constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) +); + +create table hi_tone ( + id bigserial not null, + name varchar(255), + comments varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_tone primary key (id) +); + +create table hi_tthree ( + id bigserial not null, + hi_ttwo_id bigint not null, + three varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_tthree primary key (id) +); + +create table hi_ttwo ( + id bigserial not null, + hi_tone_id bigint not null, + two varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_hi_ttwo primary key (id) +); + +create table hsd_setting ( + id bigserial not null, + code varchar(255), + content varchar(255), + user_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint uq_hsd_setting_user_id unique (user_id), + constraint pk_hsd_setting primary key (id) +); + +create table hsd_user ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_hsd_user primary key (id) +); + +create table iaf_segment ( + ptype varchar(31) not null, + id bigserial not null, + segment_id_zat bigint not null, + status_id bigint not null, + constraint pk_iaf_segment primary key (id) +); + +create table iaf_segment_status ( + id bigserial not null, + name varchar(255), + constraint pk_iaf_segment_status primary key (id) +); + +create table imrelated ( + id bigserial not null, + name varchar(255), + owner_id bigint not null, + constraint pk_imrelated primary key (id) +); + +create table imroot ( + dtype varchar(31) not null, + id bigserial not null, + name varchar(255), + title varchar(255), + when_title timestamptz, + constraint pk_imroot primary key (id) +); + +create table ixresource ( + dtype varchar(255), + id uuid not null, + name varchar(255), + constraint pk_ixresource primary key (id) +); + +create table info_company ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_info_company primary key (id) +); + +create table info_contact ( + id bigserial not null, + name varchar(255), + company_id bigint not null, + version bigint not null, + constraint pk_info_contact primary key (id) +); + +create table info_customer ( + id bigserial not null, + name varchar(255), + company_id bigint, + version bigint not null, + constraint uq_info_customer_company_id unique (company_id), + constraint pk_info_customer primary key (id) +); + +create table inner_report ( + id bigserial not null, + name varchar(255), + forecast_id bigint, + constraint uq_inner_report_forecast_id unique (forecast_id), + constraint pk_inner_report primary key (id) +); + +create table drel_invoice ( + id bigint not null, + booking bigint, + version integer not null, + constraint pk_drel_invoice primary key (id) +); +create sequence drel_invoice_seq; + +create table item ( + customer integer not null, + itemnumber varchar(127) not null, + description varchar(255), + units varchar(255), + type integer not null, + region integer not null, + date_modified timestamptz, + date_created timestamptz, + modified_by varchar(255), + created_by varchar(255), + version bigint not null, + constraint pk_item primary key (customer,itemnumber) +); + +create table monkey ( + mid bigserial not null, + name varchar(255), + food_preference varchar(255), + version bigint not null, + constraint pk_monkey primary key (mid) +); + +create table mkeygroup ( + pid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mkeygroup primary key (pid) +); + +create table mkeygroup_monkey ( + mkeygroup_pid bigint not null, + monkey_mid bigint not null, + constraint uq_mkeygroup_monkey_mid unique (monkey_mid), + constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) +); + +create table trainer ( + tid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_trainer primary key (tid) +); + +create table trainer_monkey ( + trainer_tid bigint not null, + monkey_mid bigint not null, + constraint uq_trainer_monkey_mid unique (monkey_mid), + constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) +); + +create table troop ( + pid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_troop primary key (pid) +); + +create table troop_monkey ( + troop_pid bigint not null, + monkey_mid bigint not null, + constraint uq_troop_monkey_mid unique (monkey_mid), + constraint pk_troop_monkey primary key (troop_pid,monkey_mid) +); + +create table l2_cldf_reset_bean ( + id bigserial not null, + name varchar(255), + constraint pk_l2_cldf_reset_bean primary key (id) +); + +create table l2_cldf_reset_bean_child ( + id bigserial not null, + parent_id bigint, + constraint pk_l2_cldf_reset_bean_child primary key (id) +); + +create table level1 ( + id bigserial not null, + name varchar(255), + constraint pk_level1 primary key (id) +); + +create table level1_level4 ( + level1_id bigint not null, + level4_id bigint not null, + constraint pk_level1_level4 primary key (level1_id,level4_id) +); + +create table level1_level2 ( + level1_id bigint not null, + level2_id bigint not null, + constraint pk_level1_level2 primary key (level1_id,level2_id) +); + +create table level2 ( + id bigserial not null, + name varchar(255), + constraint pk_level2 primary key (id) +); + +create table level2_level3 ( + level2_id bigint not null, + level3_id bigint not null, + constraint pk_level2_level3 primary key (level2_id,level3_id) +); + +create table level3 ( + id bigserial not null, + name varchar(255), + constraint pk_level3 primary key (id) +); + +create table level4 ( + id bigserial not null, + name varchar(255), + constraint pk_level4 primary key (id) +); + +create table link ( + id bigserial not null, + name varchar(255), + location varchar(255), + when_publish timestamptz, + link_comment varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_link primary key (id) +); + +create table link_draft ( + id bigserial not null, + name varchar(255), + location varchar(255), + when_publish timestamptz, + link_comment varchar(255), + dirty boolean default false not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + deleted boolean default false not null, + constraint pk_link_draft primary key (id) +); + +create table la_attr_value ( + id serial not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_la_attr_value primary key (id) +); + +create table la_attr_value_attribute ( + la_attr_value_id integer not null, + attribute_id integer not null, + constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) +); + +create table looney ( + id bigserial not null, + tune_id bigint, + name varchar(255), + constraint pk_looney primary key (id) +); + +create table maddress ( + id uuid not null, + street varchar(255), + city varchar(255), + version bigint not null, + constraint pk_maddress primary key (id) +); + +create table mcontact ( + id uuid not null, + email varchar(255), + first_name varchar(255), + last_name varchar(255), + customer_id uuid, + version bigint not null, + constraint pk_mcontact primary key (id) +); + +create table mcontact_message ( + id uuid not null, + title varchar(255), + subject varchar(255), + notes varchar(255), + contact_id uuid not null, + version bigint not null, + constraint pk_mcontact_message primary key (id) +); + +create table mcustomer ( + id uuid not null, + name varchar(255), + notes varchar(255), + shipping_address_id uuid, + billing_address_id uuid, + version bigint not null, + constraint pk_mcustomer primary key (id) +); + +create table mgroup ( + id bigserial not null, + name varchar(255), + constraint pk_mgroup primary key (id) +); + +create table mmachine ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mmachine primary key (id) +); + +create table mmachine_mgroup ( + mmachine_id bigint not null, + mgroup_id bigint not null, + constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) +); + +create table mmedia ( + type varchar(31) not null, + id bigserial not null, + url varchar(255), + note varchar(255), + constraint pk_mmedia primary key (id) +); + +create table non_updateprop ( + id serial not null, + non_enum varchar(5), + name varchar(255), + note varchar(255), + constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), + constraint pk_non_updateprop primary key (id) +); + +create table mprinter ( + id bigserial not null, + name varchar(255), + flags bigint not null, + current_state_id bigint, + last_swap_cyan_id bigint, + last_swap_magenta_id bigint, + last_swap_yellow_id bigint, + last_swap_black_id bigint, + version bigint not null, + constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), + constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), + constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), + constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), + constraint pk_mprinter primary key (id) +); + +create table mprinter_state ( + id bigserial not null, + flags bigint not null, + printer_id bigint, + version bigint not null, + constraint pk_mprinter_state primary key (id) +); + +create table mprofile ( + id bigserial not null, + picture_id bigint, + name varchar(255), + constraint pk_mprofile primary key (id) +); + +create table mprotected_construct_bean ( + id bigserial not null, + name varchar(255), + constraint pk_mprotected_construct_bean primary key (id) +); + +create table mrole ( + roleid serial not null, + role_name varchar(255), + constraint pk_mrole primary key (roleid) +); + +create table mrole_muser ( + mrole_roleid integer not null, + muser_userid integer not null, + constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) +); + +create table msome_other ( + id bigserial not null, + name varchar(255), + constraint pk_msome_other primary key (id) +); + +create table muser ( + userid serial not null, + user_name varchar(255), + user_type_id integer, + constraint pk_muser primary key (userid) +); + +create table muser_type ( + id serial not null, + name varchar(255), + constraint pk_muser_type primary key (id) +); + +create table mail_box ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mail_box primary key (id) +); + +create table mail_user ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mail_user primary key (id) +); + +create table mail_user_inbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) +); + +create table mail_user_outbox ( + mail_user_id bigint not null, + mail_box_id bigint not null, + constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) +); + +create table main_entity ( + id varchar(255) not null, + attr1 varchar(255), + attr2 varchar(255), + constraint pk_main_entity primary key (id) +); + +create table main_entity_relation ( + id uuid not null, + id1 varchar(255), + id2 varchar(255), + attr1 varchar(255), + constraint pk_main_entity_relation primary key (id) +); + +create table map_super_actual ( + id bigserial not null, + name varchar(255), + when_created timestamptz not null, + when_updated timestamptz not null, + constraint pk_map_super_actual primary key (id) +); + +create table c_message ( + id bigserial not null, + title varchar(255), + body varchar(255), + conversation_id bigint, + user_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_message primary key (id) +); + +create table meter_address_data ( + id uuid not null, + street varchar(255) not null, + constraint pk_meter_address_data primary key (id) +); + +create table meter_contract_data ( + id uuid not null, + special_needs_client_id uuid not null, + constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), + constraint pk_meter_contract_data primary key (id) +); + +create table meter_special_needs_client ( + id uuid not null, + name varchar(255), + primary_id uuid, + constraint uq_meter_special_needs_client_primary_id unique (primary_id), + constraint pk_meter_special_needs_client primary key (id) +); + +create table meter_special_needs_contact ( + id uuid not null, + name varchar(255), + constraint pk_meter_special_needs_contact primary key (id) +); + +create table meter_version ( + id uuid not null, + address_data_id uuid, + contract_data_id uuid not null, + constraint uq_meter_version_address_data_id unique (address_data_id), + constraint uq_meter_version_contract_data_id unique (contract_data_id), + constraint pk_meter_version primary key (id) +); + +create table mnoc_role ( + role_id serial not null, + role_name varchar(255), + version integer not null, + constraint pk_mnoc_role primary key (role_id) +); + +create table mnoc_user ( + user_id serial not null, + user_name varchar(255), + version integer not null, + constraint pk_mnoc_user primary key (user_id) +); + +create table mnoc_user_mnoc_role ( + mnoc_user_user_id integer not null, + mnoc_role_role_id integer not null, + constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) +); + +create table mny_a ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_a primary key (id) +); + +create table mny_b ( + id bigserial not null, + name varchar(255), + a_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_b primary key (id) +); + +create table mny_b_mny_c ( + mny_b_id bigint not null, + mny_c_id bigint not null, + constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) +); + +create table mny_c ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_mny_c primary key (id) +); + +create table mny_topic ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_mny_topic primary key (id) +); + +create table subtopics ( + topic bigint not null, + subtopic bigint not null, + constraint pk_subtopics primary key (topic,subtopic) +); + +create table mp_role ( + id bigserial not null, + mp_user_id bigint not null, + code varchar(255), + organization_id bigint, + constraint pk_mp_role primary key (id) +); + +create table mp_user ( + id bigserial not null, + name varchar(255), + constraint pk_mp_user primary key (id) +); + +create table ms_many_a ( + aid bigserial not null, + name varchar(255), + ms_many_a_many_b boolean default false not null, + ms_many_b boolean default false not null, + deleted boolean default false not null, + constraint pk_ms_many_a primary key (aid) +); + +create table ms_many_a_many_b ( + ms_many_a_aid bigint not null, + ms_many_b_bid bigint not null, + constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) +); + +create table ms_many_b ( + bid bigserial not null, + name varchar(255), + deleted boolean default false not null, + constraint pk_ms_many_b primary key (bid) +); + +create table ms_many_b_many_a ( + ms_many_b_bid bigint not null, + ms_many_a_aid bigint not null, + constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) +); + +create table my_lob_size ( + id serial not null, + name varchar(255), + my_count integer not null, + my_lob text, + constraint pk_my_lob_size primary key (id) +); + +create table my_lob_size_join_many ( + id serial not null, + something varchar(255), + other varchar(255), + parent_id integer, + constraint pk_my_lob_size_join_many primary key (id) +); + +create table noidbean ( + name varchar(255), + subject varchar(255), + when_created timestamptz not null +); + +create table o_cached_bean ( + id bigserial not null, + name varchar(255), + constraint pk_o_cached_bean primary key (id) +); + +create table o_cached_bean_country ( + o_cached_bean_id bigint not null, + o_country_code varchar(2) not null, + constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) +); + +create table o_cached_bean_child ( + id bigserial not null, + cached_bean_id bigint, + constraint pk_o_cached_bean_child primary key (id) +); + +create table o_cached_inherit ( + dtype varchar(31) not null, + id bigserial not null, + name varchar(255), + child_adata varchar(255), + child_bdata varchar(255), + constraint pk_o_cached_inherit primary key (id) +); + +create table o_cached_natkey ( + id bigserial not null, + store varchar(255), + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey primary key (id) +); + +create table o_cached_natkey3 ( + id bigserial not null, + store varchar(255), + code integer not null, + sku varchar(255), + description varchar(255), + constraint pk_o_cached_natkey3 primary key (id) +); + +create table ocar ( + id serial not null, + vin varchar(255), + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_ocar primary key (id) +); + +create table ocompany ( + id serial not null, + corp_id varchar(50), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_ocompany_corp_id unique (corp_id), + constraint pk_ocompany primary key (id) +); + +create table oengine ( + engine_id uuid not null, + short_desc varchar(255), + car_id integer, + version integer not null, + constraint uq_oengine_car_id unique (car_id), + constraint pk_oengine primary key (engine_id) +); + +create table ogear_box ( + id uuid not null, + box_desc varchar(255), + box_size integer, + car_id integer, + version integer not null, + constraint uq_ogear_box_car_id unique (car_id), + constraint pk_ogear_box primary key (id) +); + +create table oroad_show_msg ( + id serial not null, + company_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_oroad_show_msg_company_id unique (company_id), + constraint pk_oroad_show_msg primary key (id) +); + +create table om_ordered_detail ( + id bigserial not null, + name varchar(255), + master_id bigint, + version bigint not null, + sort_order integer, + constraint pk_om_ordered_detail primary key (id) +); + +create table om_ordered_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_om_ordered_master primary key (id) +); + +create table only_id_entity ( + id bigserial not null, + constraint pk_only_id_entity primary key (id) +); + +create table o_order ( + id serial not null, + status integer, + order_date date, + ship_date date, + kcustomer_id integer not null, + cretime timestamptz not null, + updtime timestamptz not null, + constraint ck_o_order_status check ( status in (0,1,2,3)), + constraint pk_o_order primary key (id) +); + +create table o_order_detail ( + id serial not null, + order_id integer not null, + order_qty integer, + ship_qty integer, + unit_price float, + product_id integer, + cretime timestamptz, + updtime timestamptz not null, + constraint pk_o_order_detail primary key (id) +); + +create table s_orders ( + uuid varchar(40) not null, + constraint pk_s_orders primary key (uuid) +); + +create table s_order_items ( + uuid varchar(40) not null, + product_variant_uuid varchar(255), + order_uuid varchar(40), + quantity integer not null, + amount decimal(38), + constraint pk_s_order_items primary key (uuid) +); + +create table or_order_ship ( + id serial not null, + order_id integer, + ship_time timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_or_order_ship primary key (id) +); + +create table organisation ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_organisation primary key (id) +); + +create table organization_node ( + kind varchar(31) not null, + id bigserial not null, + parent_tree_node_id bigint not null, + title varchar(255), + constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), + constraint pk_organization_node primary key (id) +); + +create table organization_tree_node ( + id bigserial not null, + name varchar(255), + constraint pk_organization_tree_node primary key (id) +); + +create table orp_detail ( + id varchar(100) not null, + detail varchar(255), + master_id varchar(100), + version bigint not null, + constraint pk_orp_detail primary key (id) +); + +create table orp_detail2 ( + id varchar(100) not null, + orp_master2_id varchar(100) not null, + detail varchar(255), + master_id varchar(255), + version bigint not null, + constraint pk_orp_detail2 primary key (id) +); + +create table orp_master ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master primary key (id) +); + +create table orp_master2 ( + id varchar(100) not null, + name varchar(255), + version bigint not null, + constraint pk_orp_master2 primary key (id) +); + +create table oto_aone ( + id varchar(100) not null, + description varchar(255), + constraint pk_oto_aone primary key (id) +); + +create table oto_atwo ( + id varchar(100) not null, + description varchar(255), + aone_id varchar(100), + constraint uq_oto_atwo_aone_id unique (aone_id), + constraint pk_oto_atwo primary key (id) +); + +create table oto_bchild ( + master_id bigint not null, + child varchar(255), + constraint pk_oto_bchild primary key (master_id) +); + +create table oto_bmaster ( + id bigserial not null, + name varchar(255), + constraint pk_oto_bmaster primary key (id) +); + +create table oto_child ( + id serial not null, + name varchar(255), + master_id bigint, + constraint uq_oto_child_master_id unique (master_id), + constraint pk_oto_child primary key (id) +); + +create table oto_cust ( + cid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_oto_cust primary key (cid) +); + +create table oto_cust_address ( + aid bigserial not null, + line1 varchar(255), + line2 varchar(255), + line3 varchar(255), + customer_cid bigint, + version bigint not null, + constraint uq_oto_cust_address_customer_cid unique (customer_cid), + constraint pk_oto_cust_address primary key (aid) +); + +create table oto_level_a ( + id bigserial not null, + name varchar(255), + b_id bigint, + constraint uq_oto_level_a_b_id unique (b_id), + constraint pk_oto_level_a primary key (id) +); + +create table oto_level_b ( + id bigserial not null, + name varchar(255), + c_id bigint, + constraint uq_oto_level_b_c_id unique (c_id), + constraint pk_oto_level_b primary key (id) +); + +create table oto_level_c ( + id bigserial not null, + name varchar(255), + constraint pk_oto_level_c primary key (id) +); + +create table oto_master ( + id bigserial not null, + name varchar(255), + constraint pk_oto_master primary key (id) +); + +create table oto_prime ( + pid bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_oto_prime primary key (pid) +); + +create table oto_prime_extra ( + eid bigint not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_prime_extra primary key (eid) +); + +create table oto_sd_child ( + id bigserial not null, + child varchar(255), + master_id bigint, + deleted boolean default false not null, + version bigint not null, + constraint uq_oto_sd_child_master_id unique (master_id), + constraint pk_oto_sd_child primary key (id) +); + +create table oto_sd_master ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_oto_sd_master primary key (id) +); + +create table oto_th_many ( + id bigserial not null, + oto_th_top_id bigint not null, + many varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_th_many primary key (id) +); + +create table oto_th_one ( + id bigserial not null, + one boolean default false not null, + many_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_th_one_many_id unique (many_id), + constraint pk_oto_th_one primary key (id) +); + +create table oto_th_top ( + id bigserial not null, + topp varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_th_top primary key (id) +); + +create table oto_ubprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_ubprime primary key (pid) +); + +create table oto_ubprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_ubprime_extra primary key (eid) +); + +create table oto_uprime ( + pid uuid not null, + name varchar(255), + version bigint not null, + constraint pk_oto_uprime primary key (pid) +); + +create table oto_uprime_extra ( + eid uuid not null, + extra varchar(255), + version bigint not null, + constraint pk_oto_uprime_extra primary key (eid) +); + +create table oto_user_model ( + id bigserial not null, + name varchar(255), + user_optional_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_user_model_user_optional_id unique (user_optional_id), + constraint pk_oto_user_model primary key (id) +); + +create table oto_user_model_optional ( + id bigserial not null, + optional varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_oto_user_model_optional primary key (id) +); + +create table pfile ( + id serial not null, + name varchar(255), + file_content_id integer, + file_content2_id integer, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_pfile_file_content_id unique (file_content_id), + constraint uq_pfile_file_content2_id unique (file_content2_id), + constraint pk_pfile primary key (id) +); + +create table pfile_content ( + id serial not null, + content bytea, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_pfile_content primary key (id) +); + +create table paggview ( + pview_id uuid, + amount integer not null, + constraint uq_paggview_pview_id unique (pview_id) +); + +create table pallet_location ( + type varchar(31) not null, + id serial not null, + zone_sid integer not null, + attribute varchar(255), + constraint pk_pallet_location primary key (id) +); + +create table parcel ( + parcelid bigserial not null, + description varchar(255), + constraint pk_parcel primary key (parcelid) +); + +create table parcel_location ( + parcellocid bigserial not null, + location varchar(255), + parcelid bigint, + constraint uq_parcel_location_parcelid unique (parcelid), + constraint pk_parcel_location primary key (parcellocid) +); + +create table rawinherit_parent ( + type varchar(31) not null, + id bigserial not null, + val integer, + more varchar(255), + constraint pk_rawinherit_parent primary key (id) +); + +create table rawinherit_parent_rawinherit_data ( + rawinherit_parent_id bigint not null, + rawinherit_data_id bigint not null, + constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) +); + +create table e_save_test_c ( + id bigserial not null, + version bigint not null, + constraint pk_e_save_test_c primary key (id) +); + +create table parent_person ( + identifier serial not null, + name varchar(255), + age integer, + some_bean_id integer, + parent_identifier integer, + family_name varchar(255), + address varchar(255), + constraint pk_parent_person primary key (identifier) +); + +create table c_participation ( + id bigserial not null, + rating integer, + type integer, + conversation_id bigint not null, + user_id bigint not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint ck_c_participation_type check ( type in (0,1)), + constraint pk_c_participation primary key (id) +); + +create table password_store_model ( + id bigserial not null, + enc1 varchar(30), + enc2 varchar(40), + enc3 text, + enc4 bytea, + enc5 bytea, + enc6 bytea, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_password_store_model primary key (id) +); + +create table mt_permission ( + id uuid not null, + name varchar(255), + constraint pk_mt_permission primary key (id) +); + +create table persistent_file ( + id serial not null, + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_persistent_file primary key (id) +); + +create table persistent_file_content ( + id serial not null, + persistent_file_id integer, + content bytea, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), + constraint pk_persistent_file_content primary key (id) +); + +create table person ( + oid bigserial not null, + default_address_oid bigint, + version integer not null, + constraint pk_person primary key (oid) +); + +create table persons ( + id bigserial not null, + surname varchar(64) not null, + name varchar(64) not null, + constraint pk_persons primary key (id) +); + +create table person_cache_email ( + id varchar(128) not null, + person_info_person_id varchar(128), + email varchar(255), + constraint pk_person_cache_email primary key (id) +); + +create table person_cache_info ( + person_id varchar(128) not null, + name varchar(255), + constraint pk_person_cache_info primary key (person_id) +); + +create table phones ( + id bigserial not null, + phone_number varchar(7) not null, + person_id bigint not null, + constraint uq_phones_phone_number unique (phone_number), + constraint pk_phones primary key (id) +); + +create table e_position ( + id bigserial not null, + name varchar(255), + contract_id bigint not null, + constraint pk_e_position primary key (id) +); + +create table primary_revision ( + id bigint not null, + revision integer not null, + name varchar(255), + version bigint not null, + constraint pk_primary_revision primary key (id,revision) +); + +create table o_product ( + id serial not null, + sku varchar(20), + name varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + constraint pk_o_product primary key (id) +); + +create table pp ( + id uuid not null, + name varchar(255), + value varchar(100) not null, + constraint pk_pp primary key (id) +); + +create table pp_to_ww ( + pp_id uuid not null, + ww_id uuid not null, + constraint pk_pp_to_ww primary key (pp_id,ww_id) +); + +create table question ( + id bigserial not null, + name varchar(255), + groupobjectid bigint, + sequence_number integer not null, + constraint pk_question primary key (id) +); + +create table rcustomer ( + company varchar(127) not null, + name varchar(127) not null, + description varchar(255), + constraint pk_rcustomer primary key (company,name) +); + +create table r_orders ( + company varchar(127) not null, + order_number integer not null, + customername varchar(127), + item varchar(255), + constraint pk_r_orders primary key (company,order_number) +); + +create table region ( + customer integer not null, + type integer not null, + description varchar(255), + version bigint not null, + constraint pk_region primary key (customer,type) +); + +create table rel_detail ( + id bigserial not null, + name varchar(255), + version integer not null, + constraint pk_rel_detail primary key (id) +); + +create table rel_master ( + id bigserial not null, + name varchar(255), + detail_id bigint, + version integer not null, + constraint pk_rel_master primary key (id) +); + +create table resourcefile ( + id varchar(64) not null, + parentresourcefileid varchar(64), + name varchar(128) not null, + constraint pk_resourcefile primary key (id) +); + +create table mt_role ( + id uuid not null, + name varchar(50), + tenant_id uuid, + version bigint not null, + constraint pk_mt_role primary key (id) +); + +create table mt_role_permission ( + mt_role_id uuid not null, + mt_permission_id uuid not null, + constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) +); + +create table em_role ( + id bigserial not null, + name varchar(255), + constraint pk_em_role primary key (id) +); + +create table f_second ( + id bigserial not null, + mod_name varchar(255), + first bigint, + title varchar(255), + constraint uq_f_second_first unique (first), + constraint pk_f_second primary key (id) +); + +create table section ( + id serial not null, + article_id integer, + type integer, + content text, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint ck_section_type check ( type in (0,1)), + constraint pk_section primary key (id) +); + +create table self_parent ( + id bigserial not null, + name varchar(255), + parent_id bigint, + version bigint not null, + constraint pk_self_parent primary key (id) +); + +create table self_ref_customer ( + id bigserial not null, + name varchar(255), + referred_by_id bigint, + constraint pk_self_ref_customer primary key (id) +); + +create table self_ref_example ( + id bigserial not null, + name varchar(255) not null, + parent_id bigint, + constraint pk_self_ref_example primary key (id) +); + +create table e_save_test_a ( + id bigserial not null, + version bigint not null, + constraint pk_e_save_test_a primary key (id) +); + +create table e_save_test_b ( + id bigserial not null, + sibling_a_id bigint, + test_property boolean default false not null, + version bigint not null, + constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), + constraint pk_e_save_test_b primary key (id) +); + +create table site ( + id uuid not null, + name varchar(255), + parent_id uuid, + data_container_id uuid, + site_address_id uuid, + constraint uq_site_data_container_id unique (data_container_id), + constraint uq_site_site_address_id unique (site_address_id), + constraint pk_site primary key (id) +); + +create table site_address ( + id uuid not null, + street varchar(255), + city varchar(255), + zip_code varchar(255), + constraint pk_site_address primary key (id) +); + +create table some_enum_bean ( + id bigserial not null, + some_enum integer, + name varchar(255), + constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), + constraint pk_some_enum_bean primary key (id) +); + +create table some_file_bean ( + id bigserial not null, + name varchar(255), + content bytea, + version bigint not null, + constraint pk_some_file_bean primary key (id) +); + +create table some_new_types_bean ( + id bigserial not null, + dow integer, + mth integer, + yr integer, + yr_mth date, + month_day date, + local_date date, + local_date_time timestamptz, + offset_date_time timestamptz, + zoned_date_time timestamptz, + local_time time, + instant timestamptz, + zone_id varchar(60), + zone_offset varchar(60), + path varchar(255), + period varchar(20), + duration bigint, + version bigint not null, + constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), + constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), + constraint pk_some_new_types_bean primary key (id) +); + +create table some_period_bean ( + id bigserial not null, + anniversary date, + version bigint not null, + constraint pk_some_period_bean primary key (id) +); + +create table stockforecast ( + type varchar(31) not null, + id bigserial not null, + inner_report_id bigint, + constraint pk_stockforecast primary key (id) +); + +create table sub_section ( + id serial not null, + section_id integer, + title varchar(255), + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_sub_section primary key (id) +); + +create table sub_type ( + sub_type_id serial not null, + description varchar(255), + version bigint not null, + constraint pk_sub_type primary key (sub_type_id) +); + +create table survey ( + id bigserial not null, + name varchar(255), + constraint pk_survey primary key (id) +); + +create table tbytes_only ( + id serial not null, + content bytea, + constraint pk_tbytes_only primary key (id) +); + +create table tcar ( + type varchar(31) not null, + plate_no varchar(32) not null, + truckload bigint, + constraint pk_tcar primary key (plate_no) +); + +create table tevent ( + id bigserial not null, + name varchar(255), + version bigint not null, + constraint pk_tevent primary key (id) +); + +create table tevent_many ( + id bigserial not null, + description varchar(255), + event_id bigint, + units integer not null, + amount float not null, + version bigint not null, + constraint pk_tevent_many primary key (id) +); + +create table tevent_one ( + id bigserial not null, + name varchar(255), + status integer, + event_id bigint, + version bigint not null, + constraint ck_tevent_one_status check ( status in (0,1)), + constraint uq_tevent_one_event_id unique (event_id), + constraint pk_tevent_one primary key (id) +); + +create table tint_root ( + my_type integer not null, + id serial not null, + name varchar(255), + child_property varchar(255), + constraint pk_tint_root primary key (id) +); + +create table tjoda_entity ( + id serial not null, + local_time time, + constraint pk_tjoda_entity primary key (id) +); + +create table t_mapsuper1 ( + id serial not null, + something varchar(255), + name varchar(255), + version integer not null, + constraint pk_t_mapsuper1 primary key (id) +); + +create table t_oneb ( + id serial not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_oneb primary key (id) +); + +create table t_detail_with_other_namexxxyy ( + id integer not null, + name varchar(255), + description varchar(255), + some_unique_value varchar(127), + active boolean default false not null, + master_id integer, + constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), + constraint pk_t_detail_with_other_namexxxyy primary key (id) +); +create sequence t_atable_detail_seq; + +create table ts_detail_two ( + id serial not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + master_id integer, + constraint pk_ts_detail_two primary key (id) +); + +create table t_atable_thatisrelatively ( + id integer not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_t_atable_thatisrelatively primary key (id) +); +create sequence t_atable_master_seq; + +create table ts_master_two ( + id serial not null, + name varchar(255), + description varchar(255), + active boolean default false not null, + constraint pk_ts_master_two primary key (id) +); + +create table tuuid_entity ( + id uuid not null, + name varchar(255), + constraint pk_tuuid_entity primary key (id) +); + +create table twheel ( + id bigserial not null, + owner_plate_no varchar(32) not null, + constraint pk_twheel primary key (id) +); + +create table twith_pre_insert ( + id serial not null, + name varchar(255) not null, + title varchar(255), + constraint pk_twith_pre_insert primary key (id) +); + +create table mt_tenant ( + id uuid not null, + name varchar(255), + version bigint not null, + constraint pk_mt_tenant primary key (id) +); + +create table test_annotation_base_entity ( + direct varchar(255), + meta varchar(255), + mixed varchar(255), + constraint_annotation varchar(40), + null1 varchar(255) not null, + null2 varchar(255), + null3 varchar(255) +); + +create table tire ( + id bigint not null, + wheel bigint, + version integer not null, + constraint uq_tire_wheel unique (wheel), + constraint pk_tire primary key (id) +); +create sequence tire_seq; + +create table sa_tire ( + id bigint not null, + version integer not null, + constraint pk_sa_tire primary key (id) +); +create sequence sa_tire_seq; + +create table trip ( + id serial not null, + vehicle_driver_id integer, + destination varchar(255), + address_id smallint, + star_date timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_trip primary key (id) +); + +create table truck_ref ( + id serial not null, + something varchar(255), + constraint pk_truck_ref primary key (id) +); + +create table tune ( + id bigserial not null, + name varchar(255), + constraint pk_tune primary key (id) +); + +create table "type" ( + customer integer not null, + type integer not null, + description varchar(255), + sub_type_id integer, + version bigint not null, + constraint pk_type primary key (customer,type) +); + +create table tz_bean ( + id bigserial not null, + moda varchar(255), + ts timestamptz, + tstz timestamptz, + constraint pk_tz_bean primary key (id) +); + +create table usib_child ( + id uuid not null, + parent_id bigint, + deleted boolean default false not null, + constraint pk_usib_child primary key (id) +); + +create table usib_child_sibling ( + id bigserial not null, + child_id uuid, + deleted boolean default false not null, + constraint uq_usib_child_sibling_child_id unique (child_id), + constraint pk_usib_child_sibling primary key (id) +); + +create table usib_parent ( + id bigserial not null, + deleted boolean default false not null, + constraint pk_usib_parent primary key (id) +); + +create table ut_detail ( + id serial not null, + utmaster_id integer not null, + name varchar(255), + qty integer, + amount float, + version integer not null, + constraint pk_ut_detail primary key (id) +); + +create table ut_master ( + id serial not null, + name varchar(255), + description varchar(255), + date date, + version integer not null, + constraint pk_ut_master primary key (id) +); + +create table uuone ( + id uuid not null, + name varchar(255), + description varchar(255), + version bigint not null, + constraint pk_uuone primary key (id) +); + +create table uutwo ( + id uuid not null, + name varchar(255), + notes varchar(255), + master_id uuid, + version bigint not null, + constraint pk_uutwo primary key (id) +); + +create table oto_user ( + id bigserial not null, + name varchar(255), + account_id bigint not null, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint uq_oto_user_account_id unique (account_id), + constraint pk_oto_user primary key (id) +); + +create table c_user ( + id bigserial not null, + inactive boolean default false not null, + name varchar(255), + email varchar(255), + password_hash varchar(255), + group_id bigint, + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + constraint pk_c_user primary key (id) +); + +create table tx_user ( + id bigserial not null, + name varchar(255), + constraint pk_tx_user primary key (id) +); + +create table g_user ( + id bigserial not null, + username varchar(255), + version bigint not null, + constraint pk_g_user primary key (id) +); + +create table em_user ( + id bigserial not null, + name varchar(255), + constraint pk_em_user primary key (id) +); + +create table em_user_role ( + user_id bigint not null, + role_id bigint not null, + constraint pk_em_user_role primary key (user_id,role_id) +); + +create table vehicle ( + dtype varchar(3) not null, + id serial not null, + license_number varchar(255), + registration_date timestamptz, + lease_id bigint, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + siz varchar(3), + driver varchar(255), + car_ref_id integer, + notes varchar(255), + truck_ref_id integer, + capacity float, + constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), + constraint pk_vehicle primary key (id) +); + +create table vehicle_driver ( + id serial not null, + name varchar(255), + vehicle_id integer, + address_id smallint, + license_issued_on timestamptz, + cretime timestamptz not null, + updtime timestamptz not null, + version bigint not null, + constraint pk_vehicle_driver primary key (id) +); + +create table vehicle_lease ( + dtype varchar(31) not null, + id bigserial not null, + name varchar(255), + active_start date, + active_end date, + version bigint not null, + bond decimal(38), + min_duration integer not null, + day_rate decimal(38), + max_days integer, + constraint pk_vehicle_lease primary key (id) +); + +create table warehouses ( + id serial not null, + officezoneid integer, + constraint pk_warehouses primary key (id) +); + +create table warehousesshippingzones ( + warehouseid integer not null, + shippingzoneid integer not null, + constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) +); + +create table wheel ( + id bigint not null, + version integer not null, + constraint pk_wheel primary key (id) +); +create sequence wheel_seq; + +create table sa_wheel ( + id bigint not null, + tire bigint, + car bigint, + version integer not null, + constraint pk_sa_wheel primary key (id) +); +create sequence sa_wheel_seq; + +create table sp_car_wheel ( + id bigint not null, + name varchar(255), + version integer not null, + constraint pk_sp_car_wheel primary key (id) +); +create sequence sp_car_wheel_seq; + +create table g_who_props_otm ( + id bigserial not null, + name varchar(255), + version bigint not null, + when_created timestamptz not null, + when_modified timestamptz not null, + who_created_id bigint, + who_modified_id bigint, + constraint pk_g_who_props_otm primary key (id) +); + +create table with_zero ( + id bigserial not null, + name varchar(255), + parent_id integer, + lang varchar(2) default 'en' not null, + version bigint not null, + constraint pk_with_zero primary key (id) +); + +create table parent ( + id serial not null, + name varchar(255), + constraint pk_parent primary key (id) +); + +create table wview ( + id uuid not null, + name varchar(127) not null, + constraint uq_wview_name unique (name), + constraint pk_wview primary key (id) +); + +create table zones ( + type varchar(31) not null, + id serial not null, + attribute varchar(255), + constraint pk_zones primary key (id) +); + +create index ix_contact_last_name_first_name on contact (last_name,first_name); +create index ix_e_basic_name on e_basic (name); +create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); +create index ix_organization_node_kind on organization_node (kind); +create index ix_bar_foo_id on bar (foo_id); +alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; + +create index ix_acl_container_relation_container_id on acl_container_relation (container_id); +alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; + +create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); +alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; + +create index ix_addr_employee_id on addr (employee_id); +alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; + +create index ix_o_address_country_code on o_address (country_code); +alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; + +alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; + +create index ix_animal_shelter_id on animal (shelter_id); +alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; + +create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); +alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_id on bbookmark (user_id); +alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; + +create index ix_bbookmark_user_org_id on bbookmark_user (org_id); +alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_site_id on bsite_user_a (site_id); +alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_a_user_id on bsite_user_a (user_id); +alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_site on bsite_user_b (site); +alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_b_usr on bsite_user_b (usr); +alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); +alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_site_id on bsite_user_e (site_id); +alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; + +create index ix_bsite_user_e_user_id on bsite_user_e (user_id); +alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; + +alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; + +alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_category_id on cepproduct_category (category_id); +alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; + +create index ix_cepproduct_category_product_id on cepproduct_category (product_id); +alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; + +create index ix_cinh_ref_ref_id on cinh_ref (ref_id); +alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; + +create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); +alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; + +create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); +alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; + +create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); +alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); +alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); +alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; + +create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); +alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; + +create index ix_car_accessory_fuse_id on car_accessory (fuse_id); +alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; + +create index ix_car_accessory_car_id on car_accessory (car_id); +alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_category_surveyobjectid on category (surveyobjectid); +alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; + +alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; + +create index ix_child_person_some_bean_id on child_person (some_bean_id); +alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_child_person_parent_identifier on child_person (parent_identifier); +alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; + +create index ix_cke_client_user on cke_client (username,cod_cpny); +alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; + +alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_configuration_configurations_id on configuration (configurations_id); +alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; + +create index ix_contact_customer_id on contact (customer_id); +alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_contact_group_id on contact (group_id); +alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; + +create index ix_contact_note_contact_id on contact_note (contact_id); +alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; + +create index ix_contract_costs_position_id on contract_costs (position_id); +alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; + +create index ix_c_conversation_group_id on c_conversation (group_id); +alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_o_customer_billing_address_id on o_customer (billing_address_id); +alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); +alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); +alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; + +create index ix_dcredit_drol_drol on dcredit_drol (drol_id); +alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dmachine_organisation_id on dmachine (organisation_id); +alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; + +create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); +alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); +alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_d_machine_use_machine_id on d_machine_use (machine_id); +alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; + +create index ix_drot_drol_drot on drot_drol (drot_id); +alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; + +create index ix_drot_drol_drol on drot_drol (drol_id); +alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; + +create index ix_dc_detail_master_id on dc_detail (master_id); +alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; + +create index ix_dfk_cascade_one_id on dfk_cascade (one_id); +alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; + +create index ix_dfk_set_null_one_id on dfk_set_null (one_id); +alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; + +alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; + +create index ix_doc_link_doc on doc_link (doc_id); +alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; + +create index ix_doc_link_link on doc_link (link_id); +alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; + +alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; + +create index ix_document_organisation_id on document (organisation_id); +alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_draft_organisation_id on document_draft (organisation_id); +alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; + +create index ix_document_media_document_id on document_media (document_id); +alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; + +create index ix_document_media_draft_document_id on document_media_draft (document_id); +alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; + +create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); +alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; + +create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); +alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); +alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; + +create index ix_ecache_child_root_id on ecache_child (root_id); +alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; + +alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; + +create index ix_eemb_inner_outer_id on eemb_inner (outer_id); +alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; + +create index ix_einvoice_person_id on einvoice (person_id); +alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; + +create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); +alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; + +create index ix_eopt_one_a_b_id on eopt_one_a (b_id); +alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; + +create index ix_eopt_one_b_c_id on eopt_one_b (c_id); +alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; + +create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); +alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); +alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; + +create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); +alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); +alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; + +create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); +alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; + +alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); +alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; + +create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); +alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; + +create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); +alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); +alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; + +create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); +alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; + +create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); +alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; + +create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); +alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; + +create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); +alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; + +create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); +alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; + +create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); +alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; + +create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); +alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; + +create index ix_td_child_parent_id on td_child (parent_id); +alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; + +create index ix_empl_default_address_id on empl (default_address_id); +alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; + +create index ix_esd_detail_master_id on esd_detail (master_id); +alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; + +create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); +alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); +alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); +alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; + +create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); +alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; + +create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); +alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; + +create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); +alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; + +create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); +alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; + +alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; + +create index ix_iaf_segment_status_id on iaf_segment (status_id); +alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; + +create index ix_imrelated_owner_id on imrelated (owner_id); +alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; + +create index ix_info_contact_company_id on info_contact (company_id); +alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; + +alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; + +create index ix_drel_invoice_booking on drel_invoice (booking); +alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; + +create index ix_item_etype on item (customer,type); +alter table item add constraint fk_item_etype foreign key (customer,type) references "type" (customer,type) on delete restrict on update restrict; + +create index ix_item_eregion on item (customer,region); +alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; + +alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; + +alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; + +alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; + +create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); +alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; + +create index ix_level1_level4_level1 on level1_level4 (level1_id); +alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level4_level4 on level1_level4 (level4_id); +alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level1 on level1_level2 (level1_id); +alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; + +create index ix_level1_level2_level2 on level1_level2 (level2_id); +alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level2 on level2_level3 (level2_id); +alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; + +create index ix_level2_level3_level3 on level2_level3 (level3_id); +alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; + +alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; + +create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); +alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; + +create index ix_looney_tune_id on looney (tune_id); +alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; + +create index ix_mcontact_customer_id on mcontact (customer_id); +alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; + +create index ix_mcontact_message_contact_id on mcontact_message (contact_id); +alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; + +create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); +alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); +alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; + +create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); +alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; + +create index ix_mprinter_current_state_id on mprinter (current_state_id); +alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; + +alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; + +create index ix_mprinter_state_printer_id on mprinter_state (printer_id); +alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; + +create index ix_mprofile_picture_id on mprofile (picture_id); +alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; + +create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); +alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; + +create index ix_mrole_muser_muser on mrole_muser (muser_userid); +alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; + +create index ix_muser_user_type_id on muser (user_type_id); +alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); +alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; + +create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); +alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; + +create index ix_c_message_conversation_id on c_message (conversation_id); +alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_message_user_id on c_message (user_id); +alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; + +alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; + +alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; + +create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); +alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; + +create index ix_mny_b_a_id on mny_b (a_id); +alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; + +create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); +alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_1 on subtopics (topic); +alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_subtopics_mny_topic_2 on subtopics (subtopic); +alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; + +create index ix_mp_role_mp_user_id on mp_role (mp_user_id); +alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); +alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; + +create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); +alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; + +create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); +alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); +alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; + +create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); +alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; + +alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; + +alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; + +create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); +alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; + +create index ix_o_order_kcustomer_id on o_order (kcustomer_id); +alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; + +create index ix_o_order_detail_order_id on o_order_detail (order_id); +alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +create index ix_o_order_detail_product_id on o_order_detail (product_id); +alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; + +create index ix_s_order_items_order_uuid on s_order_items (order_uuid); +alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; + +create index ix_or_order_ship_order_id on or_order_ship (order_id); +alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; + +alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; + +create index ix_orp_detail_master_id on orp_detail (master_id); +alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; + +create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); +alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; + +alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; + +alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; + +alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; + +alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; + +alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; + +alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; + +alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; + +alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; + +create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); +alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; + +alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; + +alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; + +alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; + +alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; + +alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; + +create index ix_pallet_location_zone_sid on pallet_location (zone_sid); +alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; + +alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; + +create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); +alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; + +create index ix_parent_person_some_bean_id on parent_person (some_bean_id); +alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; + +create index ix_parent_person_parent_identifier on parent_person (parent_identifier); +alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; + +create index ix_c_participation_conversation_id on c_participation (conversation_id); +alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; + +create index ix_c_participation_user_id on c_participation (user_id); +alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; + +alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; + +create index ix_person_default_address_oid on person (default_address_oid); +alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; + +create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); +alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; + +create index ix_phones_person_id on phones (person_id); +alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; + +create index ix_e_position_contract_id on e_position (contract_id); +alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_pp on pp_to_ww (pp_id); +alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; + +create index ix_pp_to_ww_wview on pp_to_ww (ww_id); +alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; + +create index ix_question_groupobjectid on question (groupobjectid); +alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; + +create index ix_r_orders_customer on r_orders (company,customername); +alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; + +create index ix_rel_master_detail_id on rel_master (detail_id); +alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; + +create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); +alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; + +create index ix_mt_role_tenant_id on mt_role (tenant_id); +alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; + +create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); +alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; + +alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; + +create index ix_section_article_id on section (article_id); +alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; + +create index ix_self_parent_parent_id on self_parent (parent_id); +alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; + +create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); +alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; + +create index ix_self_ref_example_parent_id on self_ref_example (parent_id); +alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; + +alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; + +create index ix_site_parent_id on site (parent_id); +alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; + +alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; + +create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); +alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; + +create index ix_sub_section_section_id on sub_section (section_id); +alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; + +create index ix_tevent_many_event_id on tevent_many (event_id); +alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; + +alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; + +create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); +alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; + +create index ix_ts_detail_two_master_id on ts_detail_two (master_id); +alter table ts_detail_two add constraint fk_ts_detail_two_master_id foreign key (master_id) references ts_master_two (id) on delete restrict on update restrict; + +create index ix_twheel_owner_plate_no on twheel (owner_plate_no); +alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; + +alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; + +create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); +alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; + +create index ix_trip_address_id on trip (address_id); +alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_type_sub_type_id on "type" (sub_type_id); +alter table "type" add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; + +create index ix_usib_child_parent_id on usib_child (parent_id); +alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; + +alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; + +create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); +alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; + +create index ix_uutwo_master_id on uutwo (master_id); +alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; + +alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; + +create index ix_c_user_group_id on c_user (group_id); +alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; + +create index ix_em_user_role_user_id on em_user_role (user_id); +alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; + +create index ix_em_user_role_role_id on em_user_role (role_id); +alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; + +create index ix_vehicle_lease_id on vehicle (lease_id); +alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; + +create index ix_vehicle_car_ref_id on vehicle (car_ref_id); +alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); +alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); +alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; + +create index ix_vehicle_driver_address_id on vehicle_driver (address_id); +alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; + +create index ix_warehouses_officezoneid on warehouses (officezoneid); +alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; + +create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); +alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; + +create index ix_sa_wheel_tire on sa_wheel (tire); +alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; + +create index ix_sa_wheel_car on sa_wheel (car); +alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; + +create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); +alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; + +create index ix_with_zero_parent_id on with_zero (parent_id); +alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; + +alter table hx_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hx_link set sys_period = tstzrange(when_created, null); +create table hx_link_history(like hx_link); +create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; + +alter table hi_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_link set sys_period = tstzrange(when_created, null); +create table hi_link_history(like hi_link); +create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; + +alter table hi_link_doc add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +create table hi_link_doc_history(like hi_link_doc); +create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; + +alter table hi_tone add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_tone set sys_period = tstzrange(when_created, null); +create table hi_tone_history(like hi_tone); +create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; + +alter table hi_tthree add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_tthree set sys_period = tstzrange(when_created, null); +create table hi_tthree_history(like hi_tthree); +create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; + +alter table hi_ttwo add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hi_ttwo set sys_period = tstzrange(when_created, null); +create table hi_ttwo_history(like hi_ttwo); +create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; + +alter table hsd_setting add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hsd_setting set sys_period = tstzrange(when_created, null); +create table hsd_setting_history(like hsd_setting); +create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; + +alter table hsd_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update hsd_user set sys_period = tstzrange(when_created, null); +create table hsd_user_history(like hsd_user); +create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; + +alter table link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update link set sys_period = tstzrange(when_created, null); +create table link_history(like link); +create view link_with_history as select * from link union all select * from link_history; + +alter table c_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); +update c_user set sys_period = tstzrange(when_created, null); +create table c_user_history(like c_user); +create view c_user_with_history as select * from c_user union all select * from c_user_history; + +create or replace function hx_link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hx_link_history_upd + before update or delete on hx_link + for each row execute procedure hx_link_history_version(); + +create or replace function hi_link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_link_history_upd + before update or delete on hi_link + for each row execute procedure hi_link_history_version(); + +create or replace function hi_link_doc_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_link_doc_history_upd + before update or delete on hi_link_doc + for each row execute procedure hi_link_doc_history_version(); + +create or replace function hi_tone_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_tone_history_upd + before update or delete on hi_tone + for each row execute procedure hi_tone_history_version(); + +create or replace function hi_tthree_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_tthree_history_upd + before update or delete on hi_tthree + for each row execute procedure hi_tthree_history_version(); + +create or replace function hi_ttwo_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hi_ttwo_history_upd + before update or delete on hi_ttwo + for each row execute procedure hi_ttwo_history_version(); + +create or replace function hsd_setting_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hsd_setting_history_upd + before update or delete on hsd_setting + for each row execute procedure hsd_setting_history_version(); + +create or replace function hsd_user_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger hsd_user_history_upd + before update or delete on hsd_user + for each row execute procedure hsd_user_history_version(); + +create or replace function link_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger link_history_upd + before update or delete on link + for each row execute procedure link_history_version(); + +create or replace function c_user_history_version() returns trigger as $$ +declare + lowerTs timestamptz; + upperTs timestamptz; +begin + lowerTs = lower(OLD.sys_period); + upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); + if (TG_OP = 'UPDATE') then + insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + NEW.sys_period = tstzrange(upperTs,null); + return new; + elsif (TG_OP = 'DELETE') then + insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); + return old; + end if; +end; +$$ LANGUAGE plpgsql; + +create trigger c_user_history_upd + before update or delete on c_user + for each row execute procedure c_user_history_version(); + diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql new file mode 100644 index 0000000..2afd91a --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql @@ -0,0 +1,3 @@ +create table m5 (id integer, acol varchar(20), bcol timestamp); + +create index concurrently ix_m5_acol on m5 (acol); \ No newline at end of file diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql new file mode 100644 index 0000000..3f9a84d --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql @@ -0,0 +1,5 @@ +create table m6 (id integer, acol varchar(20), bcol timestamp); + +drop index concurrently ix_m5_acol; +create index concurrently ix_m5_acol2 on m5 (acol,id); +create index concurrently ix_m6_acol2 on m6 (bcol); -- junk \ No newline at end of file diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql new file mode 100644 index 0000000..63ffe8f --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql @@ -0,0 +1,3 @@ + + +create table ${my_table_name} (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql new file mode 100644 index 0000000..7d68a2e --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql @@ -0,0 +1 @@ +create table m1 (id integer, acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql new file mode 100644 index 0000000..63ffe8f --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql @@ -0,0 +1,3 @@ + + +create table ${my_table_name} (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql new file mode 100644 index 0000000..7d68a2e --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql @@ -0,0 +1 @@ +create table m1 (id integer, acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql new file mode 100644 index 0000000..a56969c --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql @@ -0,0 +1,3 @@ + + +create table ${other_table_name} (acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql new file mode 100644 index 0000000..b2ccc21 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql @@ -0,0 +1,3 @@ + + +create table m4 (acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql new file mode 100644 index 0000000..c4aaa00 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql @@ -0,0 +1,12 @@ +create table m1 +( + id integer, + acol varchar(20) +); + +create table m2 +( + id integer, + acol varchar(20), + bcol timestamp +); diff --git a/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql new file mode 100644 index 0000000..0b975c7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql @@ -0,0 +1,9 @@ +create table m3 +( + id integer, + acol varchar(20), + bcol timestamp +); + +insert into m3 (id, acol) +VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql b/ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql new file mode 100644 index 0000000..0c07143 --- /dev/null +++ b/ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql @@ -0,0 +1,114 @@ +if not exists (select name from sys.types where name = 'ebean_bigint_tvp') +create type ebean_bigint_tvp as table (c1 bigint) +GO +if not exists (select name from sys.types where name = 'ebean_float_tvp') +create type ebean_float_tvp as table (c1 float) +GO +if not exists (select name from sys.types where name = 'ebean_bit_tvp') +create type ebean_bit_tvp as table (c1 bit) +GO +if not exists (select name from sys.types where name = 'ebean_date_tvp') +create type ebean_date_tvp as table (c1 date) +GO +if not exists (select name from sys.types where name = 'ebean_time_tvp') +create type ebean_time_tvp as table (c1 time) +GO +if not exists (select name from sys.types where name = 'ebean_uniqueidentifier_tvp') +create type ebean_uniqueidentifier_tvp as table (c1 uniqueidentifier) +GO +if not exists (select name from sys.types where name = 'ebean_nvarchar_tvp') +create type ebean_nvarchar_tvp as table (c1 nvarchar(max)) +GO + +-- +-- PROCEDURE: usp_ebean_drop_indices TABLE, COLUMN +-- deletes all indices referring to TABLE.COLUMN +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_indices @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @sql nvarchar(1000) +declare @indexName nvarchar(255) +BEGIN + DECLARE index_cursor CURSOR FOR SELECT i.name from sys.indexes i + join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id + join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id + where i.object_id = OBJECT_ID(@tableName) AND c.name = @columnName; + OPEN index_cursor + FETCH NEXT FROM index_cursor INTO @indexName + WHILE @@FETCH_STATUS = 0 + BEGIN + set @sql = 'drop index ' + @indexName + ' on ' + @tableName; + EXECUTE(@sql); + + FETCH NEXT FROM index_cursor INTO @indexName + END; + CLOSE index_cursor; + DEALLOCATE index_cursor; +END +GO + +-- +-- PROCEDURE: usp_ebean_drop_default_constraint TABLE, COLUMN +-- deletes the default constraint, which has a random name +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_default_constraint @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @tmp nvarchar(1000) +BEGIN + select @tmp = t1.name from sys.default_constraints t1 + join sys.columns t2 on t1.object_id = t2.default_object_id + where t1.parent_object_id = OBJECT_ID(@tableName) and t2.name = @columnName; + + if @tmp is not null EXEC('alter table ' + @tableName +' drop constraint ' + @tmp); +END +GO + +-- +-- PROCEDURE: usp_ebean_drop_constraints TABLE, COLUMN +-- deletes constraints and foreign keys refering to TABLE.COLUMN +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_constraints @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @sql nvarchar(1000) +declare @constraintName nvarchar(255) +BEGIN + DECLARE name_cursor CURSOR FOR + SELECT cc.name from sys.check_constraints cc + join sys.columns c on c.object_id = cc.parent_object_id and c.column_id = cc.parent_column_id + where parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName + UNION SELECT fk.name from sys.foreign_keys fk + join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id + and fkc.parent_object_id = fk.parent_object_id + join sys.columns c on c.object_id = fkc.parent_object_id and c.column_id = fkc.parent_column_id + where fkc.parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName; + + OPEN name_cursor + FETCH NEXT FROM name_cursor INTO @constraintName + WHILE @@FETCH_STATUS = 0 + BEGIN + set @sql = 'alter table ' + @tableName + ' drop constraint ' + @constraintName; + EXECUTE(@sql); + + FETCH NEXT FROM name_cursor INTO @constraintName + END; + CLOSE name_cursor; + DEALLOCATE name_cursor; +END +GO + +-- +-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN +-- deletes the column annd ensures that all indices and constraints are dropped first +-- +CREATE OR ALTER PROCEDURE usp_ebean_drop_column @tableName nvarchar(255), @columnName nvarchar(255) +AS SET NOCOUNT ON +declare @sql nvarchar(1000) +BEGIN + EXEC usp_ebean_drop_indices @tableName, @columnName; + EXEC usp_ebean_drop_default_constraint @tableName, @columnName; + EXEC usp_ebean_drop_constraints @tableName, @columnName; + + set @sql = 'alter table ' + @tableName + ' drop column ' + @columnName; + EXECUTE(@sql); +END +GO diff --git a/ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql b/ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations b/ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations new file mode 100644 index 0000000..63d7678 --- /dev/null +++ b/ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations @@ -0,0 +1 @@ +567, 1.1__initial.sql diff --git a/ebean-migration-it/src/test/resources/index0/1.0__initial.sql b/ebean-migration-it/src/test/resources/index0/1.0__initial.sql new file mode 100644 index 0000000..1e2a409 --- /dev/null +++ b/ebean-migration-it/src/test/resources/index0/1.0__initial.sql @@ -0,0 +1,232 @@ +-- Migrationscripts for ebean unittest +-- apply changes +create table migtest_ckey_assoc ( + id integer generated by default as identity not null, + assoc_one varchar(255), + constraint pk_migtest_ckey_assoc primary key (id) +); + +create table migtest_ckey_detail ( + id integer generated by default as identity not null, + something varchar(255), + constraint pk_migtest_ckey_detail primary key (id) +); + +create table migtest_ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + version integer not null, + constraint pk_migtest_ckey_parent primary key (one_key,two_key) +); + +create table migtest_fk_cascade ( + id bigint generated by default as identity not null, + one_id bigint, + constraint pk_migtest_fk_cascade primary key (id) +); + +create table migtest_fk_cascade_one ( + id bigint generated by default as identity not null, + constraint pk_migtest_fk_cascade_one primary key (id) +); + +create table migtest_fk_none ( + id bigint generated by default as identity not null, + one_id bigint, + constraint pk_migtest_fk_none primary key (id) +); + +create table migtest_fk_none_via_join ( + id bigint generated by default as identity not null, + one_id bigint, + constraint pk_migtest_fk_none_via_join primary key (id) +); + +create table migtest_fk_one ( + id bigint generated by default as identity not null, + constraint pk_migtest_fk_one primary key (id) +); + +create table migtest_fk_set_null ( + id bigint generated by default as identity not null, + one_id bigint, + constraint pk_migtest_fk_set_null primary key (id) +); + +create table migtest_e_basic ( + id integer generated by default as identity not null, + status varchar(1), + status2 varchar(1) default 'N' not null, + name varchar(127), + description varchar(127), + some_date timestamp, + old_boolean boolean default false not null, + old_boolean2 boolean, + eref_id integer, + indextest1 varchar(127), + indextest2 varchar(127), + indextest3 varchar(127), + indextest4 varchar(127), + indextest5 varchar(127), + indextest6 varchar(127), + user_id integer not null, + constraint ck_migtest_e_basic_status check ( status in ('N','A','I')), + constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')), + constraint uq_migtest_e_basic_indextest2 unique (indextest2), + constraint uq_migtest_e_basic_indextest6 unique (indextest6), + constraint pk_migtest_e_basic primary key (id) +); + +create table migtest_e_enum ( + id integer generated by default as identity not null, + test_status varchar(1), + constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')), + constraint pk_migtest_e_enum primary key (id) +); + +create table migtest_e_history ( + id integer generated by default as identity not null, + test_string varchar(255), + constraint pk_migtest_e_history primary key (id) +); + +create table migtest_e_history2 ( + id integer generated by default as identity not null, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + constraint pk_migtest_e_history2 primary key (id) +); + +create table migtest_e_history3 ( + id integer generated by default as identity not null, + test_string varchar(255), + constraint pk_migtest_e_history3 primary key (id) +); + +create table migtest_e_history4 ( + id integer generated by default as identity not null, + test_number integer, + constraint pk_migtest_e_history4 primary key (id) +); + +create table migtest_e_history5 ( + id integer generated by default as identity not null, + test_number integer, + constraint pk_migtest_e_history5 primary key (id) +); + +create table migtest_e_history6 ( + id integer generated by default as identity not null, + test_number1 integer, + test_number2 integer not null, + constraint pk_migtest_e_history6 primary key (id) +); + +create table migtest_e_ref ( + id integer generated by default as identity not null, + name varchar(127) not null, + constraint uq_migtest_e_ref_name unique (name), + constraint pk_migtest_e_ref primary key (id) +); + +create table migtest_e_softdelete ( + id integer generated by default as identity not null, + test_string varchar(255), + constraint pk_migtest_e_softdelete primary key (id) +); + +create table migtest_mtm_c ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_migtest_mtm_c primary key (id) +); + +create table migtest_mtm_m ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_migtest_mtm_m primary key (id) +); + +create table migtest_oto_child ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_migtest_oto_child primary key (id) +); + +create table migtest_oto_master ( + id bigint generated by default as identity not null, + name varchar(255), + constraint pk_migtest_oto_master primary key (id) +); + +create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); +create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); +create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; + +create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; + +create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); +alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; + +alter table migtest_e_history2 add column sys_period_start timestamp default now(); +alter table migtest_e_history2 add column sys_period_end timestamp; +create table migtest_e_history2_history( + id integer, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + sys_period_start timestamp, + sys_period_end timestamp +); +create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; + +alter table migtest_e_history3 add column sys_period_start timestamp default now(); +alter table migtest_e_history3 add column sys_period_end timestamp; +create table migtest_e_history3_history( + id integer, + test_string varchar(255), + sys_period_start timestamp, + sys_period_end timestamp +); +create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; + +alter table migtest_e_history4 add column sys_period_start timestamp default now(); +alter table migtest_e_history4 add column sys_period_end timestamp; +create table migtest_e_history4_history( + id integer, + test_number integer, + sys_period_start timestamp, + sys_period_end timestamp +); +create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; + +alter table migtest_e_history5 add column sys_period_start timestamp default now(); +alter table migtest_e_history5 add column sys_period_end timestamp; +create table migtest_e_history5_history( + id integer, + test_number integer, + sys_period_start timestamp, + sys_period_end timestamp +); +create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; + +alter table migtest_e_history6 add column sys_period_start timestamp default now(); +alter table migtest_e_history6 add column sys_period_end timestamp; +create table migtest_e_history6_history( + id integer, + test_number1 integer, + test_number2 integer, + sys_period_start timestamp, + sys_period_end timestamp +); +create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history; + +create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.1.sql b/ebean-migration-it/src/test/resources/index0/1.1.sql new file mode 100644 index 0000000..b51d15d --- /dev/null +++ b/ebean-migration-it/src/test/resources/index0/1.1.sql @@ -0,0 +1,152 @@ +-- Migrationscripts for ebean unittest +-- drop dependencies +drop view if exists migtest_e_history2_with_history; +drop view if exists migtest_e_history3_with_history; +drop view if exists migtest_e_history4_with_history; +drop view if exists migtest_e_history5_with_history; + +-- apply changes +create table migtest_e_user ( + id integer 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_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict; +alter table migtest_ckey_parent add column assoc_id integer; + +alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict; +alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict; +alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict; +alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict; + +update migtest_e_basic set status = 'A' where status is null; +alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; +alter table migtest_e_basic alter column status set default 'A'; +alter table migtest_e_basic alter column status set not null; +alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')); +alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2; +alter table migtest_e_basic alter column status2 varchar(127); +alter table migtest_e_basic alter column status2 drop default; +alter table migtest_e_basic alter column status2 set null; + +-- rename all collisions; +alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description); + +insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; +alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict; +alter table migtest_e_basic alter column user_id set null; +alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null; +alter table migtest_e_basic add column new_boolean_field boolean default true not null; +update migtest_e_basic set new_boolean_field = old_boolean; + +alter table migtest_e_basic add column new_boolean_field2 boolean default true not null; +alter table migtest_e_basic add column progress integer default 0 not null; +alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)); +alter table migtest_e_basic add column new_integer integer default 42 not null; + +alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; +alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; +alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1); +alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name); +alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4); +alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5); +alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +comment on column migtest_e_history.test_string is 'Column altered to long now'; +alter table migtest_e_history alter column test_string bigint; +comment on table migtest_e_history is 'We have history now'; + +-- NOTE: table has @History - special migration may be necessary +update migtest_e_history2 set test_string = 'unknown' where test_string is null; +alter table migtest_e_history2 alter column test_string set default 'unknown'; +alter table migtest_e_history2 alter column test_string set not null; +alter table migtest_e_history2 add column test_string2 varchar(255); +alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null; +alter table migtest_e_history2 add column new_column varchar(20); +alter table migtest_e_history2_history add column test_string2 varchar(255); +alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown'; +alter table migtest_e_history2_history add column new_column varchar(20); + +alter table migtest_e_history4 alter column test_number bigint; +alter table migtest_e_history4_history alter column test_number bigint; +alter table migtest_e_history5 add column test_boolean boolean default false not null; +alter table migtest_e_history5_history add column test_boolean boolean default false; + + +-- 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 set null; +alter table migtest_e_softdelete add column deleted boolean default false not null; + +alter table migtest_oto_child add column master_id bigint; + +create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3); +create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); +drop index if exists ix_migtest_e_basic_indextest1; +drop index if exists ix_migtest_e_basic_indextest5; +create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); +alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; + +create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id); +alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + +create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id); +alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + +create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); +alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; + +create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); +alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; + +alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict; + +alter table migtest_e_history add column sys_period_start timestamp default now(); +alter table migtest_e_history add column sys_period_end timestamp; +create table migtest_e_history_history( + id integer, + test_string bigint, + sys_period_start timestamp, + sys_period_end timestamp +); +create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history; + +create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; + +create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; + +create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; + +create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; + +create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [add test_string2, add test_string3, add new_column] +drop trigger migtest_e_history2_history_upd; +create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [exclude test_string] +drop trigger migtest_e_history3_history_upd; +create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [alter test_number] +drop trigger migtest_e_history4_history_upd; +create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [add test_boolean] +drop trigger migtest_e_history5_history_upd; +create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql b/ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql new file mode 100644 index 0000000..dea5dde --- /dev/null +++ b/ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql @@ -0,0 +1,24 @@ +-- Migrationscripts for ebean unittest +-- drop dependencies +drop view if exists migtest_e_history2_with_history; + +-- apply changes +alter table migtest_e_basic drop column old_boolean; + +alter table migtest_e_basic drop column old_boolean2; + +alter table migtest_e_basic drop column eref_id; + +alter table migtest_e_history2 drop column obsolete_string1; +alter table migtest_e_history2_history drop column obsolete_string1; + +alter table migtest_e_history2 drop column obsolete_string2; +alter table migtest_e_history2_history drop column obsolete_string2; + +drop table if exists migtest_e_ref; +drop sequence if exists migtest_e_ref_seq; +create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; + +-- changes: [drop obsolete_string1, drop obsolete_string2] +drop trigger migtest_e_history2_history_upd; +create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.3.sql b/ebean-migration-it/src/test/resources/index0/1.3.sql new file mode 100644 index 0000000..a1d6cca --- /dev/null +++ b/ebean-migration-it/src/test/resources/index0/1.3.sql @@ -0,0 +1,90 @@ +-- Migrationscripts for ebean unittest +-- drop dependencies +drop view if exists migtest_e_history2_with_history; +drop view if exists migtest_e_history3_with_history; +drop view if exists migtest_e_history4_with_history; + +-- apply changes +create table migtest_e_ref ( + id integer generated by default as identity not null, + name varchar(127) not null, + constraint uq_migtest_e_ref_name unique (name), + constraint pk_migtest_e_ref primary key (id) +); + +alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent; +alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; +alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id; +alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id; +alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; +alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; +alter table migtest_e_basic alter column status drop default; +alter table migtest_e_basic alter column status set null; +alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I')); + +update migtest_e_basic set status2 = 'N' where status2 is null; +alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2; +alter table migtest_e_basic alter column status2 varchar(1); +alter table migtest_e_basic alter column status2 set default 'N'; +alter table migtest_e_basic alter column status2 set not null; +alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')); +alter table migtest_e_basic drop constraint uq_migtest_e_basic_description; + +update migtest_e_basic set user_id = 23 where user_id is null; +alter table migtest_e_basic drop constraint if exists fk_migtest_e_basic_user_id; +alter table migtest_e_basic alter column user_id set default 23; +alter table migtest_e_basic alter column user_id set not null; +alter table migtest_e_basic add column old_boolean boolean default false not null; +alter table migtest_e_basic add column old_boolean2 boolean; +alter table migtest_e_basic add column eref_id integer; + +alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1; +alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; +alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; +alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; +alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2); +alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6); +alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')); +comment on column migtest_e_history.test_string is ''; +comment on table migtest_e_history is ''; +alter table migtest_e_history2 alter column test_string drop default; +alter table migtest_e_history2 alter column test_string set null; +alter table migtest_e_history2 add column obsolete_string1 varchar(255); +alter table migtest_e_history2 add column obsolete_string2 varchar(255); +alter table migtest_e_history2_history add column obsolete_string1 varchar(255); +alter table migtest_e_history2_history add column obsolete_string2 varchar(255); + +alter table migtest_e_history4 alter column test_number integer; +alter table migtest_e_history4_history alter column test_number integer; +alter table migtest_e_history6 alter column test_number1 drop default; +alter table migtest_e_history6 alter column test_number1 set null; + +-- NOTE: table has @History - special migration may be necessary +update migtest_e_history6 set test_number2 = 7 where test_number2 is null; +alter table migtest_e_history6 alter column test_number2 set default 7; +alter table migtest_e_history6 alter column test_number2 set not null; +create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); +create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); +drop index if exists ix_migtest_e_basic_indextest3; +drop index if exists ix_migtest_e_basic_indextest6; +create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); +alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; + +create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; + +create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; + +create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; + +-- changes: [add obsolete_string1, add obsolete_string2] +drop trigger migtest_e_history2_history_upd; +create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [include test_string] +drop trigger migtest_e_history3_history_upd; +create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [alter test_number] +drop trigger migtest_e_history4_history_upd; +create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql b/ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql new file mode 100644 index 0000000..1776f53 --- /dev/null +++ b/ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql @@ -0,0 +1,58 @@ +-- Migrationscripts for ebean unittest +-- drop dependencies +drop trigger migtest_e_history_history_upd; +drop view migtest_e_history_with_history; +alter table migtest_e_history drop column sys_period_start; +alter table migtest_e_history drop column sys_period_end; +drop table migtest_e_history_history; + +drop view if exists migtest_e_history2_with_history; +drop view if exists migtest_e_history5_with_history; + +-- apply changes +alter table migtest_ckey_detail drop column one_key; + +alter table migtest_ckey_detail drop column two_key; + +alter table migtest_ckey_parent drop column assoc_id; + +alter table migtest_e_basic drop column new_string_field; + +alter table migtest_e_basic drop column new_boolean_field; + +alter table migtest_e_basic drop column new_boolean_field2; + +alter table migtest_e_basic drop column progress; + +alter table migtest_e_basic drop column new_integer; + +alter table migtest_e_history2 drop column test_string2; +alter table migtest_e_history2_history drop column test_string2; + +alter table migtest_e_history2 drop column test_string3; +alter table migtest_e_history2_history drop column test_string3; + +alter table migtest_e_history2 drop column new_column; +alter table migtest_e_history2_history drop column new_column; + +alter table migtest_e_history5 drop column test_boolean; +alter table migtest_e_history5_history drop column test_boolean; + +alter table migtest_e_softdelete drop column deleted; + +alter table migtest_oto_child drop column master_id; + +drop table if exists migtest_e_user; +drop sequence if exists migtest_e_user_seq; +drop table if exists migtest_mtm_c_migtest_mtm_m; +drop table if exists migtest_mtm_m_migtest_mtm_c; +create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; + +create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; + +-- changes: [drop test_string2, drop test_string3, drop new_column] +drop trigger migtest_e_history2_history_upd; +create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +-- changes: [drop test_boolean] +drop trigger migtest_e_history5_history_upd; +create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/idx_h2.migrations b/ebean-migration-it/src/test/resources/index0/idx_h2.migrations new file mode 100644 index 0000000..fb21ce8 --- /dev/null +++ b/ebean-migration-it/src/test/resources/index0/idx_h2.migrations @@ -0,0 +1,6 @@ +-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 + diff --git a/ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql new file mode 100644 index 0000000..fd5f737 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql @@ -0,0 +1,6 @@ +-- apply changes +create table ${my_table_name} ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_${my_table_name} primary key (id) +); diff --git a/ebean-migration-it/src/test/resources/indexB_0/1.1.sql b/ebean-migration-it/src/test/resources/indexB_0/1.1.sql new file mode 100644 index 0000000..38e24be --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_0/1.1.sql @@ -0,0 +1 @@ +insert into ${my_table_name} (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexB_0/1.2.sql b/ebean-migration-it/src/test/resources/indexB_0/1.2.sql new file mode 100644 index 0000000..b3fa4db --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_0/1.2.sql @@ -0,0 +1 @@ +create table foo (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql new file mode 100644 index 0000000..fd5f737 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql @@ -0,0 +1,6 @@ +-- apply changes +create table ${my_table_name} ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_${my_table_name} primary key (id) +); diff --git a/ebean-migration-it/src/test/resources/indexB_1/1.1.sql b/ebean-migration-it/src/test/resources/indexB_1/1.1.sql new file mode 100644 index 0000000..38e24be --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_1/1.1.sql @@ -0,0 +1 @@ +insert into ${my_table_name} (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexB_1/1.2.sql b/ebean-migration-it/src/test/resources/indexB_1/1.2.sql new file mode 100644 index 0000000..b3fa4db --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_1/1.2.sql @@ -0,0 +1 @@ +create table foo (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations b/ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations new file mode 100644 index 0000000..a639c29 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations @@ -0,0 +1,4 @@ +845768926, 1.0__initial.sql +19858255, 1.1.sql +513154593, 1.2.sql + diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql new file mode 100644 index 0000000..fd5f737 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql @@ -0,0 +1,6 @@ +-- apply changes +create table ${my_table_name} ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_${my_table_name} primary key (id) +); diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.1.sql b/ebean-migration-it/src/test/resources/indexB_2/1.1.sql new file mode 100644 index 0000000..38e24be --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_2/1.1.sql @@ -0,0 +1 @@ +insert into ${my_table_name} (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.2.sql b/ebean-migration-it/src/test/resources/indexB_2/1.2.sql new file mode 100644 index 0000000..b3fa4db --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_2/1.2.sql @@ -0,0 +1 @@ +create table foo (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.3.sql b/ebean-migration-it/src/test/resources/indexB_2/1.3.sql new file mode 100644 index 0000000..1095ac9 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_2/1.3.sql @@ -0,0 +1 @@ +create table bazz (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations b/ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations new file mode 100644 index 0000000..aa0a5d5 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations @@ -0,0 +1,5 @@ +845768926, 1.0__initial.sql +19858255, 1.1.sql +513154593, 1.2.sql +113154590, 1.3.sql + diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql new file mode 100644 index 0000000..8f18f2a --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql @@ -0,0 +1,6 @@ +-- apply changes +create table m1 ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_m1 primary key (id) +); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql new file mode 100644 index 0000000..8583711 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql @@ -0,0 +1 @@ +insert into m1 (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql new file mode 100644 index 0000000..eb186f5 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql @@ -0,0 +1 @@ +create table m2 (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations b/ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations new file mode 100644 index 0000000..6920195 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations @@ -0,0 +1,4 @@ +1, 1.0__initial.sql +2, 1.1.sql +3, 1.2.sql + diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql new file mode 100644 index 0000000..8f18f2a --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql @@ -0,0 +1,6 @@ +-- apply changes +create table m1 ( + id integer generated by default as identity not null, + name varchar(255), + constraint pk_m1 primary key (id) +); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql new file mode 100644 index 0000000..8583711 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql @@ -0,0 +1 @@ +insert into m1 (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql new file mode 100644 index 0000000..eb186f5 --- /dev/null +++ b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql @@ -0,0 +1 @@ +create table m2 (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/logback-test.xml b/ebean-migration-it/src/test/resources/logback-test.xml new file mode 100644 index 0000000..a227835 --- /dev/null +++ b/ebean-migration-it/src/test/resources/logback-test.xml @@ -0,0 +1,17 @@ + + + + TRACE + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql b/ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql new file mode 100644 index 0000000..5f67d2b --- /dev/null +++ b/ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql @@ -0,0 +1,6 @@ +-- Migrationscripts for ebean unittest +-- apply changes +create table junk ( + id integer generated by default as identity not null, + assoc_one varchar(255) +); diff --git a/ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql b/ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql new file mode 100644 index 0000000..46c181e --- /dev/null +++ b/ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql @@ -0,0 +1,4 @@ +create table junk ( + id integer generated by default as identity not null, + assoc_one varchar(255) +); diff --git a/ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql b/ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql new file mode 100644 index 0000000..77ac746 --- /dev/null +++ b/ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql @@ -0,0 +1,4 @@ +create table junk2 ( + id integer generated by default as identity not null, + assoc_one varchar(255) +); diff --git a/ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql b/ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql new file mode 100644 index 0000000..e551f49 --- /dev/null +++ b/ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql @@ -0,0 +1 @@ +This is just junk - would not execute diff --git a/ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql b/ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql b/ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql new file mode 100644 index 0000000..3518305 --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql @@ -0,0 +1,5 @@ +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql b/ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql new file mode 100644 index 0000000..bf05736 --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql @@ -0,0 +1 @@ +i am corrupt; \ No newline at end of file diff --git a/ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql b/ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql new file mode 100644 index 0000000..41f07d7 --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql @@ -0,0 +1,3 @@ +create table m1 (id integer, acol varchar(20)); + +create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql new file mode 100644 index 0000000..3518305 --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql @@ -0,0 +1,5 @@ +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql b/ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql new file mode 100644 index 0000000..6a7c4df --- /dev/null +++ b/ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql @@ -0,0 +1 @@ +create or replace view m2_vw as select id, acol from m2; diff --git a/pom.xml b/pom.xml index f561816..2526367 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ ebean-migration-auto ebean-migration + ebean-migration-it From a66a43484aa463e429d4b917f5577e6d14b55cda Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Tue, 2 Jan 2024 11:48:47 +0100 Subject: [PATCH 11/18] add it test --- ebean-migration-it/pom.xml | 195 +- .../src/main/java/module-info.java | 4 - .../java/org/migration/model/DemoModel.java | 15 + .../src/main/java/org/migration/model/M3.java | 30 + .../resource-config.json | 10 - .../src/main/resources/ebean.mf | 3 + .../default-create-table.sql | 13 - .../sqlserver-create-table.sql | 13 - .../src/test/java/dbmig/V1_2_1__test.java | 29 - .../dbplatform/h2/H2HistoryTrigger.java | 113 - .../io/ebean/migration/AutoRunnerTest.java | 49 - .../ebean/migration/MigrationConfigTest.java | 152 - .../ebean/migration/MigrationRunnerTest.java | 334 -- .../MigrationRunner_FastCheckTest.java | 100 - .../MigrationRunner_MultiPlatformTest.java | 58 - .../MigrationRunner_PatchResetTest.java | 36 - .../migration/MigrationRunner_emptyTest.java | 29 - .../MigrationRunner_platform_Test.java | 281 - .../ebean/migration/MigrationVersionTest.java | 227 - .../migration/ServiceLoaderMigration.java | 24 - .../migration/it/EbeanMigrationTest.java | 51 + .../io/ebean/migration/it/V1_2_1__test.java | 55 + .../ebean/migration/runner/ChecksumTest.java | 18 - .../migration/runner/DbNameUtilTest.java | 62 - .../runner/MigrationEarlyModeTest.java | 86 - .../runner/MigrationMetaRowTest.java | 30 - .../runner/MigrationPlatformTest.java | 28 - .../migration/runner/MigrationSchemaTest.java | 30 - .../migration/runner/MigrationTable1Test.java | 159 - .../migration/runner/MigrationTable2Test.java | 94 - .../runner/MigrationTableAsyncTest.java | 237 - .../MigrationTableCreateTableRaceTest.java | 77 - .../runner/MigrationTableTestDb2.java | 56 - .../services/io.ebean.migration.JdbcMigration | 1 - .../resources/dbmig-roach/1.1__initial.sql | 3 - .../resources/dbmig-roach/1.2__add_m3.sql | 5 - .../test/resources/dbmig-roach/R__m2_view.sql | 2 - .../src/test/resources/dbmig2/1.3__m4.sql | 1 - .../src/test/resources/dbmig3/I__hello.sql | 1 - .../src/test/resources/dbmig3/R__m2_view.sql | 1 - .../test/resources/dbmig4/1.1__initial.sql | 5 - .../src/test/resources/dbmig4/1.2__add_m3.sql | 6 - .../src/test/resources/dbmig4/1.3__m4.sql | 1 - .../src/test/resources/dbmig4/R__m2_view.sql | 2 - .../resources/dbmig5_base/1.1__initial.sql | 5 - .../resources/dbmig5_base/1.2__add_m3.sql | 6 - .../test/resources/dbmig5_base/1.3__m4.sql | 1 - .../test/resources/dbmig5_base/I__some_i.sql | 1 - .../test/resources/dbmig5_base/R__some_r.sql | 1 - .../test/resources/dbmig5_init/1.3__m4.sql | 9 - .../test/resources/dbmig6_init/1.0__m4.sql | 9 - .../resources/dbmig_autorun/1.1__initial.sql | 3 - .../resources/dbmig_basic/1.1__initial.sql | 12 - .../resources/dbmig_basic/1.2__add_m3.sql | 9 - .../resources/dbmig_error/1.1__initial.sql | 1 - .../resources/dbmig_error/1.2__insert.sql | 1 - .../test/resources/dbmig_error/1.3__error.sql | 1 - .../dbmig_mysql/mysql-create-all.sql | 4730 ---------------- .../resources/dbmig_mysql/mysql-drop-all.sql | 1730 ------ .../resources/dbmig_nuodb/1.1__initial.sql | 45 - .../resources/dbmig_oracle/1.1__initial.sql | 3 - .../resources/dbmig_oracle/1.2__add_m3.sql | 5 - .../test/resources/dbmig_oracle/I__hello.sql | 1 - .../resources/dbmig_oracle/R__m2_view.sql | 1 - .../src/test/resources/dbmig_postgres/ex1.sql | 14 - .../dbmig_postgres/pg-create-all.sql | 4745 ----------------- .../dbmig_postgres_concurrently0/2.1__m5.sql | 3 - .../dbmig_postgres_concurrently1/2.2__m6.sql | 5 - .../dbmig_postgres_early/1.0__m0.sql | 3 - .../dbmig_postgres_early/1.1__m1.sql | 1 - .../dbmig_postgres_early1/1.0__m0.sql | 3 - .../dbmig_postgres_early1/1.1__m1.sql | 1 - .../dbmig_postgres_early1/2.0__m2.sql | 3 - .../dbmig_postgres_early1/2.1__m3.sql | 3 - .../dbmig_sqlserver/1.1__initial.sql | 12 - .../resources/dbmig_sqlserver/1.2__add_m3.sql | 9 - .../dbmig_sqlserver/I__create_procs.sql | 114 - .../src/test/resources/ebean.properties | 12 + .../test/resources/fastcheck/1.1__initial.sql | 3 - .../resources/fastcheck/idx_h2.migrations | 1 - .../test/resources/index0/1.0__initial.sql | 232 - .../src/test/resources/index0/1.1.sql | 152 - .../resources/index0/1.2__dropsFor_1.1.sql | 24 - .../src/test/resources/index0/1.3.sql | 90 - .../resources/index0/1.4__dropsFor_1.3.sql | 58 - .../test/resources/index0/idx_h2.migrations | 6 - .../test/resources/indexB_0/1.0__initial.sql | 6 - .../src/test/resources/indexB_0/1.1.sql | 1 - .../src/test/resources/indexB_0/1.2.sql | 1 - .../test/resources/indexB_1/1.0__initial.sql | 6 - .../src/test/resources/indexB_1/1.1.sql | 1 - .../src/test/resources/indexB_1/1.2.sql | 1 - .../test/resources/indexB_1/idx_h2.migrations | 4 - .../test/resources/indexB_2/1.0__initial.sql | 6 - .../src/test/resources/indexB_2/1.1.sql | 1 - .../src/test/resources/indexB_2/1.2.sql | 1 - .../src/test/resources/indexB_2/1.3.sql | 1 - .../test/resources/indexB_2/idx_h2.migrations | 5 - .../indexPatchReset_0/1.0__initial.sql | 6 - .../test/resources/indexPatchReset_0/1.1.sql | 1 - .../test/resources/indexPatchReset_0/1.2.sql | 1 - .../indexPatchReset_0/idx_h2.migrations | 4 - .../indexPatchReset_1/1.0__initial.sql | 6 - .../test/resources/indexPatchReset_1/1.1.sql | 1 - .../test/resources/indexPatchReset_1/1.2.sql | 1 - .../multiplatform/h2/1.0__multi-initial.sql | 6 - .../multiplatform/mybase/1.0__one.sql | 4 - .../multiplatform/mybase/2.0__two.sql | 4 - .../noth2/2.0__notValidForH2.sql | 1 - .../resources/tabletest1/1.1__initial.sql | 3 - .../resources/tabletest2-err/1.1__initial.sql | 3 - .../resources/tabletest2-err/1.2__add_m3.sql | 5 - .../resources/tabletest2-err/R__m2_view.sql | 1 - .../resources/tabletest2/1.1__initial.sql | 3 - .../test/resources/tabletest2/1.2__add_m3.sql | 5 - .../test/resources/tabletest2/R__m2_view.sql | 1 - .../io/ebean/migration/MigrationRunner.java | 2 +- 117 files changed, 275 insertions(+), 14611 deletions(-) delete mode 100644 ebean-migration-it/src/main/java/module-info.java create mode 100644 ebean-migration-it/src/main/java/org/migration/model/DemoModel.java create mode 100644 ebean-migration-it/src/main/java/org/migration/model/M3.java delete mode 100644 ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json create mode 100644 ebean-migration-it/src/main/resources/ebean.mf delete mode 100644 ebean-migration-it/src/main/resources/migration-support/default-create-table.sql delete mode 100644 ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql delete mode 100644 ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java create mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java delete mode 100644 ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java delete mode 100644 ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration delete mode 100644 ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig3/I__hello.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql create mode 100644 ebean-migration-it/src/test/resources/ebean.properties delete mode 100644 ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations delete mode 100644 ebean-migration-it/src/test/resources/index0/1.0__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/index0/1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/index0/1.3.sql delete mode 100644 ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql delete mode 100644 ebean-migration-it/src/test/resources/index0/idx_h2.migrations delete mode 100644 ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_0/1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_0/1.2.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_1/1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_1/1.2.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations delete mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.2.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_2/1.3.sql delete mode 100644 ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql delete mode 100644 ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql delete mode 100644 ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql delete mode 100644 ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql delete mode 100644 ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql delete mode 100644 ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql delete mode 100644 ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql diff --git a/ebean-migration-it/pom.xml b/ebean-migration-it/pom.xml index 6492dfb..59a8592 100644 --- a/ebean-migration-it/pom.xml +++ b/ebean-migration-it/pom.xml @@ -1,11 +1,12 @@ - + 4.0.0 org.avaje java11-oss 3.12 - + io.ebean @@ -23,89 +24,100 @@ - - io.ebean - ebean-migration - 13.11.2-SNAPSHOT - - - - - io.avaje - avaje-slf4j-jpl - 1.1 - test - - - - com.h2database - h2 - 2.2.220 - test - - - - com.microsoft.sqlserver - mssql-jdbc - 9.4.1.jre8 - test - - - - mysql - mysql-connector-java - 8.0.28 - test - - - - org.postgresql - postgresql - 42.4.3 - test - - - - com.nuodb.jdbc - nuodb-jdbc - 22.0.0 - test - - - com.ibm.db2 - jcc - 11.5.6.0 - test - - org.mariadb.jdbc - mariadb-java-client - 3.0.6 - test + io.ebean + ebean + 13.25.0-jakarta - com.oracle.database.jdbc - - ojdbc8 - 19.12.0.0 - test + io.ebean + ebean-migration + 13.11.2-SNAPSHOT - - - - - - - + <!– test dependencies –> + + io.avaje + avaje-slf4j-jpl + 1.1 + test + + + + + + com.microsoft.sqlserver + mssql-jdbc + 9.4.1.jre8 + test + + + + mysql + mysql-connector-java + 8.0.28 + test + + + + org.postgresql + postgresql + 42.4.3 + test + + + + com.nuodb.jdbc + nuodb-jdbc + 22.0.0 + test + + + + com.ibm.db2 + jcc + 11.5.6.0 + test + + + + org.mariadb.jdbc + mariadb-java-client + 3.0.6 + test + + + + com.oracle.database.jdbc + <!– Note: Using ojdbc10 here will affect loading other drivers on jdk8, + because the driverManager will stop on first load error and stops loading + other drivers –> + ojdbc8 + 19.12.0.0 + test + + + <!– + mvn install:install-file -Dfile=/some/path/to/ojdbc7.jar -DgroupId=oracle \ + -DartifactId=oracle-jdbc -Dversion=7.0 -Dpackaging=jar + –> + <!– –> + <!– oracle–> + <!– oracle-jdbc–> + <!– 8.0–> + <!– test–> + <!– –> + + + + io.ebean + ebean-test-containers + 7.1 + test + --> org.avaje.composite @@ -114,10 +126,11 @@ mvn install:install-file -Dfile=/some/path/to/ojdbc7.jar -DgroupId=oracle \ test + - io.ebean - ebean-test-containers - 7.1 + com.h2database + h2 + 2.2.220 test @@ -128,13 +141,21 @@ mvn install:install-file -Dfile=/some/path/to/ojdbc7.jar -DgroupId=oracle \ test - - io.ebean - ebean-datasource - 8.0 - test - - + + + + io.repaint.maven + tiles-maven-plugin + 2.33 + true + + + io.ebean.tile:enhancement:13.25.0 + + + + + diff --git a/ebean-migration-it/src/main/java/module-info.java b/ebean-migration-it/src/main/java/module-info.java deleted file mode 100644 index 1157961..0000000 --- a/ebean-migration-it/src/main/java/module-info.java +++ /dev/null @@ -1,4 +0,0 @@ -open module io.ebean.migration.it { - requires io.ebean.migration; - uses io.ebean.migration.JdbcMigration; -} diff --git a/ebean-migration-it/src/main/java/org/migration/model/DemoModel.java b/ebean-migration-it/src/main/java/org/migration/model/DemoModel.java new file mode 100644 index 0000000..a0274d1 --- /dev/null +++ b/ebean-migration-it/src/main/java/org/migration/model/DemoModel.java @@ -0,0 +1,15 @@ +package org.migration.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +/** + * @author Roland Praml, FOCONIS AG + */ +@Entity +public class DemoModel { + @Id + private int id; + + private String foo; +} diff --git a/ebean-migration-it/src/main/java/org/migration/model/M3.java b/ebean-migration-it/src/main/java/org/migration/model/M3.java new file mode 100644 index 0000000..9c4eca6 --- /dev/null +++ b/ebean-migration-it/src/main/java/org/migration/model/M3.java @@ -0,0 +1,30 @@ +package org.migration.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +/** + * @author Roland Praml, FOCONIS AG + */ +@Entity +public class M3 { + @Id + private int id; + private String acol; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getAcol() { + return acol; + } + + public void setAcol(String acol) { + this.acol = acol; + } +} diff --git a/ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json b/ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json deleted file mode 100644 index ae5a364..0000000 --- a/ebean-migration-it/src/main/resources/META-INF/native-image/io.ebean.migration.ebean-migration/resource-config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "resources": [ - { - "pattern": ".*\\.sql" - }, - { - "pattern": ".*\\.migrations" - } - ] -} diff --git a/ebean-migration-it/src/main/resources/ebean.mf b/ebean-migration-it/src/main/resources/ebean.mf new file mode 100644 index 0000000..ff58400 --- /dev/null +++ b/ebean-migration-it/src/main/resources/ebean.mf @@ -0,0 +1,3 @@ +entity-packages: org.migration.model +entity-field-access: true +synthetic: false diff --git a/ebean-migration-it/src/main/resources/migration-support/default-create-table.sql b/ebean-migration-it/src/main/resources/migration-support/default-create-table.sql deleted file mode 100644 index d71224e..0000000 --- a/ebean-migration-it/src/main/resources/migration-support/default-create-table.sql +++ /dev/null @@ -1,13 +0,0 @@ -create table ${table} ( - id integer not null, - mchecksum integer not null, - mtype varchar(1) not null, - mversion varchar(150) not null, - mcomment varchar(150) not null, - mstatus varchar(10) not null, - run_on timestamp not null, - run_by varchar(30) not null, - run_time integer not null, - constraint ${pk_table} primary key (id) -); - diff --git a/ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql b/ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql deleted file mode 100644 index 752e74c..0000000 --- a/ebean-migration-it/src/main/resources/migration-support/sqlserver-create-table.sql +++ /dev/null @@ -1,13 +0,0 @@ -create table ${table} ( - id integer not null, - mchecksum integer not null, - mtype varchar(1) not null, - mversion varchar(150) not null, - mcomment varchar(150) not null, - mstatus varchar(10) not null, - run_on datetime2 not null, - run_by varchar(30) not null, - run_time integer not null, - constraint ${pk_table} primary key (id) -); - diff --git a/ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java b/ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java deleted file mode 100644 index cc87495..0000000 --- a/ebean-migration-it/src/test/java/dbmig/V1_2_1__test.java +++ /dev/null @@ -1,29 +0,0 @@ -package dbmig; - -import java.sql.Connection; - -import io.ebean.migration.JdbcMigration; -import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationContext; - -/** - * Sample migration. - * - * @author Roland Praml, FOCONIS AG - */ -public class V1_2_1__test implements JdbcMigration { - - public static class MyDto { - String id; - } - - @Override - public void migrate(MigrationContext context) { - System.out.println("Executing migration on " + context); - } - - @Override - public String toString() { - return "Dummy jdbc migration"; - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java b/ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java deleted file mode 100644 index 323dd11..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.ebean.config.dbplatform.h2; - -import org.h2.api.Trigger; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.*; -import java.util.Arrays; - -/** - * H2 database trigger used to populate history tables to support the @History feature. - */ -public class H2HistoryTrigger implements Trigger { - - private static final Logger logger = LoggerFactory.getLogger(H2HistoryTrigger.class); - - /** - * Hardcoding the column and history table suffix for now. Not sure how to get that - * configuration into the trigger instance nicely as it is instantiated by H2. - */ - private static final String SYS_PERIOD_START = "SYS_PERIOD_START"; - private static final String SYS_PERIOD_END = "SYS_PERIOD_END"; - private static final String HISTORY_SUFFIX = "_history"; - - /** - * SQL to insert into the history table. - */ - private String insertHistorySql; - - /** - * Position of SYS_PERIOD_START column in the Object[]. - */ - private int effectStartPosition; - - /** - * Position of SYS_PERIOD_END column in the Object[]. - */ - private int effectEndPosition; - - @Override - public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException { - // get the columns for the table - ResultSet rs = conn.getMetaData().getColumns(null, schemaName, tableName, null); - - // build the insert into history table SQL - StringBuilder insertSql = new StringBuilder(150); - insertSql.append("insert into ").append(schemaName).append(".").append(tableName).append(HISTORY_SUFFIX).append(" ("); - - int count = 0; - while (rs.next()) { - if (++count > 1) { - insertSql.append(","); - } - String columnName = rs.getString("COLUMN_NAME"); - if (columnName.equalsIgnoreCase(SYS_PERIOD_START)) { - this.effectStartPosition = count - 1; - } else if (columnName.equalsIgnoreCase(SYS_PERIOD_END)) { - this.effectEndPosition = count - 1; - } - insertSql.append(columnName); - } - insertSql.append(") values ("); - for (int i = 0; i < count; i++) { - if (i > 0) { - insertSql.append(","); - } - insertSql.append("?"); - } - insertSql.append(");"); - - this.insertHistorySql = insertSql.toString(); - logger.debug("History table insert sql: {}", insertHistorySql); - } - - @Override - public void fire(Connection connection, Object[] oldRow, Object[] newRow) throws SQLException { - if (oldRow != null) { - // a delete or update event - Timestamp now = new Timestamp(System.currentTimeMillis()); - oldRow[effectEndPosition] = now; - if (newRow != null) { - // update event. Set the effective start timestamp to now. - newRow[effectStartPosition] = now; - } - if (logger.isDebugEnabled()) { - logger.debug("History insert: {}", Arrays.toString(oldRow)); - } - insertIntoHistory(connection, oldRow); - } - } - - /** - * Insert the data into the history table. - */ - private void insertIntoHistory(Connection connection, Object[] oldRow) throws SQLException { - try (PreparedStatement stmt = connection.prepareStatement(insertHistorySql)) { - for (int i = 0; i < oldRow.length; i++) { - stmt.setObject(i + 1, oldRow[i]); - } - stmt.executeUpdate(); - } - } - - @Override - public void close() throws SQLException { - // do nothing - } - - @Override - public void remove() throws SQLException { - // do nothing - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java deleted file mode 100644 index 9f4db0f..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/AutoRunnerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.ebean.migration; - -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Properties; - -import static org.junit.jupiter.api.Assertions.*; - -class AutoRunnerTest { - - @Test - void run() throws SQLException { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setUrl("jdbc:h2:mem:testsAutoRun"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - Properties properties = new Properties(); - properties.setProperty("dbmigration.migrationPath","dbmig_autorun"); - - AutoRunner autoRunner = new AutoRunner(); - autoRunner.setDefaultDbSchema("other"); - autoRunner.loadProperties(properties); - autoRunner.run(dataSource); - - - assertTrue(executeQuery(dataSource)); - } - - private boolean executeQuery(DataSourcePool dataSource) throws SQLException { - try (final Connection connection = dataSource.getConnection()) { - try (final PreparedStatement stmt = connection.prepareStatement("select * from m1")) { - try (final ResultSet resultSet = stmt.executeQuery()) { - return true; - } - } - } - } -} \ No newline at end of file diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java deleted file mode 100644 index 62c721b..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationConfigTest.java +++ /dev/null @@ -1,152 +0,0 @@ -package io.ebean.migration; - -import org.junit.jupiter.api.Test; - -import java.sql.Connection; -import java.util.Properties; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class MigrationConfigTest { - - @Test - public void testDefaults() { - - MigrationConfig config = new MigrationConfig(); - - assertNull(config.getDbUrl()); - assertNull(config.getDbUsername()); - assertNull(config.getDbPassword()); - assertTrue(config.isCreateSchemaIfNotExists()); - assertTrue(config.isSetCurrentSchema()); - assertFalse(config.isSkipChecksum()); - assertFalse(config.isSkipMigrationRun()); - assertEquals(config.getMetaTable(), "db_migration"); - assertNull(config.getRunPlaceholders()); - assertEquals(config.getMigrationPath(), "dbmigration"); - assertNotNull(config.getClassLoader()); - assertNull(config.getRunPlaceholderMap()); - } - - @Test - public void loadProperties_ebean_migration() { - - Properties props = new Properties(); - props.setProperty("ebean.migration.username","username"); - props.setProperty("ebean.migration.password","password"); - props.setProperty("ebean.migration.schema","fooSchema"); - props.setProperty("ebean.migration.createSchemaIfNotExists","false"); - props.setProperty("ebean.migration.setCurrentSchema","false"); - props.setProperty("ebean.migration.skipMigrationRun","true"); - props.setProperty("ebean.migration.skipChecksum","true"); - props.setProperty("ebean.migration.driver","driver"); - props.setProperty("ebean.migration.url","url"); - props.setProperty("ebean.migration.metaTable","metaTable"); - props.setProperty("ebean.migration.placeholders","placeholders"); - props.setProperty("ebean.migration.migrationPath","migrationPath"); - props.setProperty("ebean.migration.patchResetChecksumOn", "1.1,1.2"); - - assertLoadedProperties(props); - } - - @Test - public void loadProperties() { - - Properties props = new Properties(); - props.setProperty("dbmigration.username","username"); - props.setProperty("dbmigration.password","password"); - props.setProperty("dbmigration.schema","fooSchema"); - props.setProperty("dbmigration.createSchemaIfNotExists","false"); - props.setProperty("dbmigration.setCurrentSchema","false"); - props.setProperty("dbmigration.skipMigrationRun","true"); - props.setProperty("dbmigration.skipChecksum","true"); - props.setProperty("dbmigration.driver","driver"); - props.setProperty("dbmigration.url","url"); - props.setProperty("dbmigration.metaTable","metaTable"); - props.setProperty("dbmigration.placeholders","placeholders"); - props.setProperty("dbmigration.migrationPath","migrationPath"); - props.setProperty("dbmigration.patchResetChecksumOn", "1.1,1.2"); - - assertLoadedProperties(props); - } - - private void assertLoadedProperties(Properties props) { - MigrationConfig config = new MigrationConfig(); - config.load(props); - - assertEquals(config.getDbUrl(), "url"); - assertEquals(config.getDbUsername(), "username"); - assertEquals(config.getDbPassword(), "password"); - assertEquals(config.getDbSchema(), "fooSchema"); - assertFalse(config.isCreateSchemaIfNotExists()); - assertFalse(config.isSetCurrentSchema()); - assertTrue(config.isSkipChecksum()); - assertTrue(config.isSkipMigrationRun()); - assertEquals(config.getMetaTable(), "metaTable"); - assertEquals(config.getRunPlaceholders(), "placeholders"); - assertEquals(config.getMigrationPath(), "migrationPath"); - assertThat(config.getPatchResetChecksumOn()).contains("1.1", "1.2"); - } - - @Test - public void loadProperties_withName() { - - Properties props = new Properties(); - props.setProperty("ebean.mydb.migration.username","username"); - props.setProperty("ebean.mydb.migration.migrationPath","migrationPath"); - props.setProperty("ebean.migration.password","password"); - props.setProperty("ebean.migration.schema","fooSchema"); - props.setProperty("dbmigration.url","url"); - props.setProperty("dbmigration.metaTable","metaTable"); - - MigrationConfig config = new MigrationConfig(); - config.setName("mydb"); - config.load(props); - - assertEquals(config.getDbUrl(), "url"); - assertEquals(config.getDbUsername(), "username"); - assertEquals(config.getDbPassword(), "password"); - assertEquals(config.getDbSchema(), "fooSchema"); - - assertEquals(config.getDbUrl(), "url"); - assertEquals(config.getMetaTable(), "metaTable"); - } - - @Test - public void createConnection() { - - Properties props = new Properties(); - props.setProperty("dbmigration.username","sa"); - props.setProperty("dbmigration.password",""); - props.setProperty("dbmigration.driver","org.h2.Driver"); - props.setProperty("dbmigration.url","jdbc:h2:mem:createConn"); - - MigrationConfig config = new MigrationConfig(); - config.load(props); - - Connection connection = config.createConnection(); - assertNotNull(connection); - } - - @Test - public void setResetChecksumVersionsOn() { - - MigrationConfig config = new MigrationConfig(); - config.setPatchResetChecksumOn("1.3,2.1,3.4.5,R__foo_bar"); - config.setPatchInsertOn("2.1,R__foo_bar"); - - Set resetVersions = config.getPatchResetChecksumOn(); - assertThat(resetVersions).contains("1.3", "2.1", "3.4.5", "foo_bar"); - assertThat(resetVersions).hasSize(4); - - Set insertVersions = config.getPatchInsertOn(); - assertThat(insertVersions).contains("2.1", "foo_bar"); - assertThat(insertVersions).hasSize(2); - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java deleted file mode 100644 index b0e4cb5..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunnerTest.java +++ /dev/null @@ -1,334 +0,0 @@ -package io.ebean.migration; - -import dbmig.V1_2_1__test; -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.fail; - -public class MigrationRunnerTest { - - private MigrationConfig createMigrationConfig() { - MigrationConfig config = new MigrationConfig(); - config.setDbUsername("sa"); - config.setDbPassword(""); - config.setDbUrl("jdbc:h2:mem:dbMx1"); - - return config; - } - - @Test - public void run_when_createConnection() { - - MigrationConfig config = createMigrationConfig(); - - config.setMigrationPath("dbmig"); - MigrationRunner runner = new MigrationRunner(config); - - List check = runner.checkState(); - assertThat(check).hasSize(5); - - assertThat(check.get(0).content()).contains("-- do nothing"); - assertThat(check.get(1).content()).contains("create table m1"); - assertThat(check.get(2).content()).contains("create table m3"); - - runner.run(); - } - - @Test - public void run_when_fileSystemResources() { - - MigrationConfig config = createMigrationConfig(); - - config.setMigrationPath("filesystem:test-fs-resources/fsdbmig"); - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - } - - @Test - public void run_when_error() throws SQLException { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:err.db"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = createMigrationConfig(); - config.setMigrationPath("dbmig_error"); - MigrationRunner runner = new MigrationRunner(config); - try { - runner.run(dataSource); - } catch (Exception expected) { - try (Connection connection = dataSource.getConnection()) { - try (var pstmt = connection.prepareStatement("select count(*) from m1")) { - try (var resultSet = pstmt.executeQuery()) { - assertThat(resultSet.next()).isTrue(); - int val = resultSet.getInt(1); - assertThat(val).isEqualTo(0); - } - } catch (SQLException ex) { - fail(ex); - } - } - } - } - - @Test - public void run_when_suppliedConnection() { - - MigrationConfig config = createMigrationConfig(); - Connection connection = config.createConnection(); - - config.setMigrationPath("dbmig"); - MigrationRunner runner = new MigrationRunner(config); - runner.run(connection); - } - - @Test - public void run_when_suppliedDataSource() { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:tests"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = createMigrationConfig(); - config.setMigrationPath("dbmig"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - System.out.println("-- run second time --"); - runner.run(dataSource); - - // simulate change to repeatable migration - config.setMigrationPath("dbmig3"); - System.out.println("-- run third time --"); - runner.run(dataSource); - - config.setMigrationPath("dbmig4"); - - config.setPatchResetChecksumOn("m2_view,1.2"); - List checkState = runner.checkState(dataSource); - assertThat(checkState).hasSize(1); - assertThat(checkState.get(0).version().asString()).isEqualTo("1.3"); - - config.setPatchInsertOn("1.3"); - checkState = runner.checkState(dataSource); - assertThat(checkState).isEmpty(); - - System.out.println("-- run forth time --"); - runner.run(dataSource); - - System.out.println("-- run fifth time --"); - checkState = runner.checkState(dataSource); - assertThat(checkState).isEmpty(); - runner.run(dataSource); - - } - - @Test - public void run_with_dbinit() throws SQLException { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:testsDbInit"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = createMigrationConfig(); - config.setDbUrl("jdbc:h2:mem:testsDbInit"); - config.setMigrationPath("dbmig5_base"); - config.setMigrationInitPath("dbmig5_init"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - MigrationRunner runner2 = new MigrationRunner(config); - runner2.run(dataSource); - - try (final Connection connection = dataSource.getConnection()) { - final List names = migrationNames(connection); - assertThat(names).containsExactly("", "some_i", "m4", "some_r"); - } - } - - @Test - public void run_only_dbinit_available() throws SQLException { - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:testsDbInit2"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = createMigrationConfig(); - config.setDbUrl("jdbc:h2:mem:testsDbInit2"); - config.setMigrationPath("dbmig6_base"); - config.setMigrationInitPath("dbmig6_init"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - MigrationRunner runner2 = new MigrationRunner(config); - runner2.run(dataSource); - - try (final Connection connection = dataSource.getConnection()) { - final List names = migrationNames(connection); - assertThat(names).containsExactly("", "m4"); - } - } - - @Test - public void run_with_min_version() { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:testsMinV"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = createMigrationConfig(); - config.setMigrationPath("dbmig"); - config.setJdbcMigrations(List.of(new V1_2_1__test())); - - config.setMinVersion("1.3"); // dbmig must run, if DB is empty! - new MigrationRunner(config).run(dataSource); - - - config = createMigrationConfig(); - config.setMigrationPath("dbmig3"); - config.setMinVersion("1.3"); - config.setMinVersionFailMessage("Must run dbmig2 first."); - - MigrationRunner runner3 = new MigrationRunner(config); - assertThatThrownBy(() -> runner3.run(dataSource)) - .isInstanceOf(MigrationException.class) - .hasMessageContaining("Must run dbmig2 first. MigrationVersion mismatch: v1.2.1 < v1.3"); - - // now run dbmig2, as intended by error message - config = createMigrationConfig(); - config.setMigrationPath("dbmig2"); - new MigrationRunner(config).run(dataSource); - - // dbmig3 should pass now - runner3.run(dataSource); - } - - @Test - public void run_init_with_min_version() { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:testsMinVinit"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - // init - MigrationConfig config = createMigrationConfig(); - config.setMigrationPath("dbmig5_base"); - config.setMigrationInitPath("dbmig5_init"); - config.setMinVersion("2.0"); // init must run, although DB is empty! - new MigrationRunner(config).run(dataSource); - - // test if migration detects correct init-version (1.3) - config = createMigrationConfig(); - config.setMigrationPath("dbmig3"); - config.setMinVersion("2.0"); - - MigrationRunner runner = new MigrationRunner(config); - assertThatThrownBy(() -> runner.run(dataSource)) - .isInstanceOf(MigrationException.class) - .hasMessageContaining("MigrationVersion mismatch: v1.3 < v2.0"); - } - - @Test - public void run_with_skipMigration() throws SQLException { - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:testsSkipMigration"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - MigrationConfig config = createMigrationConfig(); - // not actually run the migrations but populate the migration table - config.setSkipMigrationRun(true); - config.setMigrationPath("dbmig"); - - DataSourcePool dataSource = DataSourceFactory.create("skipMigration", dataSourceConfig); - new MigrationRunner(config).run(dataSource); - - // assert migrations are in the migration table - try (final Connection connection = dataSource.getConnection()) { - final List names = migrationNames(connection); - assertThat(names).containsExactly("", "hello", "initial", "add_m3", "serviceLoaded", "m2_view"); - } - - // assert the migrations didn't actually run (create the tables etc) - try (final Connection connection = dataSource.getConnection()) { - singleQueryResult(connection, "select acol from m3"); - fail(); - } catch (SQLException e) { - assertThat(e.getMessage()).contains("Table \"M3\" not found;"); - } - } - - - /** - * Run this integration test manually against CockroachDB. - */ - @Disabled - @Test - public void cockroach_integrationTest() { - - MigrationConfig config = createMigrationConfig(); - config.setDbUsername("unit"); - config.setDbPassword("unit"); - config.setDbUrl("jdbc:postgresql://127.0.0.1:26257/unit"); - config.setMigrationPath("dbmig-roach"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - } - - private List migrationNames(Connection connection) throws SQLException { - return singleQueryResult(connection, "select mcomment from db_migration"); - } - - private List singleQueryResult(Connection connection, String sql) throws SQLException { - List names = new ArrayList<>(); - try (final PreparedStatement statement = connection.prepareStatement(sql)) { - try (final ResultSet resultSet = statement.executeQuery()) { - while (resultSet.next()) { - names.add(resultSet.getString(1)); - } - } - } - return names; - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java deleted file mode 100644 index 6c158c3..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_FastCheckTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package io.ebean.migration; - -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrationRunner_FastCheckTest { - - private MigrationConfig createMigrationConfig() { - MigrationConfig config = new MigrationConfig(); - config.setDbUsername("sa"); - config.setDbPassword(""); - config.setDbUrl("jdbc:h2:mem:dbMxFastCheck"); - - return config; - } - - @Test - public void run_when_createConnection() { - - MigrationConfig config = createMigrationConfig(); - - config.setPlatform("h2"); - config.setMigrationPath("fastcheck"); - - MigrationRunner runner = new MigrationRunner(config); - - runner.run(); - } - - @Test - public void run_when() { - - MigrationConfig config = createMigrationConfig(); - - config.setPlatform("h2"); - config.setMigrationPath("index0"); - - MigrationRunner runner = new MigrationRunner(config); - - runner.run(); - } - - @Test - public void autoEnableEarlyMode_when_indexFileAddedToExistingMigrations() { - - String url = "jdbc:h2:mem:autoEnableEarlyMode"; - DataSourceConfig dataSourceConfig = new DataSourceConfig() - .setUrl(url) - .setUsername("sa") - .setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = new MigrationConfig(); - config.setPlatform("h2"); - config.setRunPlaceholderMap(Map.of("my_table_name", "bar")); - - // initial traditional migration - config.setMigrationPath("indexB_0"); - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - assertThat(config.isEarlyChecksumMode()).isFalse(); - - // add an index file now, expect automatically go to early mode + patch checksums - config.setMigrationPath("indexB_1"); - new MigrationRunner(config).run(dataSource); - assertThat(config.isEarlyChecksumMode()).isTrue(); - - // early mode via row + add an extra migration - config.setMigrationPath("indexB_2"); - new MigrationRunner(config).run(dataSource); - - dataSource.shutdown(); - } - - @Test - public void autoEnableEarlyMode() { - - MigrationConfig config = createMigrationConfig(); - - config.setPlatform("h2"); - config.setMigrationPath("indexB_1"); - config.setDbUrl("jdbc:h2:mem:autoEnableEarlyMode_simple"); - config.setRunPlaceholderMap(Map.of("my_table_name", "bar")); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - assertThat(config.isEarlyChecksumMode()).isTrue(); - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java deleted file mode 100644 index 33c6958..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_MultiPlatformTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.ebean.migration; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class MigrationRunner_MultiPlatformTest { - - private MigrationConfig createMigrationConfig(String memName) { - MigrationConfig config = new MigrationConfig(); - config.setDbUsername("sa"); - config.setDbPassword(""); - config.setDbUrl("jdbc:h2:mem:" + memName); - return config; - } - - @Test - void run_withPlatformOnly() { - MigrationConfig config = createMigrationConfig("dbMxMultiPlatform0"); - - config.setPlatform("h2"); - config.setMigrationPath("multiplatform"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - assertThat(runner.checkState()).hasSize(1); - } - - @Test - void run_withBase_thatDoesNotExist() { - MigrationConfig config = createMigrationConfig("dbMxMultiPlatform1"); - - config.setBasePlatform("doesNotExist"); - config.setPlatform("h2"); - config.setMigrationPath("multiplatform"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - assertThat(runner.checkState()).hasSize(1); - } - - @Test - void run_withBase() { - MigrationConfig config = createMigrationConfig("dbMxBasePlatform"); - - config.setBasePlatform("mybase"); - config.setPlatform("h2"); - config.setMigrationPath("multiplatform"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - assertThat(runner.checkState()).hasSize(2); - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java deleted file mode 100644 index d57ea4a..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_PatchResetTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.ebean.migration; - -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import org.junit.jupiter.api.Test; - -class MigrationRunner_PatchResetTest { - - @Test - void patchReset() { - - String url = "jdbc:h2:mem:patchReset"; - DataSourceConfig dataSourceConfig = new DataSourceConfig() - .setUrl(url) - .setUsername("sa") - .setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test", dataSourceConfig); - - MigrationConfig config = new MigrationConfig(); - config.setPlatform("h2"); - - config.setMigrationPath("indexPatchReset_0"); - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - // add an index file now, expect automatically go to early mode + patch checksums - config.setMigrationPath("indexPatchReset_1"); - config.setPatchResetChecksumOn("*"); - new MigrationRunner(config).run(dataSource); - - dataSource.shutdown(); - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java deleted file mode 100644 index 1b24355..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_emptyTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.ebean.migration; - -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import org.junit.jupiter.api.Test; - -class MigrationRunner_emptyTest { - - @Test - void run_withDatasource_expectNoLeak() { - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setDriver("org.h2.Driver"); - dataSourceConfig.setUrl("jdbc:h2:mem:dbEmpty1"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - - DataSourcePool dataSource = DataSourceFactory.create("test-empty", dataSourceConfig); - - MigrationConfig config = new MigrationConfig(); - config.setMigrationPath("empty-dbmig"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - dataSource.shutdown(); - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java deleted file mode 100644 index 8f6e6a9..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationRunner_platform_Test.java +++ /dev/null @@ -1,281 +0,0 @@ -package io.ebean.migration; - -import io.ebean.ddlrunner.DdlRunner; -import io.ebean.test.containers.*; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrationRunner_platform_Test { - - private final NuoDBContainer nuoDBContainer = createNuoDB(); - private final PostgresContainer postgresContainer = createPostgres(); - private final SqlServerContainer sqlServerContainer = createSqlServer(); - private final MySqlContainer mysqlContainer = createMySqlContainer(); - private final OracleContainer oracleContainer = createOracleContainer(); - - private static void setContainerName(ContainerBuilderDb config, String suffix) { - config.containerName("test_ebean_migration_" + suffix); - config.user("mig_test"); - config.dbName("mig_test"); - } - - private static NuoDBContainer createNuoDB() { - return NuoDBContainer.builder("4.0") - .schema("mig_test") - .user("mig_test") - .password("test") - .build(); - } - - private static PostgresContainer createPostgres() { - PostgresContainer.Builder builder = PostgresContainer.builder("15") - .port(9823); - setContainerName(builder, "pg15"); - return builder.build(); - } - - private static SqlServerContainer createSqlServer() { - SqlServerContainer.Builder builder = SqlServerContainer.builder("2017-GA-ubuntu").port(2433); - setContainerName(builder, "sql17"); - return builder.build(); - } - - private static MySqlContainer createMySqlContainer() { - MySqlContainer.Builder builder = MySqlContainer.builder("8.0").port(14306); - setContainerName(builder, "mysql"); - return builder.build(); - } - - private static OracleContainer createOracleContainer() { - OracleContainer.Builder builder = OracleContainer.builder("latest"); - setContainerName(builder, "oracle"); - return builder - .dbName("XE") - .image("oracleinanutshell/oracle-xe-11g:latest") - .build(); - } - - private MigrationConfig newMigrationConfig() { - MigrationConfig config = new MigrationConfig(); - config.setDbUsername("mig_test"); - config.setDbPassword("test"); - return config; - } - - private MigrationConfig postgresMigrationConfig() { - MigrationConfig config = newMigrationConfig(); - config.setDbUrl(postgresContainer.jdbcUrl()); - return config; - } - - private MigrationConfig sqlServerMigrationConfig() { - MigrationConfig config = newMigrationConfig(); - config.setDbPassword("SqlS3rv#r"); - config.setDbUrl(sqlServerContainer.jdbcUrl()); - return config; - } - - private MigrationConfig nuodDbMigrationConfig() { - MigrationConfig config = newMigrationConfig(); - config.setDbUrl(nuoDBContainer.jdbcUrl()); - config.setDbSchema("mig_test"); - config.setDbUsername("mig_test"); - config.setDbPassword("test"); - return config; - } - - private MigrationConfig mysqlMigrationConfig() { - MigrationConfig config = newMigrationConfig(); - config.setDbUrl(mysqlContainer.jdbcUrl()); - return config; - } - - private MigrationConfig oracleMigrationConfig() { - MigrationConfig config = newMigrationConfig(); - config.setDbUrl(oracleContainer.jdbcUrl()); - return config; - } - - @Test - public void postgres_migration() throws SQLException { - - postgresContainer.startWithDropCreate(); - - MigrationConfig config = postgresMigrationConfig(); - - config.setMigrationPath("dbmig"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - System.out.println("-- run 2 --"); - runner.run(); - - System.out.println("-- run 3 --"); - config.setMigrationPath("dbmig2"); - runner.run(); - - try (Connection connection = postgresContainer.createConnection()) { - assertThat(readQuery(connection, "select * from m1")).isEqualTo(0); - readQuery(connection, "select * from m2"); - readQuery(connection, "select * from m3"); - } - - config.setMigrationPath("dbmig_postgres_concurrently0"); - runner.run(); - - config.setMigrationPath("dbmig_postgres_concurrently1"); - runner.run(); - - ddlRunnerBasic(); - ddlRunnerWithConcurrently(); - try (Connection connection = postgresContainer.createConnection()) { - assertThat(readQuery(connection, "select * from m1")).isEqualTo(6); - } - - postgresContainer.stopRemove(); - } - - private void ddlRunnerWithConcurrently() throws SQLException { - String content = - "insert into m1 (id, acol) values (2001, '2one');\n" + - "insert into m1 (id, acol) values (2002, '2two');\n" + - "insert into m1 (id, acol) values (2003, '2three');\n" + - "create index concurrently ix2_m1_acol0 on m1 (acol);\n" + - "create index concurrently ix2_m1_acol1 on m1 (lower(acol), id);\n"; - - try (Connection connection = postgresContainer.createConnection()) { - connection.setAutoCommit(false); - DdlRunner runner = new DdlRunner(false, "test", "postgres"); - runner.runAll(content, connection); - connection.commit(); - - assertThat(runner.runNonTransactional(connection)).isEqualTo(2).as("executed create index concurrently"); - } - } - - private void ddlRunnerBasic() throws SQLException { - - String content = - "insert into m1 (id, acol) values (1001, 'one');\n" + - "insert into m1 (id, acol) values (1002, 'two');\n" + - "insert into m1 (id, acol) values (1003, 'three');\n"; - - try (Connection connection = postgresContainer.createConnection()) { - connection.setAutoCommit(false); - DdlRunner runner = new DdlRunner(false, "test"); - runner.runAll(content, connection); - connection.commit(); - - assertThat(runner.runNonTransactional(connection)).isEqualTo(0).as("all transactional"); - } - } - - @Disabled - @Test - public void sqlServer_migration() throws SQLException { - - sqlServerContainer.startWithDropCreate(); - - MigrationConfig config = sqlServerMigrationConfig(); - - config.setMigrationPath("dbmig_sqlserver"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - try (Connection connection = sqlServerContainer.createConnection()) { - readQuery(connection, "select * from m1"); - readQuery(connection, "select * from m2"); - readQuery(connection, "select * from m3"); - } - -// sqlServerContainer.stopRemove(); - } - - @Test - public void mysql_migration() throws SQLException { - - mysqlContainer.stopRemove(); - mysqlContainer.startWithDropCreate(); - - MigrationConfig config = mysqlMigrationConfig(); - - config.setMigrationPath("dbmig_basic"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - try (Connection connection = mysqlContainer.createConnection()) { - readQuery(connection, "select * from m1"); - readQuery(connection, "select * from m2"); - readQuery(connection, "select * from m3"); - } - - mysqlContainer.stopRemove(); - } - - @Disabled - @Test - public void nuodb_migration() throws SQLException { - - //nuoDBContainer.stopRemove(); - nuoDBContainer.startWithDropCreate(); - - MigrationConfig config = nuodDbMigrationConfig(); - config.setMigrationPath("dbmig_nuodb"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - try (Connection connection = nuoDBContainer.createConnection()) { - readQuery(connection, "select * from m1"); - readQuery(connection, "select * from orp_master"); - readQuery(connection, "select * from orp_master_with_history"); - } - nuoDBContainer.stop(); - } - - @Disabled - @Test - public void oracle_migration() throws SQLException { - - oracleContainer.startWithDropCreate(); - - MigrationConfig config = oracleMigrationConfig(); - - config.setMigrationPath("dbmig_basic"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(); - - try (Connection connection = oracleContainer.createConnection()) { - readQuery(connection, "select * from m1"); - readQuery(connection, "select * from m2"); - readQuery(connection, "select * from m3"); - } - - //oracleContainer.stopRemove(); - } - - private int readQuery(Connection connection, String sql) throws SQLException { - int rowCount = 0; - try (PreparedStatement stmt = connection.prepareStatement(sql)) { - try (ResultSet rset = stmt.executeQuery()) { - while (rset.next()) { - rset.getObject(1); - rowCount++; - } - } - } - return rowCount; - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java deleted file mode 100644 index ce65b8c..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/MigrationVersionTest.java +++ /dev/null @@ -1,227 +0,0 @@ -package io.ebean.migration; - -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -class MigrationVersionTest { - - - @Test - void sort() { - - List list = new ArrayList<>(); - list.add(MigrationVersion.parse("1.1__point")); - list.add(MigrationVersion.parse("3.0__three")); - list.add(MigrationVersion.parse("1.0__init")); - list.add(MigrationVersion.parse("R__beta")); - list.add(MigrationVersion.parse("R__alpha")); - - Collections.sort(list); - - assertThat(list.get(0).comment()).isEqualTo("init"); - assertThat(list.get(1).comment()).isEqualTo("point"); - assertThat(list.get(2).comment()).isEqualTo("three"); - assertThat(list.get(3).comment()).isEqualTo("alpha"); - assertThat(list.get(4).comment()).isEqualTo("beta"); - } - - @Test - void test_subversions() { - - MigrationVersion v141 = MigrationVersion.parse("V1.4.1__comment"); - MigrationVersion v14 = MigrationVersion.parse("V1.4__comment"); - assertThat(v141).isGreaterThan(v14); - assertThat(v14).isLessThan(v141); - } - - @Test - void test_parse_hyphenSnapshot() { - - MigrationVersion version = MigrationVersion.parse("0.1.1-SNAPSHOT"); - assertThat(version.normalised()).isEqualTo("0.1.1"); - assertThat(version.comment()).isEqualTo(""); - assertThat(version.type()).isEqualTo("V"); - } - - @Test - void test_parse_hyphenSnapshot_when_underscores() { - - MigrationVersion version = MigrationVersion.parse("0_1_1-SNAPSHOT__Foo"); - assertThat(version.normalised()).isEqualTo("0.1.1"); - assertThat(version.comment()).isEqualTo("Foo"); - } - - @Test - void test_parse_when_repeatable() { - - MigrationVersion version = MigrationVersion.parse("R__Foo"); - assertThat(version.comment()).isEqualTo("Foo"); - assertThat(version.isRepeatable()).isTrue(); - assertThat(version.normalised()).isEqualTo("R"); - assertThat(version.type()).isEqualTo("R"); - } - - @Test - void test_parse_when_init() { - - MigrationVersion version = MigrationVersion.parse("I__Foo"); - assertThat(version.comment()).isEqualTo("Foo"); - assertThat(version.isRepeatable()).isTrue(); - assertThat(version.normalised()).isEqualTo("I"); - assertThat(version.type()).isEqualTo("I"); - } - - @Test - void test_parse_when_repeatable_R1() { - - MigrationVersion version = MigrationVersion.parse("R1__Foo"); - assertThat(version.comment()).isEqualTo("Foo"); - assertThat(version.normalised()).isEqualTo("R"); - assertThat(version.isRepeatable()).isTrue(); - assertThat(version.type()).isEqualTo("R"); - } - - @Test - void test_parse_when_repeatable_case() { - - MigrationVersion version = MigrationVersion.parse("r__Foo"); - assertThat(version.isRepeatable()).isTrue(); - assertThat(version.comment()).isEqualTo("Foo"); - assertThat(version.normalised()).isEqualTo("R"); - assertThat(version.type()).isEqualTo("R"); - } - - @Test - void test_parse_when_v_prefix() { - - MigrationVersion version = MigrationVersion.parse("v1_0__Foo"); - assertThat(version.isRepeatable()).isFalse(); - assertThat(version.comment()).isEqualTo("Foo"); - assertThat(version.normalised()).isEqualTo("1.0"); - assertThat(version.asString()).isEqualTo("1_0"); - assertThat(version.raw()).isEqualTo("1_0__Foo"); - assertThat(version.type()).isEqualTo("V"); - } - - @Test - void test_parse_when_sql_suffix() { - - MigrationVersion version = MigrationVersion.parse("v1_0__Foo.sql"); - assertThat(version.isRepeatable()).isFalse(); - assertThat(version.comment()).isEqualTo("Foo"); - assertThat(version.normalised()).isEqualTo("1.0"); - assertThat(version.asString()).isEqualTo("1_0"); - assertThat(version.raw()).isEqualTo("1_0__Foo"); - assertThat(version.type()).isEqualTo("V"); - } - - @Test - void repeatable_compareTo() { - - MigrationVersion foo = MigrationVersion.parse("R__Foo"); - MigrationVersion bar = MigrationVersion.parse("R__Bar"); - assertThat(foo.compareTo(bar)).isGreaterThan(0); - assertThat(bar.compareTo(foo)).isLessThan(0); - - MigrationVersion bar2 = MigrationVersion.parse("R__Bar"); - assertThat(bar.compareTo(bar2)).isEqualTo(0); - } - - @Test - void repeatable_init_compareTo() { - - MigrationVersion foo = MigrationVersion.parse("R__Foo"); - MigrationVersion goo = MigrationVersion.parse("I__Goo"); - assertThat(foo.compareTo(goo)).isGreaterThan(0); - assertThat(goo.compareTo(foo)).isLessThan(0); - } - - @Test - void repeatable_compareTo_when_caseDifferent() { - - MigrationVersion none = MigrationVersion.parse("R__"); - MigrationVersion bar = MigrationVersion.parse("R__Bar"); - MigrationVersion bar2 = MigrationVersion.parse("R__bar"); - assertThat(none.compareTo(bar)).isLessThan(0); - assertThat(bar.compareTo(bar2)).isLessThan(0); - assertThat(none.compareTo(bar2)).isLessThan(0); - } - - @Test - void test_parse_getComment(){ - - assertThat(MigrationVersion.parse("1.1.1_2__Foo").comment()).isEqualTo("Foo"); - assertThat(MigrationVersion.parse("1.1.1.2__junk").comment()).isEqualTo("junk"); - assertThat(MigrationVersion.parse("1.1_1.2_foo").comment()).isEqualTo(""); - assertThat(MigrationVersion.parse("1.1_1.2_d").comment()).isEqualTo(""); - assertThat(MigrationVersion.parse("1.1_1.2_").comment()).isEqualTo(""); - assertThat(MigrationVersion.parse("1.1_1.2").comment()).isEqualTo(""); - } - - @Test - void test_nextVersion_expect_preserveUnderscores() { - - assertThat(MigrationVersion.parse("2").nextVersion()).isEqualTo("3"); - assertThat(MigrationVersion.parse("1.0").nextVersion()).isEqualTo("1.1"); - assertThat(MigrationVersion.parse("2.0.b34").nextVersion()).isEqualTo("2.1"); - assertThat(MigrationVersion.parse("1.1.1_2__Foo").nextVersion()).isEqualTo("1.1.1_3"); - assertThat(MigrationVersion.parse("1.1.1.2_junk").nextVersion()).isEqualTo("1.1.1.3"); - assertThat(MigrationVersion.parse("1_2.3_4__Foo").nextVersion()).isEqualTo("1_2.3_5"); - assertThat(MigrationVersion.parse("1_2.3_4_").nextVersion()).isEqualTo("1_2.3_5"); - assertThat(MigrationVersion.parse("1_2_3_4__Foo").nextVersion()).isEqualTo("1_2_3_5"); - } - - @Test - void test_normalised_expect_periods() { - - assertThat(MigrationVersion.parse("2").normalised()).isEqualTo("2"); - assertThat(MigrationVersion.parse("1.0").normalised()).isEqualTo("1.0"); - assertThat(MigrationVersion.parse("2.0.b34").normalised()).isEqualTo("2.0"); - assertThat(MigrationVersion.parse("1.1.1_2__Foo").normalised()).isEqualTo("1.1.1.2"); - assertThat(MigrationVersion.parse("1.1.1.2_junk").normalised()).isEqualTo("1.1.1.2"); - assertThat(MigrationVersion.parse("1_2.3_4__Foo").normalised()).isEqualTo("1.2.3.4"); - assertThat(MigrationVersion.parse("1_2.3_4_").normalised()).isEqualTo("1.2.3.4"); - assertThat(MigrationVersion.parse("1_2_3_4__Foo").normalised()).isEqualTo("1.2.3.4"); - } - - @Test - void test_compareTo_isEqual() { - - MigrationVersion v0 = MigrationVersion.parse("1.1.1_2__Foo"); - MigrationVersion v1 = MigrationVersion.parse("1.1.1.2_junk"); - MigrationVersion v2 = MigrationVersion.parse("1.1_1.2_foo"); - MigrationVersion v3 = MigrationVersion.parse("1.1_1.2__foo"); - - MigrationVersion v4 = MigrationVersion.parse("1.1_1.2"); - - assertThat(v0.compareTo(v1)).isEqualTo(0); - assertThat(v1.compareTo(v0)).isEqualTo(0); - assertThat(v1.compareTo(v2)).isEqualTo(0); - - assertThat(v0.compareTo(v3)).isEqualTo(0); - assertThat(v3.compareTo(v0)).isEqualTo(0); - - assertThat(v4.compareTo(v2)).isEqualTo(0); - } - - @Test - void test_compareTo() { - - MigrationVersion v0 = MigrationVersion.parse("1.1.1.1_junk"); - MigrationVersion v1 = MigrationVersion.parse("1.1.1.2_junk"); - MigrationVersion v2 = MigrationVersion.parse("1.1_1.3_junk"); - MigrationVersion v3 = MigrationVersion.parse("1.2_1.2_junk"); - MigrationVersion v4 = MigrationVersion.parse("2.1_1.2_junk"); - - assertThat(v1.compareTo(v0)).isEqualTo(1); - - assertThat(v1.compareTo(v2)).isEqualTo(-1); - assertThat(v1.compareTo(v3)).isEqualTo(-1); - assertThat(v1.compareTo(v4)).isEqualTo(-1); - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java b/ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java deleted file mode 100644 index c23dbc7..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/ServiceLoaderMigration.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.ebean.migration; - -import java.sql.Connection; - -/** - * @author Roland Praml, FOCONIS AG - */ -public class ServiceLoaderMigration implements JdbcMigration { - - @Override - public String getName() { - return "1.4.1__serviceLoaded"; - } - - @Override - public void migrate(MigrationContext context) { - - } - - @Override - public boolean matches(MigrationContext context) { - return "dbmig".equals(context.migrationPath()); - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java new file mode 100644 index 0000000..0cb690b --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java @@ -0,0 +1,51 @@ +package io.ebean.migration.it; + +import io.ebean.DB; +import io.ebean.Database; +import io.ebean.DatabaseFactory; +import io.ebean.config.DatabaseConfig; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationRunner; +import org.migration.model.M3; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class EbeanMigrationTest { + + @Test + public void testEbeanServerJdbcMig() { + + // NOTE: This can be done by AutoMigration (or MigrationPlugin) later + MigrationConfig config = new MigrationConfig(); + Database db = DB.getDefault(); + config.setName(db.name()); + config.load(db.pluginApi().config().getProperties()); + new MigrationRunner(config).run(db); + + + M3 m3 = DB.find(M3.class).findOne(); + assertThat(m3.getId()).isEqualTo(1); + assertThat(m3.getAcol()).isEqualTo("Hello Migration"); + + } + + @Test + public void testWithRunner() { + + // NOTE: This can be done by AutoMigration (or MigrationPlugin) later + DatabaseConfig dbCfg = new DatabaseConfig(); + dbCfg.setName("h2"); + dbCfg.loadFromProperties(); + dbCfg.setRunMigration(true); + DatabaseFactory.create(dbCfg); + + M3 m3 = DB.find(M3.class).findOne(); + assertThat(m3.getId()).isEqualTo(1); + assertThat(m3.getAcol()).isEqualTo("text with ; sign"); + + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java new file mode 100644 index 0000000..1da7c14 --- /dev/null +++ b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java @@ -0,0 +1,55 @@ +package io.ebean.migration.it; + +import io.ebean.Database; +import io.ebean.Transaction; +import io.ebean.TxScope; +import io.ebean.migration.JdbcMigration; +import io.ebean.migration.MigrationContext; +import io.ebeaninternal.api.ScopeTrans; +import io.ebeaninternal.api.ScopedTransaction; +import io.ebeaninternal.api.SpiTransaction; +import io.ebeaninternal.server.core.DefaultServer; +import io.ebeaninternal.server.transaction.ExternalJdbcTransaction; +import io.ebeaninternal.server.transaction.TransactionManager; +import jakarta.persistence.PersistenceException; +import org.migration.model.M3; + +import java.sql.Connection; + +/** + * Sample migration. + * + * @author Roland Praml, FOCONIS AG + */ +public class V1_2_1__test implements JdbcMigration { + + + @Override + public void migrate(MigrationContext context) { + Database db = context.database(); + try (Transaction txn = beginExternalTransaction(context.database(), context.connection())) { + + + M3 m3 = db.find(M3.class).findOne(); + m3.setAcol("Hello Migration"); + db.save(m3); + } + } + + private Transaction beginExternalTransaction(Database database, Connection connection) { + DefaultServer defaultServer = (DefaultServer) database; + TransactionManager transactionManager = (io.ebeaninternal.server.transaction.TransactionManager) defaultServer.transactionManager(); + ExternalJdbcTransaction txn = new ExternalJdbcTransaction(true, connection, transactionManager) { + @Override + public void end() throws PersistenceException { + transactionManager.externalRemoveTransaction(); + } + }; + return transactionManager.externalBeginTransaction(txn, TxScope.required()); + } + + @Override + public String toString() { + return "Dummy jdbc migration"; + } +} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java deleted file mode 100644 index 4010b94..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/ChecksumTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.ebean.migration.runner; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; - -public class ChecksumTest { - - @Test - void test_calculate() { - - int checkFoo = Checksum.calculate("foo"); - - assertThat(Checksum.calculate("foo")).isEqualTo(checkFoo); - assertThat(Checksum.calculate("Foo")).isNotEqualTo(checkFoo); - } - -} \ No newline at end of file diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java deleted file mode 100644 index 552c07c..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/DbNameUtilTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.migration.MigrationConfig; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; -import java.sql.SQLException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DbNameUtilTest { - - /** - * Run manually against Postgres database. - */ - @Disabled - @Test - public void normalise_when_realPostgres() throws SQLException { - - MigrationConfig config = createConfig(); - // assumes DB unit exists on our local postgres database - config.setDbUrl("jdbc:postgresql://127.0.0.1:5432/unit"); - - try (Connection connection = config.createConnection()) { - String platformName = DbNameUtil.normalise(connection); - - assertThat(platformName).isEqualTo("postgres"); - } catch (SQLException e) { - throw e; - } - } - - /** - * Run manually against cockroach database. - */ - @Disabled - @Test - public void normalise_when_cockroach() throws SQLException { - - MigrationConfig config = createConfig(); - // assumes DB unit exists on our local cockroach database - config.setDbUrl("jdbc:postgresql://127.0.0.1:26257/unit"); - - try (Connection connection = config.createConnection()) { - String platformName = DbNameUtil.normalise(connection); - assertThat(platformName).isEqualTo("cockroach"); - } catch (SQLException e) { - throw e; - } - } - - /** - * Assumes a DB user unit exists on the databases. - */ - private MigrationConfig createConfig() { - MigrationConfig config = new MigrationConfig(); - config.setDbUsername("unit"); - config.setDbPassword("unit"); - return config; - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java deleted file mode 100644 index f88592b..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationEarlyModeTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package io.ebean.migration.runner; - -import io.avaje.applog.AppLog; -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationRunner; -import io.ebean.test.containers.PostgresContainer; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.Map; - -import static java.lang.System.Logger.Level.INFO; -import static org.assertj.core.api.Assertions.fail; - -class MigrationEarlyModeTest { - - private static final System.Logger log = AppLog.getLogger(MigrationEarlyModeTest.class); - - String un = "mig_early"; - String pw = "test"; - - private static PostgresContainer createPostgres() { - return PostgresContainer.builder("15") - .port(9823) - .containerName("pg15") - .user("mig_early") - .dbName("mig_early") - .build(); - } - - @Test - void testEarlyMode() { - createPostgres().startWithDropCreate(); - - String url = createPostgres().jdbcUrl(); - DataSourcePool dataSource = dataSource(url); - - MigrationConfig config = new MigrationConfig(); - config.setDbUrl(url); - config.setDbUsername(un); - config.setDbPassword(pw); - config.setMigrationPath("dbmig_postgres_early"); - config.setRunPlaceholderMap(Map.of("my_table_name", "my_table")); - config.setFastMode(true); - - // legacy mode - new MigrationRunner(config).run(dataSource); - - // early mode - log.log(INFO, "-- EARLY MODE -- "); - config.setEarlyChecksumMode(true); - new MigrationRunner(config).run(dataSource); - - log.log(INFO, "-- RE-RUN EARLY MODE -- "); - new MigrationRunner(config).run(dataSource); - - log.log(INFO, "-- LEGACY MODE AGAIN (will auto detect early mode) -- "); - config.setEarlyChecksumMode(false); - new MigrationRunner(config).run(dataSource); - - log.log(INFO, "-- LEGACY MODE with more migrations -- "); - - config.setRunPlaceholderMap(Map.of("my_table_name", "my_table", "other_table_name", "other")); - config.setMigrationPath("dbmig_postgres_early1"); - new MigrationRunner(config).run(dataSource); - - log.log(INFO, "-- EARLY MODE again -- "); - config.setEarlyChecksumMode(true); - new MigrationRunner(config).run(dataSource); - - } - - private DataSourcePool dataSource(String url) { - DataSourceConfig dataSourceConfig = new DataSourceConfig() - .setUrl(url) - .setUsername(un) - .setPassword(pw); - return DataSourceFactory.create("mig_early", dataSourceConfig); - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java deleted file mode 100644 index d6054c8..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationMetaRowTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.ebean.migration.runner; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - - -class MigrationMetaRowTest { - - @Test - void testSelectSql() { - - final MigrationPlatform sqlServer = new MigrationPlatform.SqlServer(); - String sql = sqlServer.sqlSelectForReading("someTable"); - assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable with (updlock) order by id"); - - final MigrationPlatform noLocking = new MigrationPlatform.NoLocking(); - sql = noLocking.sqlSelectForReading("someTable"); - assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable order by id"); - - final MigrationPlatform postgres = new MigrationPlatform.Postgres(); - sql = postgres.sqlSelectForReading("someTable"); - assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable order by id for update"); - - final MigrationPlatform defaultPlatform = new MigrationPlatform(); - sql = defaultPlatform.sqlSelectForReading("someTable"); - assertThat(sql).isEqualTo("select id, mtype, mversion, mchecksum from someTable order by id for update"); - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java deleted file mode 100644 index d5e1760..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationPlatformTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.ddlrunner.DdlDetect; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class MigrationPlatformTest { - - final DdlDetect pg = DdlDetect.POSTGRES; - - @Test - public void transaction_false() { - assertFalse(pg.transactional("create index concurrently foo")); - assertFalse(pg.transactional("drop index concurrently foo")); - assertFalse(pg.transactional("CREATE INDEX CONCURRENTLY foo")); - assertFalse(pg.transactional("DROP INDEX CONCURRENTLY foo")); - } - - @Test - public void transaction_true() { - assertTrue(pg.transactional("create index foo")); - assertTrue(pg.transactional("drop index foo")); - assertTrue(pg.transactional("CREATE INDEX foo")); - assertTrue(pg.transactional("DROP INDEX foo")); - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java deleted file mode 100644 index 82f9cdf..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationSchemaTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.migration.MigrationConfig; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; - -public class MigrationSchemaTest { - - @Test - void testCreateAndSetIfNeeded() throws Exception { - - MigrationConfig config = createMigrationConfig(); - config.setDbSchema("SOME_NEW_SCHEMA"); - config.setCreateSchemaIfNotExists(true); - - Connection connection = config.createConnection(); - - MigrationSchema.createIfNeeded(config, connection); - } - - private MigrationConfig createMigrationConfig() { - - MigrationConfig config = new MigrationConfig(); - config.setDbUsername("sa"); - config.setDbPassword(""); - config.setDbUrl("jdbc:h2:mem:db1"); - return config; - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java deleted file mode 100644 index 5cd89bb..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java +++ /dev/null @@ -1,159 +0,0 @@ -package io.ebean.migration.runner; - -import dbmig.V1_2_1__test; -import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationRunner; -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourcePool; -import io.ebean.datasource.DataSourceFactory; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrationTable1Test { - - private static MigrationConfig config; - private static DataSourcePool dataSource; - private MigrationPlatform platform = new MigrationPlatform(); - - @BeforeEach - public void setUp() { - config = new MigrationConfig(); - config.setDbUsername("sa"); - config.setDbPassword(""); - config.setDbUrl("jdbc:h2:mem:db2"); - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setUrl("jdbc:h2:mem:db2"); - dataSourceConfig.setUsername("sa"); - dataSourceConfig.setPassword(""); - dataSource = DataSourceFactory.create("test", dataSourceConfig); - } - - @AfterEach - public void shutdown() { - dataSource.shutdown(); - } - - - private MigrationTable migrationTable(Connection conn) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); - return new MigrationTable(fc, false); - } - - @Test - public void testMigrationTableBase() throws Exception { - - config.setMigrationPath("dbmig"); - config.setJdbcMigrations(List.of(new V1_2_1__test())); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - try (Connection conn = dataSource.getConnection()) { - MigrationTable table = migrationTable(conn); - table.createIfNeededAndLock(); - assertThat(table.versions()).containsExactly("hello", "1.1", "1.2", "1.2.1", "m2_view"); - - List rawVersions = new ArrayList<>(); - try (PreparedStatement stmt = conn.prepareStatement("select mversion from db_migration order by id")) { - try (ResultSet rset = stmt.executeQuery()) { - while (rset.next()) { - rawVersions.add(rset.getString(1)); - } - } - } - assertThat(rawVersions).containsExactly("0", "hello", "1.1", "1.2", "1.2.1", "m2_view"); - table.unlockMigrationTable(); - conn.rollback(); - } - } - - - @Test - public void testMigrationTableRepeatableOk() throws Exception { - - config.setMigrationPath("tabletest1"); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - try (Connection conn = dataSource.getConnection()) { - MigrationTable table = migrationTable(conn); - table.createIfNeededAndLock(); - assertThat(table.versions()).containsExactly("1.1"); - table.unlockMigrationTable(); - conn.rollback(); - } - - config.setMigrationPath("tabletest2"); - - runner = new MigrationRunner(config); - runner.run(dataSource); - - try (Connection conn = dataSource.getConnection()) { - MigrationTable table = migrationTable(conn); - table.createIfNeededAndLock(); - assertThat(table.versions()).containsExactly("1.1", "1.2", "m2_view"); - table.unlockMigrationTable(); - conn.rollback(); - } - } - - @Test - public void testMigrationTableRepeatableFail() throws Exception { - - config.setMigrationPath("tabletest1"); - config.setAllowErrorInRepeatable(true); - - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - - try (Connection conn = dataSource.getConnection()) { - MigrationTable table = migrationTable(conn); - table.createIfNeededAndLock(); - assertThat(table.versions()).containsExactly("1.1"); - table.unlockMigrationTable(); - conn.rollback(); - } - - // now execute corrupt migration - config.setMigrationPath("tabletest2-err"); - - MigrationRunner runner2 = new MigrationRunner(config); - - runner2.run(dataSource); - - try (Connection conn = dataSource.getConnection()) { - - List m3Content = new ArrayList<>(); - try ( - // the next statement will fail, if "1.3__add_m3" is not executed - PreparedStatement stmt = conn.prepareStatement("select * from m3"); - ResultSet result = stmt.executeQuery()) { - while (result.next()) { - m3Content.add(result.getString(2)); - } - } - - // the next statement will fail, if "1.3__add_m3" is not executed - // - // BUT: currently, we will fail here. that means, the 1.3 script creates the table - // but does not insert the data. (there was not commit) This might be also a bug in H2 - assertThat(m3Content).contains("text with ; sign"); - - // we expect, that 1.1 and 1.2 is executed (but not the R__ script) - MigrationTable table = migrationTable(conn); - table.createIfNeededAndLock(); - assertThat(table.versions()).containsExactly("1.1", "1.2"); - conn.rollback(); - } - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java deleted file mode 100644 index f8130ce..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationVersion; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class MigrationTable2Test { - - - private static MigrationTable migrationTable(MigrationConfig config) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, null, null), new MigrationPlatform()); - return new MigrationTable(fc, false); - } - - @Test - void testCreateTableDdl() throws Exception { - - MigrationConfig config = new MigrationConfig(); - config.setDbSchema("foo"); - - MigrationTable mt = migrationTable(config); - String tableSql = mt.createTableDdl(); - - assertThat(tableSql).contains("create table foo.db_migration "); - assertThat(tableSql).contains("constraint pk_db_migration primary key (id)"); - } - - @Test - void testCreateTableDdl_sqlserver() throws Exception { - - MigrationConfig config = new MigrationConfig(); - config.setDbSchema("bar"); - config.setPlatform(DbPlatformNames.SQLSERVER); - - MigrationTable mt = migrationTable(config); - String tableSql = mt.createTableDdl(); - - assertThat(tableSql).contains("datetime2 "); - assertThat(tableSql).contains("create table bar.db_migration "); - assertThat(tableSql).contains("constraint pk_db_migration primary key (id)"); - } - - @Test - void test_skipMigration_Repeatable() throws Exception { - - MigrationConfig config = new MigrationConfig(); - - LocalMigrationResource local = local("R__hello"); - MigrationMetaRow existing = new MigrationMetaRow(12, "R", "", "comment", 42, null, null, 0); - - MigrationTable mt = migrationTable(config); - // checksum different - no skip - assertFalse(mt.skipMigration(100, 100, local, existing)); - // checksum same - skip - assertTrue(mt.skipMigration(42, 42, local, existing)); - } - - @Test - void test_skipMigration_skipChecksum() throws Exception { - - MigrationConfig config = new MigrationConfig(); - config.setSkipChecksum(true); - - MigrationTable mt = migrationTable(config); - - // skip regardless of checksum difference - LocalMigrationResource local = local("R__hello"); - MigrationMetaRow existing = new MigrationMetaRow(12, "R", "", "comment", 42, null, null, 0); - - // repeatable checksum mismatch - assertFalse(mt.skipMigration(44, 44, local, existing)); - - // repeatable match checksum - assertTrue(mt.skipMigration(42, 42, local, existing)); - // assertTrue(mt.skipMigration(99, 42, local, existing)); - - LocalMigrationResource localVer = local("V1__hello"); - MigrationMetaRow localExisting = new MigrationMetaRow(12, "V", "1", "comment", 42, null, null, 0); - - // re-run on checksum mismatch and skipChecksum - assertFalse(mt.skipMigration(44, 44, localVer, localExisting)); - - // match checksum so skip - assertTrue(mt.skipMigration(42, 42, localVer, localExisting)); - } - - private LocalMigrationResource local(String raw) { - return new LocalDdlMigrationResource(MigrationVersion.parse(raw), "loc", null); - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java deleted file mode 100644 index e7e1235..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java +++ /dev/null @@ -1,237 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationRunner; -import io.ebean.test.containers.*; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MigrationTableAsyncTest { - - private static MigrationConfig config; - private static DataSourcePool dataSource; - - @BeforeEach - public void setUp() { - config = new MigrationConfig(); - config.setMetaTable("migtable"); - config.setMigrationPath("dbmig"); - } - - @AfterEach - public void shutdown() { - dataSource.shutdown(); - } - - @Disabled - @Test - public void testDb2() throws Exception { - // Note: Holding any lock during "reorg table" does not work - // (checked row lock and 'lock table x in exclusive mode') - // as soon as reorg table is executed, all locks held by the current - // connection are dropped - // See comment in 1.1__initial.sql - - Db2Container container = Db2Container.builder("latest") - .port(50055) - .containerName("mig_async_db2") - .dbName("mig_test") - .user("test_ebean") - .password("test") - .build(); - - container.startWithDropCreate(); - - config.setMigrationPath("dbmig"); - config.setDbUsername("test_ebean"); - config.setDbPassword("test"); - config.setDbUrl(container.jdbcUrl()); - runTest(false); - runTest(true); - } - - @Disabled - @Test - public void testOracle() throws Exception { - // init oracle docker container - OracleContainer container = OracleContainer.builder("latest") - .dbName("XE") - .image("oracleinanutshell/oracle-xe-11g:latest") - .user("test_ebean") - .password("test") - .build(); - container.startWithDropCreate(); - - config.setMigrationPath("dbmig_oracle"); - config.setDbUsername("test_ebean"); - config.setDbPassword("test"); - config.setDbUrl(container.jdbcUrl()); - runTest(false); - runTest(true); - } - - @Test - public void testMySqlDb() throws Exception { - // init mysql docker container - MySqlContainer container = MySqlContainer.builder("8.0") - .port(14307) - .containerName("mig_async_mysql") - .dbName("test_ebean") - .user("test_ebean") - .password("test") - .build(); - - container.startWithDropCreate(); - - config.setMigrationPath("dbmig"); - config.setDbUsername("test_ebean"); - config.setDbPassword("test"); - config.setDbUrl("jdbc:mysql://localhost:14307/test_ebean"); - runTest(false); - runTest(true); - } - - @Test - public void testMariaDb() throws Exception { - // init mariadb docker container - MariaDBContainer container = MariaDBContainer.builder("10") - .port(14308) - .containerName("mig_async_mariadb") - .dbName("test_ebean") - .user("test_ebean") - .password("test") - .build(); - - container.startWithDropCreate(); - - config.setMigrationPath("dbmig"); - config.setDbUsername("test_ebean"); - config.setDbPassword("test"); - config.setDbUrl("jdbc:mariadb://localhost:14308/test_ebean"); - runTest(false); - runTest(true); - } - - //@Disabled - @Test - public void testSqlServer() throws Exception { - // init sqlserver docker container - SqlServerContainer container = SqlServerContainer.builder("2017-GA-ubuntu") - .port(9435) - .containerName("mig_async_sqlserver") - .dbName("test_ebean") - .user("test_ebean") - .build(); - //conf.setPassword("SqlS3rv#r"); - - container.startWithDropCreate(); - - config.setMigrationPath("dbmig_sqlserver"); - config.setDbUsername("test_ebean"); - config.setDbPassword("SqlS3rv#r"); - config.setDbUrl("jdbc:sqlserver://localhost:9435;databaseName=test_ebean;sendTimeAsDateTime=false"); - runTest(true); - runTest(false); - } - - - /** - * H2 using logical lock mechanism. - */ - @Test - public void testH2() throws Exception { - // thread A looses the lock while thread B runs the migrations. - config.setMigrationPath("dbmig"); - config.setDbUsername("sa"); - config.setDbPassword(""); - config.setDbUrl("jdbc:h2:mem:dbAsync;LOCK_TIMEOUT=100000"); - runTest(false); - runTest(true); - } - - private void runTest(boolean withExisting) throws SQLException, InterruptedException, ExecutionException, IOException { - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setUrl(config.getDbUrl()); - dataSourceConfig.setUsername(config.getDbUsername()); - dataSourceConfig.setPassword(config.getDbPassword()); - dataSource = DataSourceFactory.create("test", dataSourceConfig); - dropTable("migtable"); - dropTable("m1"); - dropTable("m2"); - dropTable("m3"); - - if (withExisting) { - // create empty migration table - try (Connection conn = dataSource.getConnection()) { - String derivedPlatformName = DbNameUtil.normalise(conn); - - config.setPlatform(derivedPlatformName); - MigrationPlatform platform = DbNameUtil.platform(derivedPlatformName); - MigrationTable table = migrationTable(platform, conn); - table.createIfNeededAndLock(); - table.unlockMigrationTable(); - conn.commit(); - } - } - - ExecutorService exec = Executors.newFixedThreadPool(8); - List> futures = new ArrayList<>(); - for (int i = 0; i < 2; i++) { - Future future = exec.submit(this::runMigration); - futures.add(future); - } - for (Future future : futures) { - assertThat(future.get()).isEqualTo("OK"); - } - } - - private static MigrationTable migrationTable(MigrationPlatform platform, Connection connection) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection, null), platform); - return new MigrationTable(fc, false); - } - - private void dropTable(String tableName) throws SQLException { - try (Connection conn = dataSource.getConnection(); - Statement stmt = conn.createStatement()) { - String dbProductName = conn.getMetaData().getDatabaseProductName().toLowerCase(); - if (dbProductName.contains("db2")) { - stmt.execute("begin\n" - + "if exists (select tabname from syscat.tables where lcase(tabname) = '" + tableName + "' and tabschema = current_schema) then\n" - + " prepare stmt from 'drop table " + tableName + "';\n" - + " execute stmt;\n" - + "end if;\n" - + "end"); - } else if (dbProductName.contains("oracle")) { - // do nothing, re-created via container.startWithDropCreate(); - } else { - stmt.execute("drop view if exists " + tableName + "_vw"); - stmt.execute("drop table if exists " + tableName); - } - conn.commit(); - } - } - - String runMigration() { - MigrationRunner runner = new MigrationRunner(config); - runner.run(dataSource); - return "OK"; - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java deleted file mode 100644 index 37b4167..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourceFactory; -import io.ebean.datasource.DataSourcePool; -import io.ebean.migration.MigrationConfig; -import io.ebean.test.containers.PostgresContainer; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import static org.assertj.core.api.Assertions.fail; - -class MigrationTableCreateTableRaceTest { - - private final MigrationPlatform platform = new MigrationPlatform(); - - private static PostgresContainer createPostgres() { - PostgresContainer.Builder builder = PostgresContainer.builder("15") - .port(9823); - builder.containerName("pg15"); - builder.user("mig_create_test"); - builder.dbName("mig_create_test"); - return builder.build(); - } - - // @Disabled - @Test - void testRaceCondition_expect_loserOfCreateTableCanPerformTableExistsCheck() throws SQLException, IOException { - PostgresContainer postgresContainer = createPostgres(); - postgresContainer.start(); - - String url = postgresContainer.jdbcUrl(); - String un = "mig_create_test"; - String pw = "test"; - - MigrationConfig config = new MigrationConfig(); - config.setDbUrl(url); - config.setDbUsername(un); - config.setDbPassword(pw); - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setUrl(url); - dataSourceConfig.setUsername(un); - dataSourceConfig.setPassword(pw); - DataSourcePool dataSource = DataSourceFactory.create("mig_create_test", dataSourceConfig); - - try (Connection conn = dataSource.getConnection()) { - dropTable(conn); - - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); - MigrationTable table = new MigrationTable(fc, false); - table.createTable(); - try { - // simulate losing the race, this createTable() will fail as the table exists - table.createTable(); - } catch (SQLException e) { - // need rollback to allow further use of the connection - if (!table.tableExists()) { - fail("Table should exist"); - } - } - // cleanup - dropTable(conn); - } - } - - private static void dropTable(Connection conn) throws SQLException { - try (PreparedStatement stmt = conn.prepareStatement("drop table if exists db_migration")) { - stmt.executeUpdate(); - } - } - -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java b/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java deleted file mode 100644 index 4cd3907..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.ebean.migration.runner; - -import io.ebean.migration.MigrationConfig; -import io.ebean.datasource.DataSourceConfig; -import io.ebean.datasource.DataSourcePool; -import io.ebean.datasource.DataSourceFactory; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.sql.Connection; - -public class MigrationTableTestDb2 { - - private static MigrationConfig config; - private static DataSourcePool dataSource; - private final MigrationPlatform platform = new MigrationPlatform(); - - @BeforeEach - public void setUp() { - config = new MigrationConfig(); - config.setDbUsername("unit"); - config.setDbPassword("test"); - config.setMetaTable("bla"); - config.setDbUrl("jdbc:db2://localhost:50000/unit:currentSchema=Sch_2;"); // Sch2 will work - - DataSourceConfig dataSourceConfig = new DataSourceConfig(); - dataSourceConfig.setUrl("jdbc:db2://localhost:50000/unit:currentSchema=Sch_2;"); - dataSourceConfig.setUsername("unit"); - dataSourceConfig.setPassword("test"); - dataSource = DataSourceFactory.create("test", dataSourceConfig); - } - - @AfterEach - public void shutdown() { - dataSource.shutdown(); - } - - @Disabled // run test manually - @Test - public void testMigrationTableBase() throws Exception { - - config.setMigrationPath("dbmig"); - - try (Connection conn = dataSource.getConnection()) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); - MigrationTable table = new MigrationTable(fc, false); - table.createIfNeededAndLock(); - table.unlockMigrationTable(); - table.createIfNeededAndLock(); - table.unlockMigrationTable(); - conn.commit(); - } - } -} diff --git a/ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration b/ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration deleted file mode 100644 index 6615228..0000000 --- a/ebean-migration-it/src/test/resources/META-INF/services/io.ebean.migration.JdbcMigration +++ /dev/null @@ -1 +0,0 @@ -io.ebean.migration.ServiceLoaderMigration diff --git a/ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/dbmig-roach/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql deleted file mode 100644 index 3518305..0000000 --- a/ebean-migration-it/src/test/resources/dbmig-roach/1.2__add_m3.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m3 (id integer, acol varchar(20), bcol timestamp); - -alter table m1 add column addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql deleted file mode 100644 index 1a92845..0000000 --- a/ebean-migration-it/src/test/resources/dbmig-roach/R__m2_view.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop view if exists m2_vw; -create view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql deleted file mode 100644 index c3ed0f1..0000000 --- a/ebean-migration-it/src/test/resources/dbmig2/1.3__m4.sql +++ /dev/null @@ -1 +0,0 @@ -create table m4 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig3/I__hello.sql b/ebean-migration-it/src/test/resources/dbmig3/I__hello.sql deleted file mode 100644 index a36d833..0000000 --- a/ebean-migration-it/src/test/resources/dbmig3/I__hello.sql +++ /dev/null @@ -1 +0,0 @@ --- do nothing again diff --git a/ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql deleted file mode 100644 index f6ca6ef..0000000 --- a/ebean-migration-it/src/test/resources/dbmig3/R__m2_view.sql +++ /dev/null @@ -1 +0,0 @@ -create or replace view m2_vw as select id, acol, bcol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql deleted file mode 100644 index c627009..0000000 --- a/ebean-migration-it/src/test/resources/dbmig4/1.1__initial.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m1 (id integer, acol varchar(20)); --- Check with DB2: --- call sysproc.admin_cmd('reorg table m1'); -create table m2 (id integer, acol varchar(20), bcol timestamp); - diff --git a/ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql deleted file mode 100644 index 5b16f78..0000000 --- a/ebean-migration-it/src/test/resources/dbmig4/1.2__add_m3.sql +++ /dev/null @@ -1,6 +0,0 @@ - -create table m3 (id integer, acol varchar(20), bcol timestamp); - -alter table m1 add column addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql deleted file mode 100644 index c3ed0f1..0000000 --- a/ebean-migration-it/src/test/resources/dbmig4/1.3__m4.sql +++ /dev/null @@ -1 +0,0 @@ -create table m4 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql deleted file mode 100644 index e8cb9a7..0000000 --- a/ebean-migration-it/src/test/resources/dbmig4/R__m2_view.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop view m2_vw; -create view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql deleted file mode 100644 index c627009..0000000 --- a/ebean-migration-it/src/test/resources/dbmig5_base/1.1__initial.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m1 (id integer, acol varchar(20)); --- Check with DB2: --- call sysproc.admin_cmd('reorg table m1'); -create table m2 (id integer, acol varchar(20), bcol timestamp); - diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql deleted file mode 100644 index 5b16f78..0000000 --- a/ebean-migration-it/src/test/resources/dbmig5_base/1.2__add_m3.sql +++ /dev/null @@ -1,6 +0,0 @@ - -create table m3 (id integer, acol varchar(20), bcol timestamp); - -alter table m1 add column addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql deleted file mode 100644 index c3ed0f1..0000000 --- a/ebean-migration-it/src/test/resources/dbmig5_base/1.3__m4.sql +++ /dev/null @@ -1 +0,0 @@ -create table m4 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql b/ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql deleted file mode 100644 index 8e6b5aa..0000000 --- a/ebean-migration-it/src/test/resources/dbmig5_base/I__some_i.sql +++ /dev/null @@ -1 +0,0 @@ -create table i_tab (icol integer); diff --git a/ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql b/ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql deleted file mode 100644 index 3eede6b..0000000 --- a/ebean-migration-it/src/test/resources/dbmig5_base/R__some_r.sql +++ /dev/null @@ -1 +0,0 @@ -create table r_tab (rcol integer); diff --git a/ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql b/ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql deleted file mode 100644 index b479b18..0000000 --- a/ebean-migration-it/src/test/resources/dbmig5_init/1.3__m4.sql +++ /dev/null @@ -1,9 +0,0 @@ -create table m1 (id integer, acol varchar(20), addcol varchar(10)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); - -create table m3 (id integer, acol varchar(20), bcol timestamp); - -create table m4 (id integer, acol varchar(20), bcol timestamp); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql b/ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql deleted file mode 100644 index b479b18..0000000 --- a/ebean-migration-it/src/test/resources/dbmig6_init/1.0__m4.sql +++ /dev/null @@ -1,9 +0,0 @@ -create table m1 (id integer, acol varchar(20), addcol varchar(10)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); - -create table m3 (id integer, acol varchar(20), bcol timestamp); - -create table m4 (id integer, acol varchar(20), bcol timestamp); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_autorun/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql deleted file mode 100644 index c4aaa00..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_basic/1.1__initial.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table m1 -( - id integer, - acol varchar(20) -); - -create table m2 -( - id integer, - acol varchar(20), - bcol timestamp -); diff --git a/ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql deleted file mode 100644 index 0b975c7..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_basic/1.2__add_m3.sql +++ /dev/null @@ -1,9 +0,0 @@ -create table m3 -( - id integer, - acol varchar(20), - bcol timestamp -); - -insert into m3 (id, acol) -VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql deleted file mode 100644 index 7d68a2e..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_error/1.1__initial.sql +++ /dev/null @@ -1 +0,0 @@ -create table m1 (id integer, acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql b/ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql deleted file mode 100644 index 3bedec8..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_error/1.2__insert.sql +++ /dev/null @@ -1 +0,0 @@ -insert into m1 (id, acol) values (1,'hi'); diff --git a/ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql b/ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql deleted file mode 100644 index 8679eef..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_error/1.3__error.sql +++ /dev/null @@ -1 +0,0 @@ -not valid sql diff --git a/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql b/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql deleted file mode 100644 index 8686f99..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-create-all.sql +++ /dev/null @@ -1,4730 +0,0 @@ --- Generated by ebean unknown at 2019-07-25T07:02:24.426Z --- init script create procs --- 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 -$$ -create table asimple_bean ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_asimple_bean primary key (id) -); - -create table bar ( - bar_type varchar(31) not null, - bar_id integer auto_increment not null, - foo_id integer not null, - version integer not null, - constraint pk_bar primary key (bar_id) -); - -create table block ( - case_type integer(31) not null, - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - notes varchar(255), - constraint pk_block primary key (id) -); - -create table oto_account ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_oto_account primary key (id) -); - -create table acl ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_acl primary key (id) -); - -create table acl_container_relation ( - id bigint auto_increment not null, - container_id bigint not null, - acl_entry_id bigint not null, - constraint pk_acl_container_relation primary key (id) -); - -create table addr ( - id bigint auto_increment not null, - employee_id bigint, - name varchar(255), - address_line1 varchar(255), - address_line2 varchar(255), - city varchar(255), - version bigint not null, - constraint pk_addr primary key (id) -); - -create table address ( - oid bigint auto_increment not null, - street varchar(255), - version integer not null, - constraint pk_address primary key (oid) -); - -create table o_address ( - id smallint auto_increment not null, - line_1 varchar(100), - line_2 varchar(100), - city varchar(100), - cretime datetime(6), - country_code varchar(2), - updtime datetime(6) not null, - constraint pk_o_address primary key (id) -); - -create table album ( - id bigint auto_increment not null, - name varchar(255), - cover_id bigint, - deleted tinyint(1) default 0 not null, - created_at datetime(6) not null, - last_update datetime(6) not null, - constraint uq_album_cover_id unique (cover_id), - constraint pk_album primary key (id) -); - -create table animal ( - species varchar(255) not null, - id bigint auto_increment not null, - shelter_id bigint, - version bigint not null, - name varchar(255), - registration_number varchar(255), - date_of_birth date, - dog_size varchar(255), - constraint pk_animal primary key (id) -); - -create table animal_shelter ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_animal_shelter primary key (id) -); - -create table article ( - id integer auto_increment not null, - name varchar(255), - author varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_article primary key (id) -); - -create table attribute ( - option_type integer(31) not null, - id integer auto_increment not null, - attribute_holder_id integer, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_attribute primary key (id) -); - -create table attribute_holder ( - id integer auto_increment not null, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_attribute_holder primary key (id) -); - -create table audit_log ( - id bigint auto_increment not null, - description varchar(255), - modified_description varchar(255), - constraint pk_audit_log primary key (id) -); - -create table bbookmark ( - id integer auto_increment not null, - bookmark_reference varchar(255), - user_id integer, - constraint pk_bbookmark primary key (id) -); - -create table bbookmark_org ( - id integer auto_increment not null, - name varchar(255), - constraint pk_bbookmark_org primary key (id) -); - -create table bbookmark_user ( - id integer auto_increment not null, - name varchar(255), - password varchar(255), - email_address varchar(255), - country varchar(255), - org_id integer, - constraint pk_bbookmark_user primary key (id) -); - -create table bsimple_with_gen ( - id integer auto_increment not null, - name varchar(255), - constraint pk_bsimple_with_gen primary key (id) -); - -create table bsite ( - id varchar(40) not null, - name varchar(255), - constraint pk_bsite primary key (id) -); - -create table bsite_user_a ( - site_id varchar(40) not null, - user_id varchar(40) not null, - access_level integer, - version bigint not null, - constraint pk_bsite_user_a primary key (site_id,user_id) -); - -create table bsite_user_b ( - site varchar(40) not null, - usr varchar(40) not null, - access_level integer, - constraint pk_bsite_user_b primary key (site,usr) -); - -create table bsite_user_c ( - site_uid varchar(40) not null, - user_uid varchar(40) not null, - access_level integer, - constraint pk_bsite_user_c primary key (site_uid,user_uid) -); - -create table bsite_user_d ( - site_id varchar(40) not null, - user_id varchar(40) not null, - access_level integer, - version bigint not null -); - -create table bsite_user_e ( - site_id varchar(40) not null, - user_id varchar(40) not null, - access_level integer -); - -create table buser ( - id varchar(40) not null, - name varchar(255), - constraint pk_buser primary key (id) -); - -create table bwith_qident ( - id integer auto_increment not null, - `Name` varchar(191), - `CODE` varchar(255), - last_updated datetime(6) not null, - constraint uq_bwith_qident_name unique (`Name`), - constraint pk_bwith_qident primary key (id) -); - -create table basic_draftable_bean ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_basic_draftable_bean primary key (id) -); - -create table basic_draftable_bean_draft ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_basic_draftable_bean_draft primary key (id) -); - -create table basic_joda_entity ( - id bigint auto_increment not null, - name varchar(255), - period varchar(50), - local_date date, - created datetime(6) not null, - updated datetime(6) not null, - version datetime(6) not null, - constraint pk_basic_joda_entity primary key (id) -); - -create table bean_with_time_zone ( - id bigint auto_increment not null, - name varchar(255), - timezone varchar(20), - constraint pk_bean_with_time_zone primary key (id) -); - -create table drel_booking ( - id bigint auto_increment not null, - booking_uid bigint, - agent_invoice bigint, - client_invoice bigint, - version integer not null, - constraint uq_drel_booking_booking_uid unique (booking_uid), - constraint uq_drel_booking_agent_invoice unique (agent_invoice), - constraint uq_drel_booking_client_invoice unique (client_invoice), - constraint pk_drel_booking primary key (id) -); - -create table bw_bean ( - id bigint auto_increment not null, - name varchar(255), - flags integer not null, - version bigint not null, - constraint pk_bw_bean primary key (id) -); - -create table cepcategory ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_cepcategory primary key (id) -); - -create table cepproduct ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_cepproduct primary key (id) -); - -create table cepproduct_category ( - customer_id bigint not null, - address_id bigint not null, - category_id bigint not null, - product_id bigint not null, - priority integer -); - -create table cinh_ref ( - id integer auto_increment not null, - ref_id integer, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_cinh_ref primary key (id) -); - -create table cinh_root ( - dtype varchar(3) not null, - id integer auto_increment not null, - license_number varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - driver varchar(255), - notes varchar(255), - action varchar(255), - constraint pk_cinh_root primary key (id) -); - -create table ckey_assoc ( - id integer auto_increment not null, - assoc_one varchar(255), - constraint pk_ckey_assoc primary key (id) -); - -create table ckey_detail ( - id integer auto_increment not null, - something varchar(255), - one_key integer, - two_key varchar(127), - constraint pk_ckey_detail primary key (id) -); - -create table ckey_parent ( - one_key integer not null, - two_key varchar(127) not null, - name varchar(255), - assoc_id integer, - version integer not null, - constraint pk_ckey_parent primary key (one_key,two_key) -); - -create table calculation_result ( - id integer auto_increment not null, - charge double not null, - product_configuration_id integer, - group_configuration_id integer, - constraint pk_calculation_result primary key (id) -); - -create table cao_bean ( - x_cust_id integer not null, - x_type_id integer not null, - description varchar(255), - version bigint not null, - constraint pk_cao_bean primary key (x_cust_id,x_type_id) -); - -create table sp_car_car ( - id bigint auto_increment not null, - name varchar(255), - version integer not null, - constraint pk_sp_car_car primary key (id) -); - -create table sp_car_car_wheels ( - car bigint not null, - wheel bigint not null, - constraint pk_sp_car_car_wheels primary key (car,wheel) -); - -create table sp_car_car_doors ( - car bigint not null, - door bigint not null, - constraint pk_sp_car_car_doors primary key (car,door) -); - -create table sa_car ( - id bigint auto_increment not null, - version integer not null, - constraint pk_sa_car primary key (id) -); - -create table car_accessory ( - id integer auto_increment not null, - name varchar(255), - fuse_id bigint not null, - car_id integer, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_car_accessory primary key (id) -); - -create table car_fuse ( - id bigint auto_increment not null, - location_code varchar(255), - constraint pk_car_fuse primary key (id) -); - -create table category ( - id bigint auto_increment not null, - name varchar(255), - surveyobjectid bigint, - sequence_number integer not null, - constraint pk_category primary key (id) -); - -create table e_save_test_d ( - id bigint auto_increment not null, - parent_id bigint, - test_property tinyint(1) default 0 not null, - version bigint not null, - constraint uq_e_save_test_d_parent_id unique (parent_id), - constraint pk_e_save_test_d primary key (id) -); - -create table child_person ( - identifier integer auto_increment not null, - name varchar(255), - age integer, - some_bean_id integer, - parent_identifier integer, - family_name varchar(255), - address varchar(255), - constraint pk_child_person primary key (identifier) -); - -create table cke_client ( - cod_cpny integer not null, - cod_client varchar(100) not null, - username varchar(100) not null, - notes varchar(255), - constraint pk_cke_client primary key (cod_cpny,cod_client) -); - -create table cke_user ( - username varchar(100) not null, - cod_cpny integer not null, - name varchar(255), - constraint pk_cke_user primary key (username,cod_cpny) -); - -create table class_super ( - dtype varchar(31) not null, - sid bigint auto_increment not null, - constraint pk_class_super primary key (sid) -); - -create table class_super_monkey ( - class_super_sid bigint not null, - monkey_mid bigint not null, - constraint uq_class_super_monkey_mid unique (monkey_mid), - constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) -); - -create table configuration ( - type varchar(21) not null, - id integer auto_increment not null, - name varchar(255), - configurations_id integer, - group_name varchar(255), - product_name varchar(255), - constraint pk_configuration primary key (id) -); - -create table configurations ( - id integer auto_increment not null, - name varchar(255), - constraint pk_configurations primary key (id) -); - -create table contact ( - id integer auto_increment not null, - first_name varchar(127), - last_name varchar(127), - phone varchar(255), - mobile varchar(255), - email varchar(255), - customer_id integer not null, - group_id integer, - cretime datetime(6) not null, - updtime datetime(6) not null, - constraint pk_contact primary key (id) -); - -create table contact_group ( - id integer auto_increment not null, - name varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_contact_group primary key (id) -); - -create table contact_note ( - id integer auto_increment not null, - contact_id integer, - title varchar(255), - note longtext, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_contact_note primary key (id) -); - -create table contract ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_contract primary key (id) -); - -create table contract_costs ( - id bigint auto_increment not null, - status varchar(255), - position_id bigint not null, - constraint pk_contract_costs primary key (id) -); - -create table c_conversation ( - id bigint auto_increment not null, - title varchar(255), - isopen tinyint(1) default 0 not null, - group_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_c_conversation primary key (id) -); - -create table o_country ( - code varchar(2) not null, - name varchar(60), - constraint pk_o_country primary key (code) -); - -create table cover ( - id bigint auto_increment not null, - s3_url varchar(255), - deleted tinyint(1) default 0 not null, - constraint pk_cover primary key (id) -); - -create table o_customer ( - id integer auto_increment not null, - status varchar(1) comment 'status of the customer', - name varchar(40) not null, - smallnote varchar(100) comment 'Short notes regarding the customer', - anniversary date comment 'Join date of the customer', - billing_address_id smallint, - shipping_address_id smallint, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_o_customer primary key (id) -) comment='Holds external customers'; - -create table dcredit ( - id bigint auto_increment not null, - credit varchar(255), - constraint pk_dcredit primary key (id) -); - -create table dcredit_drol ( - dcredit_id bigint not null, - drol_id bigint not null, - constraint pk_dcredit_drol primary key (dcredit_id,drol_id) -); - -create table dexh_entity ( - oid bigint auto_increment not null, - exhange varchar(255), - an_enum_type varchar(255), - last_updated datetime(6) not null, - constraint pk_dexh_entity primary key (oid) -); - -create table dmachine ( - id bigint auto_increment not null, - name varchar(255), - organisation_id bigint, - version bigint not null, - constraint pk_dmachine primary key (id) -); - -create table d_machine_aux_use ( - id bigint auto_increment not null, - machine_id bigint not null, - name varchar(255), - date date, - use_secs bigint not null, - fuel decimal(38), - version bigint not null, - constraint pk_d_machine_aux_use primary key (id) -); - -create table d_machine_stats ( - id bigint auto_increment not null, - machine_id bigint not null, - date date, - total_kms bigint not null, - hours bigint not null, - rate decimal(38), - cost decimal(38), - version bigint not null, - constraint pk_d_machine_stats primary key (id) -); - -create table d_machine_use ( - id bigint auto_increment not null, - machine_id bigint not null, - date date, - distance_kms bigint not null, - time_secs bigint not null, - fuel decimal(38), - version bigint not null, - constraint pk_d_machine_use primary key (id) -); - -create table dorg ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_dorg primary key (id) -); - -create table dperson ( - id bigint auto_increment not null, - first_name varchar(255), - last_name varchar(255), - salary decimal(38), - constraint pk_dperson primary key (id) -); - -create table drol ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_drol primary key (id) -); - -create table drot ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_drot primary key (id) -); - -create table drot_drol ( - drot_id bigint not null, - drol_id bigint not null, - constraint pk_drot_drol primary key (drot_id,drol_id) -); - -create table rawinherit_data ( - id bigint auto_increment not null, - val integer, - constraint pk_rawinherit_data primary key (id) -); - -create table data_container ( - id varchar(40) not null, - content varchar(255), - constraint pk_data_container primary key (id) -); - -create table dc_detail ( - id bigint auto_increment not null, - master_id bigint, - description varchar(255), - version bigint not null, - constraint pk_dc_detail primary key (id) -); - -create table dc_master ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_dc_master primary key (id) -); - -create table dfk_cascade ( - id bigint auto_increment not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_cascade primary key (id) -); - -create table dfk_cascade_one ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_dfk_cascade_one primary key (id) -); - -create table dfk_none ( - id bigint auto_increment not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_none primary key (id) -); - -create table dfk_none_via_join ( - id bigint auto_increment not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_none_via_join primary key (id) -); - -create table dfk_none_via_mto_m ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_dfk_none_via_mto_m primary key (id) -); - -create table dfk_none_via_mto_m_dfk_one ( - dfk_none_via_mto_m_id bigint not null, - dfk_one_id bigint not null, - constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) -); - -create table dfk_one ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_dfk_one primary key (id) -); - -create table dfk_set_null ( - id bigint auto_increment not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_set_null primary key (id) -); - -create table doc ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_doc primary key (id) -); - -create table doc_link ( - doc_id bigint not null, - link_id bigint not null, - constraint pk_doc_link primary key (doc_id,link_id) -); - -create table doc_link_draft ( - doc_id bigint not null, - link_id bigint not null, - constraint pk_doc_link_draft primary key (doc_id,link_id) -); - -create table doc_draft ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_doc_draft primary key (id) -); - -create table document ( - id bigint auto_increment not null, - title varchar(127), - body varchar(255), - organisation_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint uq_document_title unique (title), - constraint pk_document primary key (id) -); - -create table document_draft ( - id bigint auto_increment not null, - title varchar(127), - body varchar(255), - when_publish datetime(6), - organisation_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint uq_document_draft_title unique (title), - constraint pk_document_draft primary key (id) -); - -create table document_media ( - id bigint auto_increment not null, - document_id bigint, - name varchar(255), - description varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_document_media primary key (id) -); - -create table document_media_draft ( - id bigint auto_increment not null, - document_id bigint, - name varchar(255), - description varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_document_media_draft primary key (id) -); - -create table sp_car_door ( - id bigint auto_increment not null, - name varchar(255), - version integer not null, - constraint pk_sp_car_door primary key (id) -); - -create table earray_bean ( - id bigint auto_increment not null, - foo integer, - name varchar(255), - phone_numbers varchar(300), - uids varchar(1000), - other_ids varchar(1000), - doubs varchar(1000), - statuses varchar(1000), - vc_enums varchar(1000), - int_enums varchar(1000), - status2 varchar(1000), - version bigint not null, - constraint pk_earray_bean primary key (id) -); - -create table earray_set_bean ( - id bigint auto_increment not null, - name varchar(255), - phone_numbers varchar(300), - uids varchar(1000), - other_ids varchar(1000), - doubs varchar(1000), - version bigint not null, - constraint pk_earray_set_bean primary key (id) -); - -create table e_basic ( - id integer auto_increment not null, - status varchar(1), - name varchar(127), - description varchar(255), - some_date datetime(6), - constraint pk_e_basic primary key (id) -); - -create table ebasic_change_log ( - id bigint auto_increment not null, - name varchar(20), - short_description varchar(50), - long_description varchar(100), - who_created varchar(255) not null, - who_modified varchar(255) not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - version bigint not null, - constraint pk_ebasic_change_log primary key (id) -); - -create table ebasic_clob ( - id bigint auto_increment not null, - name varchar(255), - title varchar(255), - description longtext, - last_update datetime(6) not null, - constraint pk_ebasic_clob primary key (id) -); - -create table ebasic_clob_fetch_eager ( - id bigint auto_increment not null, - name varchar(255), - title varchar(255), - description longtext, - last_update datetime(6) not null, - constraint pk_ebasic_clob_fetch_eager primary key (id) -); - -create table ebasic_clob_no_ver ( - id bigint auto_increment not null, - name varchar(255), - description longtext, - constraint pk_ebasic_clob_no_ver primary key (id) -); - -create table e_basicenc ( - id integer auto_increment not null, - name varchar(255), - description varbinary(80), - dob varbinary(20), - status varbinary(20), - last_update datetime(6), - constraint pk_e_basicenc primary key (id) -); - -create table e_basicenc_bin ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - data longblob, - some_time varbinary(255), - last_update datetime(6) not null, - constraint pk_e_basicenc_bin primary key (id) -); - -create table e_basicenc_client ( - id bigint auto_increment not null, - name varchar(255), - description varbinary(80), - dob varbinary(20), - status varbinary(20), - version bigint not null, - constraint pk_e_basicenc_client primary key (id) -); - -create table e_basic_enum_id ( - status varchar(1) not null, - name varchar(255), - description varchar(255), - constraint pk_e_basic_enum_id primary key (status) -); - -create table e_basic_eni ( - id integer auto_increment not null, - status integer, - name varchar(255), - description varchar(255), - some_date datetime(6), - constraint pk_e_basic_eni primary key (id) -); - -create table ebasic_hstore ( - id bigint auto_increment not null, - name varchar(255), - map varchar(800), - version bigint not null, - constraint pk_ebasic_hstore primary key (id) -); - -create table ebasic_json_jackson ( - id bigint auto_increment not null, - name varchar(255), - value_set varchar(700), - value_list longtext, - value_map varchar(700), - plain_value varchar(500), - version bigint not null, - constraint pk_ebasic_json_jackson primary key (id) -); - -create table ebasic_json_jackson2 ( - id bigint auto_increment not null, - name varchar(255), - value_set varchar(700), - value_list longtext, - value_map varchar(700), - plain_value varchar(500), - version bigint not null, - constraint pk_ebasic_json_jackson2 primary key (id) -); - -create table ebasic_json_list ( - id bigint auto_increment not null, - name varchar(255), - bean_set varchar(700), - bean_list longtext, - bean_map varchar(700), - plain_bean varchar(500), - flags varchar(50), - tags varchar(100), - version bigint not null, - constraint pk_ebasic_json_list primary key (id) -); - -create table ebasic_json_map ( - id bigint auto_increment not null, - name varchar(255), - content longtext, - version bigint not null, - constraint pk_ebasic_json_map primary key (id) -); - -create table ebasic_json_map_blob ( - id bigint auto_increment not null, - name varchar(255), - content longblob, - version bigint not null, - constraint pk_ebasic_json_map_blob primary key (id) -); - -create table ebasic_json_map_clob ( - id bigint auto_increment not null, - name varchar(255), - content longtext, - version bigint not null, - constraint pk_ebasic_json_map_clob primary key (id) -); - -create table ebasic_json_map_detail ( - id bigint auto_increment not null, - owner_id bigint, - name varchar(255), - content longtext, - version bigint not null, - constraint pk_ebasic_json_map_detail primary key (id) -); - -create table ebasic_json_map_json_b ( - id bigint auto_increment not null, - name varchar(255), - content longtext, - version bigint not null, - constraint pk_ebasic_json_map_json_b primary key (id) -); - -create table ebasic_json_map_varchar ( - id bigint auto_increment not null, - name varchar(255), - content varchar(3000), - version bigint not null, - constraint pk_ebasic_json_map_varchar primary key (id) -); - -create table ebasic_json_node ( - id bigint auto_increment not null, - name varchar(255), - content longtext, - version bigint not null, - constraint pk_ebasic_json_node primary key (id) -); - -create table ebasic_json_node_blob ( - id bigint auto_increment not null, - name varchar(255), - content longblob, - version bigint not null, - constraint pk_ebasic_json_node_blob primary key (id) -); - -create table ebasic_json_node_json_b ( - id bigint auto_increment not null, - name varchar(255), - content longtext, - version bigint not null, - constraint pk_ebasic_json_node_json_b primary key (id) -); - -create table ebasic_json_node_varchar ( - id bigint auto_increment not null, - name varchar(255), - content varchar(1000), - version bigint not null, - constraint pk_ebasic_json_node_varchar primary key (id) -); - -create table ebasic_json_unmapped ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ebasic_json_unmapped primary key (id) -); - -create table e_basic_ndc ( - id integer auto_increment not null, - name varchar(255), - constraint pk_e_basic_ndc primary key (id) -); - -create table ebasic_no_sdchild ( - id bigint auto_increment not null, - owner_id bigint not null, - child_name varchar(255), - amount bigint not null, - version bigint not null, - constraint pk_ebasic_no_sdchild primary key (id) -); - -create table ebasic_sdchild ( - id bigint auto_increment not null, - owner_id bigint not null, - child_name varchar(255), - amount bigint not null, - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_ebasic_sdchild primary key (id) -); - -create table ebasic_soft_delete ( - id bigint auto_increment not null, - name varchar(255), - description varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_ebasic_soft_delete primary key (id) -); - -create table e_basicver ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - other varchar(255), - last_update datetime(6) not null, - constraint pk_e_basicver primary key (id) -); - -create table e_basic_withlife ( - id bigint auto_increment not null, - name varchar(255), - deleted tinyint(1) default 0 not null, - version bigint not null, - constraint pk_e_basic_withlife primary key (id) -); - -create table e_basic_with_ex ( - id bigint auto_increment not null, - deleted tinyint(1) default 0 not null, - version bigint not null, - constraint pk_e_basic_with_ex primary key (id) -); - -create table e_basicverucon ( - id integer auto_increment not null, - name varchar(127), - other varchar(127), - other_one varchar(127), - description varchar(255), - last_update datetime(6) not null, - constraint uq_e_basicverucon_name unique (name), - constraint uq_e_basicverucon_other_other_one unique (other,other_one), - constraint pk_e_basicverucon primary key (id) -); - -create table ecache_child ( - id varchar(40) not null, - name varchar(100), - root_id varchar(40) not null, - constraint pk_ecache_child primary key (id) -); - -create table ecache_root ( - id varchar(40) not null, - name varchar(100), - constraint pk_ecache_root primary key (id) -); - -create table e_col_ab ( - id bigint auto_increment not null, - column_a varchar(255), - column_b varchar(255), - constraint pk_e_col_ab primary key (id) -); - -create table ecustom_id ( - id varchar(127) not null, - name varchar(255), - constraint pk_ecustom_id primary key (id) -); - -create table edefault_prop ( - id integer auto_increment not null, - e_simple_usertypeid integer, - name varchar(255), - constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), - constraint pk_edefault_prop primary key (id) -); - -create table eemb_inner ( - id integer auto_increment not null, - nome_inner varchar(255), - outer_id integer, - update_count integer not null, - constraint pk_eemb_inner primary key (id) -); - -create table eemb_outer ( - id integer auto_increment not null, - nome_outer varchar(255), - date1 datetime(6), - date2 datetime(6), - update_count integer not null, - constraint pk_eemb_outer primary key (id) -); - -create table efile2_no_fk ( - file_name varchar(64) not null, - owner_id integer not null, - constraint pk_efile2_no_fk primary key (file_name) -); - -create table efile_no_fk ( - file_name varchar(64) not null, - owner_user_id integer, - owner_soft_del_user_id integer, - constraint pk_efile_no_fk primary key (file_name) -); - -create table efile_no_fk_euser_no_fk ( - efile_no_fk_file_name varchar(64) not null, - euser_no_fk_user_id integer not null, - constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) -); - -create table efile_no_fk_euser_no_fk_soft_del ( - efile_no_fk_file_name varchar(64) not null, - euser_no_fk_soft_del_user_id integer not null, - constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) -); - -create table egen_props ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - ts_created datetime(6) not null, - ts_updated datetime(6) not null, - ldt_created datetime(6) not null, - ldt_updated datetime(6) not null, - odt_created datetime(6) not null, - odt_updated datetime(6) not null, - zdt_created datetime(6) not null, - zdt_updated datetime(6) not null, - instant_created datetime(6) not null, - instant_updated datetime(6) not null, - long_created bigint not null, - long_updated bigint not null, - constraint pk_egen_props primary key (id) -); - -create table einvoice ( - id bigint auto_increment not null, - invoice_date datetime(6), - state integer, - person_id bigint, - ship_street varchar(255), - ship_suburb varchar(255), - ship_city varchar(255), - ship_status varchar(3), - bill_street varchar(255), - bill_suburb varchar(255), - bill_city varchar(255), - bill_status varchar(3), - version bigint not null, - constraint pk_einvoice primary key (id) -); - -create table e_main ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - version bigint not null, - constraint pk_e_main primary key (id) -); - -create table enull_collection ( - id integer auto_increment not null, - name varchar(255), - constraint pk_enull_collection primary key (id) -); - -create table enull_collection_detail ( - id integer auto_increment not null, - enull_collection_id integer not null, - something varchar(255), - constraint pk_enull_collection_detail primary key (id) -); - -create table eopt_one_a ( - id integer auto_increment not null, - name_for_a varchar(255), - b_id integer, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_eopt_one_a primary key (id) -); - -create table eopt_one_b ( - id integer auto_increment not null, - name_for_b varchar(255), - c_id integer not null, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_eopt_one_b primary key (id) -); - -create table eopt_one_c ( - id integer auto_increment not null, - name_for_c varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_eopt_one_c primary key (id) -); - -create table eper_addr ( - id bigint auto_increment not null, - name varchar(255), - ma_street varchar(255), - ma_suburb varchar(255), - ma_city varchar(255), - ma_country_code varchar(2), - version bigint not null, - constraint pk_eper_addr primary key (id) -); - -create table eperson ( - id bigint auto_increment not null, - name varchar(255), - notes varchar(255), - street varchar(255), - suburb varchar(255), - addr_city varchar(255), - addr_status varchar(3), - version bigint not null, - constraint pk_eperson primary key (id) -); - -create table e_person_online ( - id bigint auto_increment not null, - email varchar(127), - online_status tinyint(1) default 0 not null, - when_updated datetime(6) not null, - constraint uq_e_person_online_email unique (email), - constraint pk_e_person_online primary key (id) -); - -create table esimple ( - usertypeid integer auto_increment not null, - name varchar(255), - constraint pk_esimple primary key (usertypeid) -); - -create table esoft_del_book ( - id bigint auto_increment not null, - book_title varchar(255), - lend_by_id bigint, - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_book primary key (id) -); - -create table esoft_del_book_esoft_del_user ( - esoft_del_book_id bigint not null, - esoft_del_user_id bigint not null, - constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) -); - -create table esoft_del_down ( - id bigint auto_increment not null, - esoft_del_mid_id bigint not null, - down varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_down primary key (id) -); - -create table esoft_del_mid ( - id bigint auto_increment not null, - top_id bigint, - mid varchar(255), - up_id bigint, - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_mid primary key (id) -); - -create table esoft_del_one_a ( - id bigint auto_increment not null, - name varchar(255), - oneb_id bigint, - deleted tinyint(1) default 0 not null, - version bigint not null, - constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), - constraint pk_esoft_del_one_a primary key (id) -); - -create table esoft_del_one_b ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_esoft_del_one_b primary key (id) -); - -create table esoft_del_role ( - id bigint auto_increment not null, - role_name varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_role primary key (id) -); - -create table esoft_del_role_esoft_del_user ( - esoft_del_role_id bigint not null, - esoft_del_user_id bigint not null, - constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) -); - -create table esoft_del_top ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_top primary key (id) -); - -create table esoft_del_up ( - id bigint auto_increment not null, - up varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_up primary key (id) -); - -create table esoft_del_user ( - id bigint auto_increment not null, - user_name varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esoft_del_user primary key (id) -); - -create table esoft_del_user_esoft_del_role ( - esoft_del_user_id bigint not null, - esoft_del_role_id bigint not null, - constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) -); - -create table esome_convert_type ( - id bigint auto_increment not null, - name varchar(255), - money decimal(38), - constraint pk_esome_convert_type primary key (id) -); - -create table esome_type ( - id integer auto_increment not null, - currency varchar(3), - locale varchar(20), - time_zone varchar(20), - constraint pk_esome_type primary key (id) -); - -create table etrans_many ( - id integer auto_increment not null, - name varchar(255), - constraint pk_etrans_many primary key (id) -); - -create table rawinherit_uncle ( - id integer auto_increment not null, - name varchar(255), - parent_id bigint not null, - version bigint not null, - constraint pk_rawinherit_uncle primary key (id) -); - -create table euser_no_fk ( - user_id integer auto_increment not null, - user_name varchar(255), - constraint pk_euser_no_fk primary key (user_id) -); - -create table euser_no_fk_soft_del ( - user_id integer auto_increment not null, - user_name varchar(255), - constraint pk_euser_no_fk_soft_del primary key (user_id) -); - -create table evanilla_collection ( - id integer auto_increment not null, - name varchar(255), - constraint pk_evanilla_collection primary key (id) -); - -create table evanilla_collection_detail ( - id integer auto_increment not null, - evanilla_collection_id integer not null, - something varchar(255), - constraint pk_evanilla_collection_detail primary key (id) -); - -create table ewho_props ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - who_created varchar(255) not null, - who_modified varchar(255) not null, - constraint pk_ewho_props primary key (id) -); - -create table e_withinet ( - id bigint auto_increment not null, - name varchar(255), - inet_address varchar(50), - inet2 varchar(255), - cdir varchar(50), - version bigint not null, - constraint pk_e_withinet primary key (id) -); - -create table ec_enum_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ec_enum_person primary key (id) -); - -create table ec_enum_person_tags ( - ec_enum_person_id bigint not null, - value varchar(5) not null -); - -create table ec_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ec_person primary key (id) -); - -create table ec_person_phone ( - owner_id bigint not null, - phone varchar(255) not null -); - -create table ecbl_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ecbl_person primary key (id) -); - -create table ecbl_person_phone_numbers ( - person_id bigint not null, - country_code varchar(2), - area varchar(6), - number varchar(20) -); - -create table ecbm_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ecbm_person primary key (id) -); - -create table ecbm_person_phone_numbers ( - person_id bigint not null, - mkey varchar(255) not null, - country_code varchar(2), - area varchar(6), - number varchar(20) -); - -create table ecm_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ecm_person primary key (id) -); - -create table ecm_person_phone_numbers ( - ecm_person_id bigint not null, - type varchar(4) not null, - number varchar(10) not null -); - -create table ecmc_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ecmc_person primary key (id) -); - -create table ecmc_person_phone_numbers ( - ecmc_person_id bigint not null, - type varchar(4) not null, - value longtext not null -); - -create table ecs_person ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_ecs_person primary key (id) -); - -create table ecs_person_phone ( - ecs_person_id bigint not null, - phone varchar(255) not null -); - -create table td_child ( - child_id integer auto_increment not null, - child_name varchar(255), - parent_id integer not null, - constraint pk_td_child primary key (child_id) -); - -create table td_parent ( - parent_type varchar(31) not null, - parent_id integer auto_increment not null, - parent_name varchar(255), - extended_name varchar(255), - constraint pk_td_parent primary key (parent_id) -); - -create table empl ( - id bigint auto_increment not null, - name varchar(255), - age integer, - default_address_id bigint, - constraint pk_empl primary key (id) -); - -create table esd_detail ( - id bigint auto_increment not null, - name varchar(255), - master_id bigint not null, - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esd_detail primary key (id) -); - -create table esd_master ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - deleted tinyint(1) default 0 not null, - constraint pk_esd_master primary key (id) -); - -create table feature_desc ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - constraint pk_feature_desc primary key (id) -); - -create table f_first ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_f_first primary key (id) -); - -create table foo ( - foo_id integer auto_increment not null, - important_text varchar(255), - version integer not null, - constraint pk_foo primary key (foo_id) -); - -create table gen_key_identity ( - id bigint auto_increment not null, - description varchar(255), - constraint pk_gen_key_identity primary key (id) -); - -create table gen_key_sequence ( - id bigint auto_increment not null, - description varchar(255), - constraint pk_gen_key_sequence primary key (id) -); - -create table gen_key_table ( - id bigint auto_increment not null, - description varchar(255), - constraint pk_gen_key_table primary key (id) -); - -create table grand_parent_person ( - identifier integer auto_increment not null, - name varchar(255), - age integer, - some_bean_id integer, - family_name varchar(255), - address varchar(255), - constraint pk_grand_parent_person primary key (identifier) -); - -create table survey_group ( - id bigint auto_increment not null, - name varchar(255), - categoryobjectid bigint, - sequence_number integer not null, - constraint pk_survey_group primary key (id) -); - -create table c_group ( - id bigint auto_increment not null, - inactive tinyint(1) default 0 not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_c_group primary key (id) -); - -create table he_doc ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_he_doc primary key (id) -); - -create table hx_link ( - id bigint auto_increment not null, - name varchar(255), - location varchar(255), - comments varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - deleted tinyint(1) default 0 not null, - constraint pk_hx_link primary key (id) -); - -create table hx_link_doc ( - hx_link_id bigint not null, - he_doc_id bigint not null, - constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) -); - -create table hi_doc ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_hi_doc primary key (id) -); - -create table hi_link ( - id bigint auto_increment not null, - name varchar(255), - location varchar(255), - comments varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_hi_link primary key (id) -); - -create table hi_link_doc ( - hi_link_id bigint not null, - hi_doc_id bigint not null, - constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) -); - -create table hi_tone ( - id bigint auto_increment not null, - name varchar(255), - comments varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_hi_tone primary key (id) -); - -create table hi_tthree ( - id bigint auto_increment not null, - hi_ttwo_id bigint not null, - three varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_hi_tthree primary key (id) -); - -create table hi_ttwo ( - id bigint auto_increment not null, - hi_tone_id bigint not null, - two varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_hi_ttwo primary key (id) -); - -create table hsd_setting ( - id bigint auto_increment not null, - code varchar(255), - content varchar(255), - user_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - deleted tinyint(1) default 0 not null, - constraint uq_hsd_setting_user_id unique (user_id), - constraint pk_hsd_setting primary key (id) -); - -create table hsd_user ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - deleted tinyint(1) default 0 not null, - constraint pk_hsd_user primary key (id) -); - -create table iaf_segment ( - ptype varchar(31) not null, - id bigint auto_increment not null, - segment_id_zat bigint not null, - status_id bigint not null, - constraint pk_iaf_segment primary key (id) -); - -create table iaf_segment_status ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_iaf_segment_status primary key (id) -); - -create table imrelated ( - id bigint auto_increment not null, - name varchar(255), - owner_id bigint not null, - constraint pk_imrelated primary key (id) -); - -create table imroot ( - dtype varchar(31) not null, - id bigint auto_increment not null, - name varchar(255), - title varchar(255), - when_title datetime(6), - constraint pk_imroot primary key (id) -); - -create table ixresource ( - dtype varchar(255), - id varchar(40) not null, - name varchar(255), - constraint pk_ixresource primary key (id) -); - -create table info_company ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_info_company primary key (id) -); - -create table info_contact ( - id bigint auto_increment not null, - name varchar(255), - company_id bigint not null, - version bigint not null, - constraint pk_info_contact primary key (id) -); - -create table info_customer ( - id bigint auto_increment not null, - name varchar(255), - company_id bigint, - version bigint not null, - constraint uq_info_customer_company_id unique (company_id), - constraint pk_info_customer primary key (id) -); - -create table inner_report ( - id bigint auto_increment not null, - name varchar(255), - forecast_id bigint, - constraint uq_inner_report_forecast_id unique (forecast_id), - constraint pk_inner_report primary key (id) -); - -create table drel_invoice ( - id bigint auto_increment not null, - booking bigint, - version integer not null, - constraint pk_drel_invoice primary key (id) -); - -create table item ( - customer integer not null, - itemnumber varchar(127) not null, - description varchar(255), - units varchar(255), - type integer not null, - region integer not null, - date_modified datetime(6), - date_created datetime(6), - modified_by varchar(255), - created_by varchar(255), - version bigint not null, - constraint pk_item primary key (customer,itemnumber) -); - -create table monkey ( - mid bigint auto_increment not null, - name varchar(255), - food_preference varchar(255), - version bigint not null, - constraint pk_monkey primary key (mid) -); - -create table mkeygroup ( - pid bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_mkeygroup primary key (pid) -); - -create table mkeygroup_monkey ( - mkeygroup_pid bigint not null, - monkey_mid bigint not null, - constraint uq_mkeygroup_monkey_mid unique (monkey_mid), - constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) -); - -create table trainer ( - tid bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_trainer primary key (tid) -); - -create table trainer_monkey ( - trainer_tid bigint not null, - monkey_mid bigint not null, - constraint uq_trainer_monkey_mid unique (monkey_mid), - constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) -); - -create table troop ( - pid bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_troop primary key (pid) -); - -create table troop_monkey ( - troop_pid bigint not null, - monkey_mid bigint not null, - constraint uq_troop_monkey_mid unique (monkey_mid), - constraint pk_troop_monkey primary key (troop_pid,monkey_mid) -); - -create table l2_cldf_reset_bean ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_l2_cldf_reset_bean primary key (id) -); - -create table l2_cldf_reset_bean_child ( - id bigint auto_increment not null, - parent_id bigint, - constraint pk_l2_cldf_reset_bean_child primary key (id) -); - -create table level1 ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_level1 primary key (id) -); - -create table level1_level4 ( - level1_id bigint not null, - level4_id bigint not null, - constraint pk_level1_level4 primary key (level1_id,level4_id) -); - -create table level1_level2 ( - level1_id bigint not null, - level2_id bigint not null, - constraint pk_level1_level2 primary key (level1_id,level2_id) -); - -create table level2 ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_level2 primary key (id) -); - -create table level2_level3 ( - level2_id bigint not null, - level3_id bigint not null, - constraint pk_level2_level3 primary key (level2_id,level3_id) -); - -create table level3 ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_level3 primary key (id) -); - -create table level4 ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_level4 primary key (id) -); - -create table link ( - id bigint auto_increment not null, - name varchar(255), - location varchar(255), - when_publish datetime(6), - link_comment varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - deleted tinyint(1) default 0 not null, - constraint pk_link primary key (id) -); - -create table link_draft ( - id bigint auto_increment not null, - name varchar(255), - location varchar(255), - when_publish datetime(6), - link_comment varchar(255), - dirty tinyint(1) default 0 not null, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - deleted tinyint(1) default 0 not null, - constraint pk_link_draft primary key (id) -); - -create table la_attr_value ( - id integer auto_increment not null, - name varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_la_attr_value primary key (id) -); - -create table la_attr_value_attribute ( - la_attr_value_id integer not null, - attribute_id integer not null, - constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) -); - -create table looney ( - id bigint auto_increment not null, - tune_id bigint, - name varchar(255), - constraint pk_looney primary key (id) -); - -create table maddress ( - id varchar(40) not null, - street varchar(255), - city varchar(255), - version bigint not null, - constraint pk_maddress primary key (id) -); - -create table mcontact ( - id varchar(40) not null, - email varchar(255), - first_name varchar(255), - last_name varchar(255), - customer_id varchar(40), - version bigint not null, - constraint pk_mcontact primary key (id) -); - -create table mcontact_message ( - id varchar(40) not null, - title varchar(255), - subject varchar(255), - notes varchar(255), - contact_id varchar(40) not null, - version bigint not null, - constraint pk_mcontact_message primary key (id) -); - -create table mcustomer ( - id varchar(40) not null, - name varchar(255), - notes varchar(255), - shipping_address_id varchar(40), - billing_address_id varchar(40), - version bigint not null, - constraint pk_mcustomer primary key (id) -); - -create table mgroup ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_mgroup primary key (id) -); - -create table mmachine ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_mmachine primary key (id) -); - -create table mmachine_mgroup ( - mmachine_id bigint not null, - mgroup_id bigint not null, - constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) -); - -create table mmedia ( - type varchar(31) not null, - id bigint auto_increment not null, - url varchar(255), - note varchar(255), - constraint pk_mmedia primary key (id) -); - -create table non_updateprop ( - id integer auto_increment not null, - non_enum varchar(5), - name varchar(255), - note varchar(255), - constraint pk_non_updateprop primary key (id) -); - -create table mprinter ( - id bigint auto_increment not null, - name varchar(255), - flags bigint not null, - current_state_id bigint, - last_swap_cyan_id bigint, - last_swap_magenta_id bigint, - last_swap_yellow_id bigint, - last_swap_black_id bigint, - version bigint not null, - constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), - constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), - constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), - constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), - constraint pk_mprinter primary key (id) -); - -create table mprinter_state ( - id bigint auto_increment not null, - flags bigint not null, - printer_id bigint, - version bigint not null, - constraint pk_mprinter_state primary key (id) -); - -create table mprofile ( - id bigint auto_increment not null, - picture_id bigint, - name varchar(255), - constraint pk_mprofile primary key (id) -); - -create table mprotected_construct_bean ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_mprotected_construct_bean primary key (id) -); - -create table mrole ( - roleid integer auto_increment not null, - role_name varchar(255), - constraint pk_mrole primary key (roleid) -); - -create table mrole_muser ( - mrole_roleid integer not null, - muser_userid integer not null, - constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) -); - -create table msome_other ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_msome_other primary key (id) -); - -create table muser ( - userid integer auto_increment not null, - user_name varchar(255), - user_type_id integer, - constraint pk_muser primary key (userid) -); - -create table muser_type ( - id integer auto_increment not null, - name varchar(255), - constraint pk_muser_type primary key (id) -); - -create table mail_box ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_mail_box primary key (id) -); - -create table mail_user ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_mail_user primary key (id) -); - -create table mail_user_inbox ( - mail_user_id bigint not null, - mail_box_id bigint not null, - constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) -); - -create table mail_user_outbox ( - mail_user_id bigint not null, - mail_box_id bigint not null, - constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) -); - -create table main_entity ( - id varchar(255) not null, - attr1 varchar(255), - attr2 varchar(255), - constraint pk_main_entity primary key (id) -); - -create table main_entity_relation ( - id varchar(40) not null, - id1 varchar(255), - id2 varchar(255), - attr1 varchar(255), - constraint pk_main_entity_relation primary key (id) -); - -create table map_super_actual ( - id bigint auto_increment not null, - name varchar(255), - when_created datetime(6) not null, - when_updated datetime(6) not null, - constraint pk_map_super_actual primary key (id) -); - -create table c_message ( - id bigint auto_increment not null, - title varchar(255), - body varchar(255), - conversation_id bigint, - user_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_c_message primary key (id) -); - -create table meter_address_data ( - id varchar(40) not null, - street varchar(255) not null, - constraint pk_meter_address_data primary key (id) -); - -create table meter_contract_data ( - id varchar(40) not null, - special_needs_client_id varchar(40) not null, - constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), - constraint pk_meter_contract_data primary key (id) -); - -create table meter_special_needs_client ( - id varchar(40) not null, - name varchar(255), - primary_id varchar(40), - constraint uq_meter_special_needs_client_primary_id unique (primary_id), - constraint pk_meter_special_needs_client primary key (id) -); - -create table meter_special_needs_contact ( - id varchar(40) not null, - name varchar(255), - constraint pk_meter_special_needs_contact primary key (id) -); - -create table meter_version ( - id varchar(40) not null, - address_data_id varchar(40), - contract_data_id varchar(40) not null, - constraint uq_meter_version_address_data_id unique (address_data_id), - constraint uq_meter_version_contract_data_id unique (contract_data_id), - constraint pk_meter_version primary key (id) -); - -create table mnoc_role ( - role_id integer auto_increment not null, - role_name varchar(255), - version integer not null, - constraint pk_mnoc_role primary key (role_id) -); - -create table mnoc_user ( - user_id integer auto_increment not null, - user_name varchar(255), - version integer not null, - constraint pk_mnoc_user primary key (user_id) -); - -create table mnoc_user_mnoc_role ( - mnoc_user_user_id integer not null, - mnoc_role_role_id integer not null, - constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) -); - -create table mny_a ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_mny_a primary key (id) -); - -create table mny_b ( - id bigint auto_increment not null, - name varchar(255), - a_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_mny_b primary key (id) -); - -create table mny_b_mny_c ( - mny_b_id bigint not null, - mny_c_id bigint not null, - constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) -); - -create table mny_c ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_mny_c primary key (id) -); - -create table mny_topic ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_mny_topic primary key (id) -); - -create table subtopics ( - topic bigint not null, - subtopic bigint not null, - constraint pk_subtopics primary key (topic,subtopic) -); - -create table mp_role ( - id bigint auto_increment not null, - mp_user_id bigint not null, - code varchar(255), - organization_id bigint, - constraint pk_mp_role primary key (id) -); - -create table mp_user ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_mp_user primary key (id) -); - -create table ms_many_a ( - aid bigint auto_increment not null, - name varchar(255), - ms_many_a_many_b tinyint(1) default 0 not null, - ms_many_b tinyint(1) default 0 not null, - deleted tinyint(1) default 0 not null, - constraint pk_ms_many_a primary key (aid) -); - -create table ms_many_a_many_b ( - ms_many_a_aid bigint not null, - ms_many_b_bid bigint not null, - constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) -); - -create table ms_many_b ( - bid bigint auto_increment not null, - name varchar(255), - deleted tinyint(1) default 0 not null, - constraint pk_ms_many_b primary key (bid) -); - -create table ms_many_b_many_a ( - ms_many_b_bid bigint not null, - ms_many_a_aid bigint not null, - constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) -); - -create table my_lob_size ( - id integer auto_increment not null, - name varchar(255), - my_count integer not null, - my_lob longtext, - constraint pk_my_lob_size primary key (id) -); - -create table my_lob_size_join_many ( - id integer auto_increment not null, - something varchar(255), - other varchar(255), - parent_id integer, - constraint pk_my_lob_size_join_many primary key (id) -); - -create table noidbean ( - name varchar(255), - subject varchar(255), - when_created datetime(6) not null -); - -create table o_cached_bean ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_o_cached_bean primary key (id) -); - -create table o_cached_bean_country ( - o_cached_bean_id bigint not null, - o_country_code varchar(2) not null, - constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) -); - -create table o_cached_bean_child ( - id bigint auto_increment not null, - cached_bean_id bigint, - constraint pk_o_cached_bean_child primary key (id) -); - -create table o_cached_inherit ( - dtype varchar(31) not null, - id bigint auto_increment not null, - name varchar(255), - child_adata varchar(255), - child_bdata varchar(255), - constraint pk_o_cached_inherit primary key (id) -); - -create table o_cached_natkey ( - id bigint auto_increment not null, - store varchar(255), - sku varchar(255), - description varchar(255), - constraint pk_o_cached_natkey primary key (id) -); - -create table o_cached_natkey3 ( - id bigint auto_increment not null, - store varchar(255), - code integer not null, - sku varchar(255), - description varchar(255), - constraint pk_o_cached_natkey3 primary key (id) -); - -create table ocar ( - id integer auto_increment not null, - vin varchar(255), - name varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_ocar primary key (id) -); - -create table ocompany ( - id integer auto_increment not null, - corp_id varchar(50), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint uq_ocompany_corp_id unique (corp_id), - constraint pk_ocompany primary key (id) -); - -create table oengine ( - engine_id varchar(40) not null, - short_desc varchar(255), - car_id integer, - version integer not null, - constraint uq_oengine_car_id unique (car_id), - constraint pk_oengine primary key (engine_id) -); - -create table ogear_box ( - id varchar(40) not null, - box_desc varchar(255), - box_size integer, - car_id integer, - version integer not null, - constraint uq_ogear_box_car_id unique (car_id), - constraint pk_ogear_box primary key (id) -); - -create table oroad_show_msg ( - id integer auto_increment not null, - company_id integer not null, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint uq_oroad_show_msg_company_id unique (company_id), - constraint pk_oroad_show_msg primary key (id) -); - -create table om_ordered_detail ( - id bigint auto_increment not null, - name varchar(255), - master_id bigint, - version bigint not null, - sort_order integer, - constraint pk_om_ordered_detail primary key (id) -); - -create table om_ordered_master ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_om_ordered_master primary key (id) -); - -create table only_id_entity ( - id bigint auto_increment not null, - constraint pk_only_id_entity primary key (id) -); - -create table o_order ( - id integer auto_increment not null, - status integer, - order_date date, - ship_date date, - kcustomer_id integer not null, - cretime datetime(6) not null, - updtime datetime(6) not null, - constraint pk_o_order primary key (id) -); - -create table o_order_detail ( - id integer auto_increment not null, - order_id integer not null, - order_qty integer, - ship_qty integer, - unit_price double, - product_id integer, - cretime datetime(6), - updtime datetime(6) not null, - constraint pk_o_order_detail primary key (id) -); - -create table s_orders ( - uuid varchar(40) not null, - constraint pk_s_orders primary key (uuid) -); - -create table s_order_items ( - uuid varchar(40) not null, - product_variant_uuid varchar(255), - order_uuid varchar(40), - quantity integer not null, - amount decimal(38), - constraint pk_s_order_items primary key (uuid) -); - -create table or_order_ship ( - id integer auto_increment not null, - order_id integer, - ship_time datetime(6), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_or_order_ship primary key (id) -); - -create table organisation ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_organisation primary key (id) -); - -create table organization_node ( - kind varchar(31) not null, - id bigint auto_increment not null, - parent_tree_node_id bigint not null, - title varchar(255), - constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), - constraint pk_organization_node primary key (id) -); - -create table organization_tree_node ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_organization_tree_node primary key (id) -); - -create table orp_detail ( - id varchar(100) not null, - detail varchar(255), - master_id varchar(100), - version bigint not null, - constraint pk_orp_detail primary key (id) -); - -create table orp_detail2 ( - id varchar(100) not null, - orp_master2_id varchar(100) not null, - detail varchar(255), - master_id varchar(255), - version bigint not null, - constraint pk_orp_detail2 primary key (id) -); - -create table orp_master ( - id varchar(100) not null, - name varchar(255), - version bigint not null, - constraint pk_orp_master primary key (id) -); - -create table orp_master2 ( - id varchar(100) not null, - name varchar(255), - version bigint not null, - constraint pk_orp_master2 primary key (id) -); - -create table oto_aone ( - id varchar(100) not null, - description varchar(255), - constraint pk_oto_aone primary key (id) -); - -create table oto_atwo ( - id varchar(100) not null, - description varchar(255), - aone_id varchar(100), - constraint uq_oto_atwo_aone_id unique (aone_id), - constraint pk_oto_atwo primary key (id) -); - -create table oto_bchild ( - master_id bigint not null, - child varchar(255), - constraint pk_oto_bchild primary key (master_id) -); - -create table oto_bmaster ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_oto_bmaster primary key (id) -); - -create table oto_child ( - id integer auto_increment not null, - name varchar(255), - master_id bigint, - constraint uq_oto_child_master_id unique (master_id), - constraint pk_oto_child primary key (id) -); - -create table oto_cust ( - cid bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_oto_cust primary key (cid) -); - -create table oto_cust_address ( - aid bigint auto_increment not null, - line1 varchar(255), - line2 varchar(255), - line3 varchar(255), - customer_cid bigint, - version bigint not null, - constraint uq_oto_cust_address_customer_cid unique (customer_cid), - constraint pk_oto_cust_address primary key (aid) -); - -create table oto_level_a ( - id bigint auto_increment not null, - name varchar(255), - b_id bigint, - constraint uq_oto_level_a_b_id unique (b_id), - constraint pk_oto_level_a primary key (id) -); - -create table oto_level_b ( - id bigint auto_increment not null, - name varchar(255), - c_id bigint, - constraint uq_oto_level_b_c_id unique (c_id), - constraint pk_oto_level_b primary key (id) -); - -create table oto_level_c ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_oto_level_c primary key (id) -); - -create table oto_master ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_oto_master primary key (id) -); - -create table oto_prime ( - pid bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_oto_prime primary key (pid) -); - -create table oto_prime_extra ( - eid bigint not null, - extra varchar(255), - version bigint not null, - constraint pk_oto_prime_extra primary key (eid) -); - -create table oto_sd_child ( - id bigint auto_increment not null, - child varchar(255), - master_id bigint, - deleted tinyint(1) default 0 not null, - version bigint not null, - constraint uq_oto_sd_child_master_id unique (master_id), - constraint pk_oto_sd_child primary key (id) -); - -create table oto_sd_master ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_oto_sd_master primary key (id) -); - -create table oto_th_many ( - id bigint auto_increment not null, - oto_th_top_id bigint not null, - many varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_oto_th_many primary key (id) -); - -create table oto_th_one ( - id bigint auto_increment not null, - one tinyint(1) default 0 not null, - many_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint uq_oto_th_one_many_id unique (many_id), - constraint pk_oto_th_one primary key (id) -); - -create table oto_th_top ( - id bigint auto_increment not null, - topp varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_oto_th_top primary key (id) -); - -create table oto_ubprime ( - pid varchar(40) not null, - name varchar(255), - version bigint not null, - constraint pk_oto_ubprime primary key (pid) -); - -create table oto_ubprime_extra ( - eid varchar(40) not null, - extra varchar(255), - version bigint not null, - constraint pk_oto_ubprime_extra primary key (eid) -); - -create table oto_uprime ( - pid varchar(40) not null, - name varchar(255), - version bigint not null, - constraint pk_oto_uprime primary key (pid) -); - -create table oto_uprime_extra ( - eid varchar(40) not null, - extra varchar(255), - version bigint not null, - constraint pk_oto_uprime_extra primary key (eid) -); - -create table oto_user_model ( - id bigint auto_increment not null, - name varchar(255), - user_optional_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint uq_oto_user_model_user_optional_id unique (user_optional_id), - constraint pk_oto_user_model primary key (id) -); - -create table oto_user_model_optional ( - id bigint auto_increment not null, - optional varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_oto_user_model_optional primary key (id) -); - -create table pfile ( - id integer auto_increment not null, - name varchar(255), - file_content_id integer, - file_content2_id integer, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint uq_pfile_file_content_id unique (file_content_id), - constraint uq_pfile_file_content2_id unique (file_content2_id), - constraint pk_pfile primary key (id) -); - -create table pfile_content ( - id integer auto_increment not null, - content longblob, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_pfile_content primary key (id) -); - -create table paggview ( - pview_id varchar(40), - amount integer not null, - constraint uq_paggview_pview_id unique (pview_id) -); - -create table pallet_location ( - type varchar(31) not null, - id integer auto_increment not null, - zone_sid integer not null, - attribute varchar(255), - constraint pk_pallet_location primary key (id) -); - -create table parcel ( - parcelid bigint auto_increment not null, - description varchar(255), - constraint pk_parcel primary key (parcelid) -); - -create table parcel_location ( - parcellocid bigint auto_increment not null, - location varchar(255), - parcelid bigint, - constraint uq_parcel_location_parcelid unique (parcelid), - constraint pk_parcel_location primary key (parcellocid) -); - -create table rawinherit_parent ( - type varchar(31) not null, - id bigint auto_increment not null, - val integer, - more varchar(255), - constraint pk_rawinherit_parent primary key (id) -); - -create table rawinherit_parent_rawinherit_data ( - rawinherit_parent_id bigint not null, - rawinherit_data_id bigint not null, - constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) -); - -create table e_save_test_c ( - id bigint auto_increment not null, - version bigint not null, - constraint pk_e_save_test_c primary key (id) -); - -create table parent_person ( - identifier integer auto_increment not null, - name varchar(255), - age integer, - some_bean_id integer, - parent_identifier integer, - family_name varchar(255), - address varchar(255), - constraint pk_parent_person primary key (identifier) -); - -create table c_participation ( - id bigint auto_increment not null, - rating integer, - type integer, - conversation_id bigint not null, - user_id bigint not null, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_c_participation primary key (id) -); - -create table password_store_model ( - id bigint auto_increment not null, - enc1 varchar(30), - enc2 varchar(40), - enc3 longtext, - enc4 varbinary(30), - enc5 varbinary(40), - enc6 longblob, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_password_store_model primary key (id) -); - -create table mt_permission ( - id varchar(40) not null, - name varchar(255), - constraint pk_mt_permission primary key (id) -); - -create table persistent_file ( - id integer auto_increment not null, - name varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_persistent_file primary key (id) -); - -create table persistent_file_content ( - id integer auto_increment not null, - persistent_file_id integer, - content longblob, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), - constraint pk_persistent_file_content primary key (id) -); - -create table person ( - oid bigint auto_increment not null, - default_address_oid bigint, - version integer not null, - constraint pk_person primary key (oid) -); - -create table persons ( - id bigint auto_increment not null, - surname varchar(64) not null, - name varchar(64) not null, - constraint pk_persons primary key (id) -); - -create table person_cache_email ( - id varchar(128) not null, - person_info_person_id varchar(128), - email varchar(255), - constraint pk_person_cache_email primary key (id) -); - -create table person_cache_info ( - person_id varchar(128) not null, - name varchar(255), - constraint pk_person_cache_info primary key (person_id) -); - -create table phones ( - id bigint auto_increment not null, - phone_number varchar(7) not null, - person_id bigint not null, - constraint uq_phones_phone_number unique (phone_number), - constraint pk_phones primary key (id) -); - -create table e_position ( - id bigint auto_increment not null, - name varchar(255), - contract_id bigint not null, - constraint pk_e_position primary key (id) -); - -create table primary_revision ( - id bigint not null, - revision integer not null, - name varchar(255), - version bigint not null, - constraint pk_primary_revision primary key (id,revision) -); - -create table o_product ( - id integer auto_increment not null, - sku varchar(20), - name varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - constraint pk_o_product primary key (id) -); - -create table pp ( - id varchar(40) not null, - name varchar(255), - value varchar(100) not null, - constraint pk_pp primary key (id) -); - -create table pp_to_ww ( - pp_id varchar(40) not null, - ww_id varchar(40) not null, - constraint pk_pp_to_ww primary key (pp_id,ww_id) -); - -create table question ( - id bigint auto_increment not null, - name varchar(255), - groupobjectid bigint, - sequence_number integer not null, - constraint pk_question primary key (id) -); - -create table rcustomer ( - company varchar(127) not null, - name varchar(127) not null, - description varchar(255), - constraint pk_rcustomer primary key (company,name) -); - -create table r_orders ( - company varchar(127) not null, - order_number integer not null, - customername varchar(127), - item varchar(255), - constraint pk_r_orders primary key (company,order_number) -); - -create table region ( - customer integer not null, - type integer not null, - description varchar(255), - version bigint not null, - constraint pk_region primary key (customer,type) -); - -create table rel_detail ( - id bigint auto_increment not null, - name varchar(255), - version integer not null, - constraint pk_rel_detail primary key (id) -); - -create table rel_master ( - id bigint auto_increment not null, - name varchar(255), - detail_id bigint, - version integer not null, - constraint pk_rel_master primary key (id) -); - -create table resourcefile ( - id varchar(64) not null, - parentresourcefileid varchar(64), - name varchar(128) not null, - constraint pk_resourcefile primary key (id) -); - -create table mt_role ( - id varchar(40) not null, - name varchar(50), - tenant_id varchar(40), - version bigint not null, - constraint pk_mt_role primary key (id) -); - -create table mt_role_permission ( - mt_role_id varchar(40) not null, - mt_permission_id varchar(40) not null, - constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) -); - -create table em_role ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_em_role primary key (id) -); - -create table f_second ( - id bigint auto_increment not null, - mod_name varchar(255), - first bigint, - title varchar(255), - constraint uq_f_second_first unique (first), - constraint pk_f_second primary key (id) -); - -create table section ( - id integer auto_increment not null, - article_id integer, - type integer, - content longtext, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_section primary key (id) -); - -create table self_parent ( - id bigint auto_increment not null, - name varchar(255), - parent_id bigint, - version bigint not null, - constraint pk_self_parent primary key (id) -); - -create table self_ref_customer ( - id bigint auto_increment not null, - name varchar(255), - referred_by_id bigint, - constraint pk_self_ref_customer primary key (id) -); - -create table self_ref_example ( - id bigint auto_increment not null, - name varchar(255) not null, - parent_id bigint, - constraint pk_self_ref_example primary key (id) -); - -create table e_save_test_a ( - id bigint auto_increment not null, - version bigint not null, - constraint pk_e_save_test_a primary key (id) -); - -create table e_save_test_b ( - id bigint auto_increment not null, - sibling_a_id bigint, - test_property tinyint(1) default 0 not null, - version bigint not null, - constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), - constraint pk_e_save_test_b primary key (id) -); - -create table site ( - id varchar(40) not null, - name varchar(255), - parent_id varchar(40), - data_container_id varchar(40), - site_address_id varchar(40), - constraint uq_site_data_container_id unique (data_container_id), - constraint uq_site_site_address_id unique (site_address_id), - constraint pk_site primary key (id) -); - -create table site_address ( - id varchar(40) not null, - street varchar(255), - city varchar(255), - zip_code varchar(255), - constraint pk_site_address primary key (id) -); - -create table some_enum_bean ( - id bigint auto_increment not null, - some_enum integer, - name varchar(255), - constraint pk_some_enum_bean primary key (id) -); - -create table some_file_bean ( - id bigint auto_increment not null, - name varchar(255), - content longblob, - version bigint not null, - constraint pk_some_file_bean primary key (id) -); - -create table some_new_types_bean ( - id bigint auto_increment not null, - dow integer(1), - mth integer(1), - yr integer, - yr_mth date, - month_day date, - local_date date, - local_date_time datetime(6), - offset_date_time datetime(6), - zoned_date_time datetime(6), - local_time time, - instant datetime(6), - zone_id varchar(60), - zone_offset varchar(60), - path varchar(255), - period varchar(20), - duration bigint, - version bigint not null, - constraint pk_some_new_types_bean primary key (id) -); - -create table some_period_bean ( - id bigint auto_increment not null, - anniversary date, - version bigint not null, - constraint pk_some_period_bean primary key (id) -); - -create table stockforecast ( - type varchar(31) not null, - id bigint auto_increment not null, - inner_report_id bigint, - constraint pk_stockforecast primary key (id) -); - -create table sub_section ( - id integer auto_increment not null, - section_id integer, - title varchar(255), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_sub_section primary key (id) -); - -create table sub_type ( - sub_type_id integer auto_increment not null, - description varchar(255), - version bigint not null, - constraint pk_sub_type primary key (sub_type_id) -); - -create table survey ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_survey primary key (id) -); - -create table tbytes_only ( - id integer auto_increment not null, - content longblob, - constraint pk_tbytes_only primary key (id) -); - -create table tcar ( - type varchar(31) not null, - plate_no varchar(32) not null, - truckload bigint, - constraint pk_tcar primary key (plate_no) -); - -create table tevent ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - constraint pk_tevent primary key (id) -); - -create table tevent_many ( - id bigint auto_increment not null, - description varchar(255), - event_id bigint, - units integer not null, - amount double not null, - version bigint not null, - constraint pk_tevent_many primary key (id) -); - -create table tevent_one ( - id bigint auto_increment not null, - name varchar(255), - status integer, - event_id bigint, - version bigint not null, - constraint uq_tevent_one_event_id unique (event_id), - constraint pk_tevent_one primary key (id) -); - -create table tint_root ( - my_type integer(3) not null, - id integer auto_increment not null, - name varchar(255), - child_property varchar(255), - constraint pk_tint_root primary key (id) -); - -create table tjoda_entity ( - id integer auto_increment not null, - local_time time, - constraint pk_tjoda_entity primary key (id) -); - -create table t_mapsuper1 ( - id integer auto_increment not null, - something varchar(255), - name varchar(255), - version integer not null, - constraint pk_t_mapsuper1 primary key (id) -); - -create table t_oneb ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - active tinyint(1) default 0 not null, - constraint pk_t_oneb primary key (id) -); - -create table t_detail_with_other_namexxxyy ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - some_unique_value varchar(127), - active tinyint(1) default 0 not null, - master_id integer, - constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), - constraint pk_t_detail_with_other_namexxxyy primary key (id) -); - -create table ts_detail_two ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - active tinyint(1) default 0 not null, - master_id integer, - constraint pk_ts_detail_two primary key (id) -); - -create table t_atable_thatisrelatively ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - active tinyint(1) default 0 not null, - constraint pk_t_atable_thatisrelatively primary key (id) -); - -create table ts_master_two ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - active tinyint(1) default 0 not null, - constraint pk_ts_master_two primary key (id) -); - -create table tuuid_entity ( - id varchar(40) not null, - name varchar(255), - constraint pk_tuuid_entity primary key (id) -); - -create table twheel ( - id bigint auto_increment not null, - owner_plate_no varchar(32) not null, - constraint pk_twheel primary key (id) -); - -create table twith_pre_insert ( - id integer auto_increment not null, - name varchar(255) not null, - title varchar(255), - constraint pk_twith_pre_insert primary key (id) -); - -create table mt_tenant ( - id varchar(40) not null, - name varchar(255), - version bigint not null, - constraint pk_mt_tenant primary key (id) -); - -create table test_annotation_base_entity ( - direct varchar(255), - meta varchar(255), - mixed varchar(255), - constraint_annotation varchar(40), - null1 varchar(255) not null, - null2 varchar(255), - null3 varchar(255) -); - -create table tire ( - id bigint auto_increment not null, - wheel bigint, - version integer not null, - constraint uq_tire_wheel unique (wheel), - constraint pk_tire primary key (id) -); - -create table sa_tire ( - id bigint auto_increment not null, - version integer not null, - constraint pk_sa_tire primary key (id) -); - -create table trip ( - id integer auto_increment not null, - vehicle_driver_id integer, - destination varchar(255), - address_id smallint, - star_date datetime(6), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_trip primary key (id) -); - -create table truck_ref ( - id integer auto_increment not null, - something varchar(255), - constraint pk_truck_ref primary key (id) -); - -create table tune ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_tune primary key (id) -); - -create table `type` ( - customer integer not null, - type integer not null, - description varchar(255), - sub_type_id integer, - version bigint not null, - constraint pk_type primary key (customer,type) -); - -create table tz_bean ( - id bigint auto_increment not null, - moda varchar(255), - ts datetime(6), - tstz datetime(6), - constraint pk_tz_bean primary key (id) -); - -create table usib_child ( - id varchar(40) not null, - parent_id bigint, - deleted tinyint(1) default 0 not null, - constraint pk_usib_child primary key (id) -); - -create table usib_child_sibling ( - id bigint auto_increment not null, - child_id varchar(40), - deleted tinyint(1) default 0 not null, - constraint uq_usib_child_sibling_child_id unique (child_id), - constraint pk_usib_child_sibling primary key (id) -); - -create table usib_parent ( - id bigint auto_increment not null, - deleted tinyint(1) default 0 not null, - constraint pk_usib_parent primary key (id) -); - -create table ut_detail ( - id integer auto_increment not null, - utmaster_id integer not null, - name varchar(255), - qty integer, - amount double, - version integer not null, - constraint pk_ut_detail primary key (id) -); - -create table ut_master ( - id integer auto_increment not null, - name varchar(255), - description varchar(255), - date date, - version integer not null, - constraint pk_ut_master primary key (id) -); - -create table uuone ( - id varchar(40) not null, - name varchar(255), - description varchar(255), - version bigint not null, - constraint pk_uuone primary key (id) -); - -create table uutwo ( - id varchar(40) not null, - name varchar(255), - notes varchar(255), - master_id varchar(40), - version bigint not null, - constraint pk_uutwo primary key (id) -); - -create table oto_user ( - id bigint auto_increment not null, - name varchar(255), - account_id bigint not null, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint uq_oto_user_account_id unique (account_id), - constraint pk_oto_user primary key (id) -); - -create table c_user ( - id bigint auto_increment not null, - inactive tinyint(1) default 0 not null, - name varchar(255), - email varchar(255), - password_hash varchar(255), - group_id bigint, - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - constraint pk_c_user primary key (id) -); - -create table tx_user ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_tx_user primary key (id) -); - -create table g_user ( - id bigint auto_increment not null, - username varchar(255), - version bigint not null, - constraint pk_g_user primary key (id) -); - -create table em_user ( - id bigint auto_increment not null, - name varchar(255), - constraint pk_em_user primary key (id) -); - -create table em_user_role ( - user_id bigint not null, - role_id bigint not null, - constraint pk_em_user_role primary key (user_id,role_id) -); - -create table vehicle ( - dtype varchar(3) not null, - id integer auto_increment not null, - license_number varchar(255), - registration_date datetime(6), - lease_id bigint, - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - siz varchar(3), - driver varchar(255), - car_ref_id integer, - notes varchar(255), - truck_ref_id integer, - capacity double, - constraint pk_vehicle primary key (id) -); - -create table vehicle_driver ( - id integer auto_increment not null, - name varchar(255), - vehicle_id integer, - address_id smallint, - license_issued_on datetime(6), - cretime datetime(6) not null, - updtime datetime(6) not null, - version bigint not null, - constraint pk_vehicle_driver primary key (id) -); - -create table vehicle_lease ( - dtype varchar(31) not null, - id bigint auto_increment not null, - name varchar(255), - active_start date, - active_end date, - version bigint not null, - bond decimal(38), - min_duration integer not null, - day_rate decimal(38), - max_days integer, - constraint pk_vehicle_lease primary key (id) -); - -create table warehouses ( - id integer auto_increment not null, - officezoneid integer, - constraint pk_warehouses primary key (id) -); - -create table warehousesshippingzones ( - warehouseid integer not null, - shippingzoneid integer not null, - constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) -); - -create table wheel ( - id bigint auto_increment not null, - version integer not null, - constraint pk_wheel primary key (id) -); - -create table sa_wheel ( - id bigint auto_increment not null, - tire bigint, - car bigint, - version integer not null, - constraint pk_sa_wheel primary key (id) -); - -create table sp_car_wheel ( - id bigint auto_increment not null, - name varchar(255), - version integer not null, - constraint pk_sp_car_wheel primary key (id) -); - -create table g_who_props_otm ( - id bigint auto_increment not null, - name varchar(255), - version bigint not null, - when_created datetime(6) not null, - when_modified datetime(6) not null, - who_created_id bigint, - who_modified_id bigint, - constraint pk_g_who_props_otm primary key (id) -); - -create table with_zero ( - id bigint auto_increment not null, - name varchar(255), - parent_id integer, - lang varchar(2) default 'en' not null, - version bigint not null, - constraint pk_with_zero primary key (id) -); - -create table parent ( - id integer auto_increment not null, - name varchar(255), - constraint pk_parent primary key (id) -); - -create table wview ( - id varchar(40) not null, - name varchar(127) not null, - constraint uq_wview_name unique (name), - constraint pk_wview primary key (id) -); - -create table zones ( - type varchar(31) not null, - id integer auto_increment not null, - attribute varchar(255), - constraint pk_zones primary key (id) -); - -create index ix_contact_last_name_first_name on contact (last_name,first_name); -create index ix_e_basic_name on e_basic (name); -create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); -create index ix_organization_node_kind on organization_node (kind); -create index ix_bar_foo_id on bar (foo_id); -alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; - -create index ix_acl_container_relation_container_id on acl_container_relation (container_id); -alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; - -create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); -alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; - -create index ix_addr_employee_id on addr (employee_id); -alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; - -create index ix_o_address_country_code on o_address (country_code); -alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; - -alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; - -create index ix_animal_shelter_id on animal (shelter_id); -alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; - -create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); -alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; - -create index ix_bbookmark_user_id on bbookmark (user_id); -alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; - -create index ix_bbookmark_user_org_id on bbookmark_user (org_id); -alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; - -create index ix_bsite_user_a_site_id on bsite_user_a (site_id); -alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_a_user_id on bsite_user_a (user_id); -alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; - -create index ix_bsite_user_b_site on bsite_user_b (site); -alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_b_usr on bsite_user_b (usr); -alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; - -create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); -alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); -alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; - -create index ix_bsite_user_e_site_id on bsite_user_e (site_id); -alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_e_user_id on bsite_user_e (user_id); -alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; - -alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; - -alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; - -alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; - -create index ix_cepproduct_category_category_id on cepproduct_category (category_id); -alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; - -create index ix_cepproduct_category_product_id on cepproduct_category (product_id); -alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; - -create index ix_cinh_ref_ref_id on cinh_ref (ref_id); -alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; - -create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); -alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; - -create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); -alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; - -create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); -alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; - -create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); -alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; - -create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); -alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; - -create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); -alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; - -create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); -alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; - -create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); -alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; - -create index ix_car_accessory_fuse_id on car_accessory (fuse_id); -alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; - -create index ix_car_accessory_car_id on car_accessory (car_id); -alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; - -create index ix_category_surveyobjectid on category (surveyobjectid); -alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; - -alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; - -create index ix_child_person_some_bean_id on child_person (some_bean_id); -alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; - -create index ix_child_person_parent_identifier on child_person (parent_identifier); -alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; - -create index ix_cke_client_user on cke_client (username,cod_cpny); -alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; - -alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; - -alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -create index ix_configuration_configurations_id on configuration (configurations_id); -alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; - -create index ix_contact_customer_id on contact (customer_id); -alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; - -create index ix_contact_group_id on contact (group_id); -alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; - -create index ix_contact_note_contact_id on contact_note (contact_id); -alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; - -create index ix_contract_costs_position_id on contract_costs (position_id); -alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; - -create index ix_c_conversation_group_id on c_conversation (group_id); -alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; - -create index ix_o_customer_billing_address_id on o_customer (billing_address_id); -alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); -alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); -alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; - -create index ix_dcredit_drol_drol on dcredit_drol (drol_id); -alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; - -create index ix_dmachine_organisation_id on dmachine (organisation_id); -alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; - -create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); -alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; - -create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); -alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; - -create index ix_d_machine_use_machine_id on d_machine_use (machine_id); -alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; - -create index ix_drot_drol_drot on drot_drol (drot_id); -alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; - -create index ix_drot_drol_drol on drot_drol (drol_id); -alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; - -create index ix_dc_detail_master_id on dc_detail (master_id); -alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; - -create index ix_dfk_cascade_one_id on dfk_cascade (one_id); -alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; - -create index ix_dfk_set_null_one_id on dfk_set_null (one_id); -alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; - -alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; - -create index ix_doc_link_doc on doc_link (doc_id); -alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; - -create index ix_doc_link_link on doc_link (link_id); -alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; - -alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; - -create index ix_document_organisation_id on document (organisation_id); -alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; - -create index ix_document_draft_organisation_id on document_draft (organisation_id); -alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; - -create index ix_document_media_document_id on document_media (document_id); -alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; - -create index ix_document_media_draft_document_id on document_media_draft (document_id); -alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; - -create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); -alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; - -create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); -alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; - -create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); -alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; - -create index ix_ecache_child_root_id on ecache_child (root_id); -alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; - -alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; - -create index ix_eemb_inner_outer_id on eemb_inner (outer_id); -alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; - -create index ix_einvoice_person_id on einvoice (person_id); -alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; - -create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); -alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; - -create index ix_eopt_one_a_b_id on eopt_one_a (b_id); -alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; - -create index ix_eopt_one_b_c_id on eopt_one_b (c_id); -alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; - -create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); -alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; - -create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); -alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); -alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; - -create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); -alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); -alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; - -create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); -alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; - -create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); -alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; - -alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; - -create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); -alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; - -create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); -alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); -alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); -alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; - -create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); -alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; - -create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); -alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; - -create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); -alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; - -create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); -alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; - -create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); -alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; - -create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); -alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; - -create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); -alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; - -create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); -alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; - -create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); -alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; - -create index ix_td_child_parent_id on td_child (parent_id); -alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; - -create index ix_empl_default_address_id on empl (default_address_id); -alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; - -create index ix_esd_detail_master_id on esd_detail (master_id); -alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; - -create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); -alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; - -create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); -alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; - -create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); -alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; - -create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); -alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; - -create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); -alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; - -create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); -alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; - -create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); -alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; - -create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); -alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; - -alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; - -create index ix_iaf_segment_status_id on iaf_segment (status_id); -alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; - -create index ix_imrelated_owner_id on imrelated (owner_id); -alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; - -create index ix_info_contact_company_id on info_contact (company_id); -alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; - -alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; - -alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; - -create index ix_drel_invoice_booking on drel_invoice (booking); -alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; - -create index ix_item_etype on item (customer,type); -alter table item add constraint fk_item_etype foreign key (customer,type) references `type` (customer,type) on delete restrict on update restrict; - -create index ix_item_eregion on item (customer,region); -alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; - -alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; - -alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; - -alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; - -alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); -alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; - -create index ix_level1_level4_level1 on level1_level4 (level1_id); -alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; - -create index ix_level1_level4_level4 on level1_level4 (level4_id); -alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; - -create index ix_level1_level2_level1 on level1_level2 (level1_id); -alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; - -create index ix_level1_level2_level2 on level1_level2 (level2_id); -alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; - -create index ix_level2_level3_level2 on level2_level3 (level2_id); -alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; - -create index ix_level2_level3_level3 on level2_level3 (level3_id); -alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; - -alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; - -create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); -alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; - -create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); -alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; - -create index ix_looney_tune_id on looney (tune_id); -alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; - -create index ix_mcontact_customer_id on mcontact (customer_id); -alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; - -create index ix_mcontact_message_contact_id on mcontact_message (contact_id); -alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; - -create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); -alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; - -create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); -alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; - -create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); -alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; - -create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); -alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; - -create index ix_mprinter_current_state_id on mprinter (current_state_id); -alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; - -create index ix_mprinter_state_printer_id on mprinter_state (printer_id); -alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; - -create index ix_mprofile_picture_id on mprofile (picture_id); -alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; - -create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); -alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; - -create index ix_mrole_muser_muser on mrole_muser (muser_userid); -alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; - -create index ix_muser_user_type_id on muser (user_type_id); -alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; - -create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); -alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; - -create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); -alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; - -create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); -alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; - -create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); -alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; - -create index ix_c_message_conversation_id on c_message (conversation_id); -alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; - -create index ix_c_message_user_id on c_message (user_id); -alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; - -alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; - -alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; - -alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; - -alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; - -create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); -alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; - -create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); -alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; - -create index ix_mny_b_a_id on mny_b (a_id); -alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; - -create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); -alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; - -create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); -alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; - -create index ix_subtopics_mny_topic_1 on subtopics (topic); -alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; - -create index ix_subtopics_mny_topic_2 on subtopics (subtopic); -alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; - -create index ix_mp_role_mp_user_id on mp_role (mp_user_id); -alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; - -create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); -alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; - -create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); -alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; - -create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); -alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; - -create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); -alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; - -create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); -alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; - -create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); -alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; - -create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); -alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; - -create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); -alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; - -alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; - -alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; - -alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; - -create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); -alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; - -create index ix_o_order_kcustomer_id on o_order (kcustomer_id); -alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; - -create index ix_o_order_detail_order_id on o_order_detail (order_id); -alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; - -create index ix_o_order_detail_product_id on o_order_detail (product_id); -alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; - -create index ix_s_order_items_order_uuid on s_order_items (order_uuid); -alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; - -create index ix_or_order_ship_order_id on or_order_ship (order_id); -alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; - -alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; - -create index ix_orp_detail_master_id on orp_detail (master_id); -alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; - -create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); -alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; - -alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; - -alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; - -alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; - -alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; - -alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; - -alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; - -alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; - -alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; - -create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); -alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; - -alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; - -alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; - -alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; - -alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; - -alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; - -alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; - -create index ix_pallet_location_zone_sid on pallet_location (zone_sid); -alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; - -alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; - -create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); -alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; - -create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); -alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; - -create index ix_parent_person_some_bean_id on parent_person (some_bean_id); -alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; - -create index ix_parent_person_parent_identifier on parent_person (parent_identifier); -alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; - -create index ix_c_participation_conversation_id on c_participation (conversation_id); -alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; - -create index ix_c_participation_user_id on c_participation (user_id); -alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; - -alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; - -create index ix_person_default_address_oid on person (default_address_oid); -alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; - -create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); -alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; - -create index ix_phones_person_id on phones (person_id); -alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; - -create index ix_e_position_contract_id on e_position (contract_id); -alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; - -create index ix_pp_to_ww_pp on pp_to_ww (pp_id); -alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; - -create index ix_pp_to_ww_wview on pp_to_ww (ww_id); -alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; - -create index ix_question_groupobjectid on question (groupobjectid); -alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; - -create index ix_r_orders_customer on r_orders (company,customername); -alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; - -create index ix_rel_master_detail_id on rel_master (detail_id); -alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; - -create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); -alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; - -create index ix_mt_role_tenant_id on mt_role (tenant_id); -alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; - -create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); -alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; - -create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); -alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; - -alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; - -create index ix_section_article_id on section (article_id); -alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; - -create index ix_self_parent_parent_id on self_parent (parent_id); -alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; - -create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); -alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; - -create index ix_self_ref_example_parent_id on self_ref_example (parent_id); -alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; - -alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; - -create index ix_site_parent_id on site (parent_id); -alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; - -alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; - -alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; - -create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); -alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; - -create index ix_sub_section_section_id on sub_section (section_id); -alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; - -create index ix_tevent_many_event_id on tevent_many (event_id); -alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; - -alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; - -create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); -alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; - -create index ix_ts_detail_two_master_id on ts_detail_two (master_id); -alter table ts_detail_two add constraint fk_ts_detail_two_master_id foreign key (master_id) references ts_master_two (id) on delete restrict on update restrict; - -create index ix_twheel_owner_plate_no on twheel (owner_plate_no); -alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; - -alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; - -create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); -alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; - -create index ix_trip_address_id on trip (address_id); -alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_type_sub_type_id on `type` (sub_type_id); -alter table `type` add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; - -create index ix_usib_child_parent_id on usib_child (parent_id); -alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; - -alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; - -create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); -alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; - -create index ix_uutwo_master_id on uutwo (master_id); -alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; - -alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; - -create index ix_c_user_group_id on c_user (group_id); -alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; - -create index ix_em_user_role_user_id on em_user_role (user_id); -alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; - -create index ix_em_user_role_role_id on em_user_role (role_id); -alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; - -create index ix_vehicle_lease_id on vehicle (lease_id); -alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; - -create index ix_vehicle_car_ref_id on vehicle (car_ref_id); -alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; - -create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); -alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; - -create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); -alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; - -create index ix_vehicle_driver_address_id on vehicle_driver (address_id); -alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_warehouses_officezoneid on warehouses (officezoneid); -alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; - -create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); -alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; - -create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); -alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; - -create index ix_sa_wheel_tire on sa_wheel (tire); -alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; - -create index ix_sa_wheel_car on sa_wheel (car); -alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; - -create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); -alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; - -create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); -alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; - -create index ix_with_zero_parent_id on with_zero (parent_id); -alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; - -alter table hx_link add column sys_period_start datetime(6) default now(6); -alter table hx_link add column sys_period_end datetime(6); -update hx_link set sys_period_start = when_created; -create table hx_link_history( - id bigint, - name varchar(255), - location varchar(255), - comments varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - deleted tinyint(1), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; - -alter table hi_link add column sys_period_start datetime(6) default now(6); -alter table hi_link add column sys_period_end datetime(6); -update hi_link set sys_period_start = when_created; -create table hi_link_history( - id bigint, - name varchar(255), - location varchar(255), - comments varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; - -alter table hi_link_doc add column sys_period_start datetime(6) default now(6); -alter table hi_link_doc add column sys_period_end datetime(6); -create table hi_link_doc_history( - hi_link_id bigint, - hi_doc_id bigint, - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; - -alter table hi_tone add column sys_period_start datetime(6) default now(6); -alter table hi_tone add column sys_period_end datetime(6); -update hi_tone set sys_period_start = when_created; -create table hi_tone_history( - id bigint, - name varchar(255), - comments varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; - -alter table hi_tthree add column sys_period_start datetime(6) default now(6); -alter table hi_tthree add column sys_period_end datetime(6); -update hi_tthree set sys_period_start = when_created; -create table hi_tthree_history( - id bigint, - hi_ttwo_id bigint, - three varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; - -alter table hi_ttwo add column sys_period_start datetime(6) default now(6); -alter table hi_ttwo add column sys_period_end datetime(6); -update hi_ttwo set sys_period_start = when_created; -create table hi_ttwo_history( - id bigint, - hi_tone_id bigint, - two varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; - -alter table hsd_setting add column sys_period_start datetime(6) default now(6); -alter table hsd_setting add column sys_period_end datetime(6); -update hsd_setting set sys_period_start = when_created; -create table hsd_setting_history( - id bigint, - code varchar(255), - content varchar(255), - user_id bigint, - version bigint, - when_created datetime(6), - when_modified datetime(6), - deleted tinyint(1), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; - -alter table hsd_user add column sys_period_start datetime(6) default now(6); -alter table hsd_user add column sys_period_end datetime(6); -update hsd_user set sys_period_start = when_created; -create table hsd_user_history( - id bigint, - name varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - deleted tinyint(1), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; - -alter table link add column sys_period_start datetime(6) default now(6); -alter table link add column sys_period_end datetime(6); -update link set sys_period_start = when_created; -create table link_history( - id bigint, - name varchar(255), - location varchar(255), - when_publish datetime(6), - link_comment varchar(255), - version bigint, - when_created datetime(6), - when_modified datetime(6), - deleted tinyint(1), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view link_with_history as select * from link union all select * from link_history; - -alter table c_user add column sys_period_start datetime(6) default now(6); -alter table c_user add column sys_period_end datetime(6); -update c_user set sys_period_start = when_created; -create table c_user_history( - id bigint, - inactive tinyint(1), - name varchar(255), - email varchar(255), - password_hash varchar(255), - group_id bigint, - version bigint, - when_created datetime(6), - when_modified datetime(6), - sys_period_start datetime(6), - sys_period_end datetime(6) -); -create view c_user_with_history as select * from c_user union all select * from c_user_history; - -delimiter $$ -create trigger hx_link_history_upd before update on hx_link for each row begin - insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hx_link_history_del before delete on hx_link for each row begin - insert into hx_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); -end$$ -delimiter $$ -create trigger hi_link_history_upd before update on hi_link for each row begin - insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hi_link_history_del before delete on hi_link for each row begin - insert into hi_link_history (sys_period_start,sys_period_end,id, name, location, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); -end$$ -delimiter $$ -create trigger hi_link_doc_history_upd before update on hi_link_doc for each row begin - insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hi_link_doc_history_del before delete on hi_link_doc for each row begin - insert into hi_link_doc_history (sys_period_start,sys_period_end,hi_link_id, hi_doc_id) values (OLD.sys_period_start, now(6),OLD.hi_link_id, OLD.hi_doc_id); -end$$ -delimiter $$ -create trigger hi_tone_history_upd before update on hi_tone for each row begin - insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hi_tone_history_del before delete on hi_tone for each row begin - insert into hi_tone_history (sys_period_start,sys_period_end,id, name, comments, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); -end$$ -delimiter $$ -create trigger hi_tthree_history_upd before update on hi_tthree for each row begin - insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hi_tthree_history_del before delete on hi_tthree for each row begin - insert into hi_tthree_history (sys_period_start,sys_period_end,id, hi_ttwo_id, three, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); -end$$ -delimiter $$ -create trigger hi_ttwo_history_upd before update on hi_ttwo for each row begin - insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hi_ttwo_history_del before delete on hi_ttwo for each row begin - insert into hi_ttwo_history (sys_period_start,sys_period_end,id, hi_tone_id, two, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); -end$$ -delimiter $$ -create trigger hsd_setting_history_upd before update on hsd_setting for each row begin - insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hsd_setting_history_del before delete on hsd_setting for each row begin - insert into hsd_setting_history (sys_period_start,sys_period_end,id, code, content, user_id, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); -end$$ -delimiter $$ -create trigger hsd_user_history_upd before update on hsd_user for each row begin - insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger hsd_user_history_del before delete on hsd_user for each row begin - insert into hsd_user_history (sys_period_start,sys_period_end,id, name, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); -end$$ -delimiter $$ -create trigger link_history_upd before update on link for each row begin - insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger link_history_del before delete on link for each row begin - insert into link_history (sys_period_start,sys_period_end,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (OLD.sys_period_start, now(6),OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); -end$$ -delimiter $$ -create trigger c_user_history_upd before update on c_user for each row begin - insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); - set NEW.sys_period_start = now(6); -end$$ -delimiter $$ -create trigger c_user_history_del before delete on c_user for each row begin - insert into c_user_history (sys_period_start,sys_period_end,id, inactive, name, email, group_id, version, when_created, when_modified) values (OLD.sys_period_start, now(6),OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); -end$$ diff --git a/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql b/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql deleted file mode 100644 index c3bcf7d..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_mysql/mysql-drop-all.sql +++ /dev/null @@ -1,1730 +0,0 @@ --- Generated by ebean unknown at 2019-07-25T07:02:24.426Z -alter table bar drop foreign key fk_bar_foo_id; -drop index ix_bar_foo_id on bar; - -alter table acl_container_relation drop foreign key fk_acl_container_relation_container_id; -drop index ix_acl_container_relation_container_id on acl_container_relation; - -alter table acl_container_relation drop foreign key fk_acl_container_relation_acl_entry_id; -drop index ix_acl_container_relation_acl_entry_id on acl_container_relation; - -alter table addr drop foreign key fk_addr_employee_id; -drop index ix_addr_employee_id on addr; - -alter table o_address drop foreign key fk_o_address_country_code; -drop index ix_o_address_country_code on o_address; - -alter table album drop foreign key fk_album_cover_id; - -alter table animal drop foreign key fk_animal_shelter_id; -drop index ix_animal_shelter_id on animal; - -alter table attribute drop foreign key fk_attribute_attribute_holder_id; -drop index ix_attribute_attribute_holder_id on attribute; - -alter table bbookmark drop foreign key fk_bbookmark_user_id; -drop index ix_bbookmark_user_id on bbookmark; - -alter table bbookmark_user drop foreign key fk_bbookmark_user_org_id; -drop index ix_bbookmark_user_org_id on bbookmark_user; - -alter table bsite_user_a drop foreign key fk_bsite_user_a_site_id; -drop index ix_bsite_user_a_site_id on bsite_user_a; - -alter table bsite_user_a drop foreign key fk_bsite_user_a_user_id; -drop index ix_bsite_user_a_user_id on bsite_user_a; - -alter table bsite_user_b drop foreign key fk_bsite_user_b_site; -drop index ix_bsite_user_b_site on bsite_user_b; - -alter table bsite_user_b drop foreign key fk_bsite_user_b_usr; -drop index ix_bsite_user_b_usr on bsite_user_b; - -alter table bsite_user_c drop foreign key fk_bsite_user_c_site_uid; -drop index ix_bsite_user_c_site_uid on bsite_user_c; - -alter table bsite_user_c drop foreign key fk_bsite_user_c_user_uid; -drop index ix_bsite_user_c_user_uid on bsite_user_c; - -alter table bsite_user_e drop foreign key fk_bsite_user_e_site_id; -drop index ix_bsite_user_e_site_id on bsite_user_e; - -alter table bsite_user_e drop foreign key fk_bsite_user_e_user_id; -drop index ix_bsite_user_e_user_id on bsite_user_e; - -alter table basic_draftable_bean drop foreign key fk_basic_draftable_bean_id; - -alter table drel_booking drop foreign key fk_drel_booking_agent_invoice; - -alter table drel_booking drop foreign key fk_drel_booking_client_invoice; - -alter table cepproduct_category drop foreign key fk_cepproduct_category_category_id; -drop index ix_cepproduct_category_category_id on cepproduct_category; - -alter table cepproduct_category drop foreign key fk_cepproduct_category_product_id; -drop index ix_cepproduct_category_product_id on cepproduct_category; - -alter table cinh_ref drop foreign key fk_cinh_ref_ref_id; -drop index ix_cinh_ref_ref_id on cinh_ref; - -alter table ckey_detail drop foreign key fk_ckey_detail_parent; -drop index ix_ckey_detail_parent on ckey_detail; - -alter table ckey_parent drop foreign key fk_ckey_parent_assoc_id; -drop index ix_ckey_parent_assoc_id on ckey_parent; - -alter table calculation_result drop foreign key fk_calculation_result_product_configuration_id; -drop index ix_calculation_result_product_configuration_id on calculation_result; - -alter table calculation_result drop foreign key fk_calculation_result_group_configuration_id; -drop index ix_calculation_result_group_configuration_id on calculation_result; - -alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_car; -drop index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels; - -alter table sp_car_car_wheels drop foreign key fk_sp_car_car_wheels_sp_car_wheel; -drop index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels; - -alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_car; -drop index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors; - -alter table sp_car_car_doors drop foreign key fk_sp_car_car_doors_sp_car_door; -drop index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors; - -alter table car_accessory drop foreign key fk_car_accessory_fuse_id; -drop index ix_car_accessory_fuse_id on car_accessory; - -alter table car_accessory drop foreign key fk_car_accessory_car_id; -drop index ix_car_accessory_car_id on car_accessory; - -alter table category drop foreign key fk_category_surveyobjectid; -drop index ix_category_surveyobjectid on category; - -alter table e_save_test_d drop foreign key fk_e_save_test_d_parent_id; - -alter table child_person drop foreign key fk_child_person_some_bean_id; -drop index ix_child_person_some_bean_id on child_person; - -alter table child_person drop foreign key fk_child_person_parent_identifier; -drop index ix_child_person_parent_identifier on child_person; - -alter table cke_client drop foreign key fk_cke_client_user; -drop index ix_cke_client_user on cke_client; - -alter table class_super_monkey drop foreign key fk_class_super_monkey_class_super; - -alter table class_super_monkey drop foreign key fk_class_super_monkey_monkey; - -alter table configuration drop foreign key fk_configuration_configurations_id; -drop index ix_configuration_configurations_id on configuration; - -alter table contact drop foreign key fk_contact_customer_id; -drop index ix_contact_customer_id on contact; - -alter table contact drop foreign key fk_contact_group_id; -drop index ix_contact_group_id on contact; - -alter table contact_note drop foreign key fk_contact_note_contact_id; -drop index ix_contact_note_contact_id on contact_note; - -alter table contract_costs drop foreign key fk_contract_costs_position_id; -drop index ix_contract_costs_position_id on contract_costs; - -alter table c_conversation drop foreign key fk_c_conversation_group_id; -drop index ix_c_conversation_group_id on c_conversation; - -alter table o_customer drop foreign key fk_o_customer_billing_address_id; -drop index ix_o_customer_billing_address_id on o_customer; - -alter table o_customer drop foreign key fk_o_customer_shipping_address_id; -drop index ix_o_customer_shipping_address_id on o_customer; - -alter table dcredit_drol drop foreign key fk_dcredit_drol_dcredit; -drop index ix_dcredit_drol_dcredit on dcredit_drol; - -alter table dcredit_drol drop foreign key fk_dcredit_drol_drol; -drop index ix_dcredit_drol_drol on dcredit_drol; - -alter table dmachine drop foreign key fk_dmachine_organisation_id; -drop index ix_dmachine_organisation_id on dmachine; - -alter table d_machine_aux_use drop foreign key fk_d_machine_aux_use_machine_id; -drop index ix_d_machine_aux_use_machine_id on d_machine_aux_use; - -alter table d_machine_stats drop foreign key fk_d_machine_stats_machine_id; -drop index ix_d_machine_stats_machine_id on d_machine_stats; - -alter table d_machine_use drop foreign key fk_d_machine_use_machine_id; -drop index ix_d_machine_use_machine_id on d_machine_use; - -alter table drot_drol drop foreign key fk_drot_drol_drot; -drop index ix_drot_drol_drot on drot_drol; - -alter table drot_drol drop foreign key fk_drot_drol_drol; -drop index ix_drot_drol_drol on drot_drol; - -alter table dc_detail drop foreign key fk_dc_detail_master_id; -drop index ix_dc_detail_master_id on dc_detail; - -alter table dfk_cascade drop foreign key fk_dfk_cascade_one_id; -drop index ix_dfk_cascade_one_id on dfk_cascade; - -alter table dfk_set_null drop foreign key fk_dfk_set_null_one_id; -drop index ix_dfk_set_null_one_id on dfk_set_null; - -alter table doc drop foreign key fk_doc_id; - -alter table doc_link drop foreign key fk_doc_link_doc; -drop index ix_doc_link_doc on doc_link; - -alter table doc_link drop foreign key fk_doc_link_link; -drop index ix_doc_link_link on doc_link; - -alter table document drop foreign key fk_document_id; - -alter table document drop foreign key fk_document_organisation_id; -drop index ix_document_organisation_id on document; - -alter table document_draft drop foreign key fk_document_draft_organisation_id; -drop index ix_document_draft_organisation_id on document_draft; - -alter table document_media drop foreign key fk_document_media_document_id; -drop index ix_document_media_document_id on document_media; - -alter table document_media_draft drop foreign key fk_document_media_draft_document_id; -drop index ix_document_media_draft_document_id on document_media_draft; - -alter table ebasic_json_map_detail drop foreign key fk_ebasic_json_map_detail_owner_id; -drop index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail; - -alter table ebasic_no_sdchild drop foreign key fk_ebasic_no_sdchild_owner_id; -drop index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild; - -alter table ebasic_sdchild drop foreign key fk_ebasic_sdchild_owner_id; -drop index ix_ebasic_sdchild_owner_id on ebasic_sdchild; - -alter table ecache_child drop foreign key fk_ecache_child_root_id; -drop index ix_ecache_child_root_id on ecache_child; - -alter table edefault_prop drop foreign key fk_edefault_prop_e_simple_usertypeid; - -alter table eemb_inner drop foreign key fk_eemb_inner_outer_id; -drop index ix_eemb_inner_outer_id on eemb_inner; - -alter table einvoice drop foreign key fk_einvoice_person_id; -drop index ix_einvoice_person_id on einvoice; - -alter table enull_collection_detail drop foreign key fk_enull_collection_detail_enull_collection_id; -drop index ix_enull_collection_detail_enull_collection_id on enull_collection_detail; - -alter table eopt_one_a drop foreign key fk_eopt_one_a_b_id; -drop index ix_eopt_one_a_b_id on eopt_one_a; - -alter table eopt_one_b drop foreign key fk_eopt_one_b_c_id; -drop index ix_eopt_one_b_c_id on eopt_one_b; - -alter table eper_addr drop foreign key fk_eper_addr_ma_country_code; -drop index ix_eper_addr_ma_country_code on eper_addr; - -alter table esoft_del_book drop foreign key fk_esoft_del_book_lend_by_id; -drop index ix_esoft_del_book_lend_by_id on esoft_del_book; - -alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_book; -drop index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user; - -alter table esoft_del_book_esoft_del_user drop foreign key fk_esoft_del_book_esoft_del_user_esoft_del_user; -drop index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user; - -alter table esoft_del_down drop foreign key fk_esoft_del_down_esoft_del_mid_id; -drop index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down; - -alter table esoft_del_mid drop foreign key fk_esoft_del_mid_top_id; -drop index ix_esoft_del_mid_top_id on esoft_del_mid; - -alter table esoft_del_mid drop foreign key fk_esoft_del_mid_up_id; -drop index ix_esoft_del_mid_up_id on esoft_del_mid; - -alter table esoft_del_one_a drop foreign key fk_esoft_del_one_a_oneb_id; - -alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_role; -drop index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user; - -alter table esoft_del_role_esoft_del_user drop foreign key fk_esoft_del_role_esoft_del_user_esoft_del_user; -drop index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user; - -alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_user; -drop index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role; - -alter table esoft_del_user_esoft_del_role drop foreign key fk_esoft_del_user_esoft_del_role_esoft_del_role; -drop index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role; - -alter table rawinherit_uncle drop foreign key fk_rawinherit_uncle_parent_id; -drop index ix_rawinherit_uncle_parent_id on rawinherit_uncle; - -alter table evanilla_collection_detail drop foreign key fk_evanilla_collection_detail_evanilla_collection_id; -drop index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail; - -alter table ec_enum_person_tags drop foreign key fk_ec_enum_person_tags_ec_enum_person_id; -drop index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags; - -alter table ec_person_phone drop foreign key fk_ec_person_phone_owner_id; -drop index ix_ec_person_phone_owner_id on ec_person_phone; - -alter table ecbl_person_phone_numbers drop foreign key fk_ecbl_person_phone_numbers_person_id; -drop index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers; - -alter table ecbm_person_phone_numbers drop foreign key fk_ecbm_person_phone_numbers_person_id; -drop index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers; - -alter table ecm_person_phone_numbers drop foreign key fk_ecm_person_phone_numbers_ecm_person_id; -drop index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers; - -alter table ecmc_person_phone_numbers drop foreign key fk_ecmc_person_phone_numbers_ecmc_person_id; -drop index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers; - -alter table ecs_person_phone drop foreign key fk_ecs_person_phone_ecs_person_id; -drop index ix_ecs_person_phone_ecs_person_id on ecs_person_phone; - -alter table td_child drop foreign key fk_td_child_parent_id; -drop index ix_td_child_parent_id on td_child; - -alter table empl drop foreign key fk_empl_default_address_id; -drop index ix_empl_default_address_id on empl; - -alter table esd_detail drop foreign key fk_esd_detail_master_id; -drop index ix_esd_detail_master_id on esd_detail; - -alter table grand_parent_person drop foreign key fk_grand_parent_person_some_bean_id; -drop index ix_grand_parent_person_some_bean_id on grand_parent_person; - -alter table survey_group drop foreign key fk_survey_group_categoryobjectid; -drop index ix_survey_group_categoryobjectid on survey_group; - -alter table hx_link_doc drop foreign key fk_hx_link_doc_hx_link; -drop index ix_hx_link_doc_hx_link on hx_link_doc; - -alter table hx_link_doc drop foreign key fk_hx_link_doc_he_doc; -drop index ix_hx_link_doc_he_doc on hx_link_doc; - -alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_link; -drop index ix_hi_link_doc_hi_link on hi_link_doc; - -alter table hi_link_doc drop foreign key fk_hi_link_doc_hi_doc; -drop index ix_hi_link_doc_hi_doc on hi_link_doc; - -alter table hi_tthree drop foreign key fk_hi_tthree_hi_ttwo_id; -drop index ix_hi_tthree_hi_ttwo_id on hi_tthree; - -alter table hi_ttwo drop foreign key fk_hi_ttwo_hi_tone_id; -drop index ix_hi_ttwo_hi_tone_id on hi_ttwo; - -alter table hsd_setting drop foreign key fk_hsd_setting_user_id; - -alter table iaf_segment drop foreign key fk_iaf_segment_status_id; -drop index ix_iaf_segment_status_id on iaf_segment; - -alter table imrelated drop foreign key fk_imrelated_owner_id; -drop index ix_imrelated_owner_id on imrelated; - -alter table info_contact drop foreign key fk_info_contact_company_id; -drop index ix_info_contact_company_id on info_contact; - -alter table info_customer drop foreign key fk_info_customer_company_id; - -alter table inner_report drop foreign key fk_inner_report_forecast_id; - -alter table drel_invoice drop foreign key fk_drel_invoice_booking; -drop index ix_drel_invoice_booking on drel_invoice; - -alter table item drop foreign key fk_item_etype; -drop index ix_item_etype on item; - -alter table item drop foreign key fk_item_eregion; -drop index ix_item_eregion on item; - -alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_mkeygroup; - -alter table mkeygroup_monkey drop foreign key fk_mkeygroup_monkey_monkey; - -alter table trainer_monkey drop foreign key fk_trainer_monkey_trainer; - -alter table trainer_monkey drop foreign key fk_trainer_monkey_monkey; - -alter table troop_monkey drop foreign key fk_troop_monkey_troop; - -alter table troop_monkey drop foreign key fk_troop_monkey_monkey; - -alter table l2_cldf_reset_bean_child drop foreign key fk_l2_cldf_reset_bean_child_parent_id; -drop index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child; - -alter table level1_level4 drop foreign key fk_level1_level4_level1; -drop index ix_level1_level4_level1 on level1_level4; - -alter table level1_level4 drop foreign key fk_level1_level4_level4; -drop index ix_level1_level4_level4 on level1_level4; - -alter table level1_level2 drop foreign key fk_level1_level2_level1; -drop index ix_level1_level2_level1 on level1_level2; - -alter table level1_level2 drop foreign key fk_level1_level2_level2; -drop index ix_level1_level2_level2 on level1_level2; - -alter table level2_level3 drop foreign key fk_level2_level3_level2; -drop index ix_level2_level3_level2 on level2_level3; - -alter table level2_level3 drop foreign key fk_level2_level3_level3; -drop index ix_level2_level3_level3 on level2_level3; - -alter table link drop foreign key fk_link_id; - -alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_la_attr_value; -drop index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute; - -alter table la_attr_value_attribute drop foreign key fk_la_attr_value_attribute_attribute; -drop index ix_la_attr_value_attribute_attribute on la_attr_value_attribute; - -alter table looney drop foreign key fk_looney_tune_id; -drop index ix_looney_tune_id on looney; - -alter table mcontact drop foreign key fk_mcontact_customer_id; -drop index ix_mcontact_customer_id on mcontact; - -alter table mcontact_message drop foreign key fk_mcontact_message_contact_id; -drop index ix_mcontact_message_contact_id on mcontact_message; - -alter table mcustomer drop foreign key fk_mcustomer_shipping_address_id; -drop index ix_mcustomer_shipping_address_id on mcustomer; - -alter table mcustomer drop foreign key fk_mcustomer_billing_address_id; -drop index ix_mcustomer_billing_address_id on mcustomer; - -alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mmachine; -drop index ix_mmachine_mgroup_mmachine on mmachine_mgroup; - -alter table mmachine_mgroup drop foreign key fk_mmachine_mgroup_mgroup; -drop index ix_mmachine_mgroup_mgroup on mmachine_mgroup; - -alter table mprinter drop foreign key fk_mprinter_current_state_id; -drop index ix_mprinter_current_state_id on mprinter; - -alter table mprinter drop foreign key fk_mprinter_last_swap_cyan_id; - -alter table mprinter drop foreign key fk_mprinter_last_swap_magenta_id; - -alter table mprinter drop foreign key fk_mprinter_last_swap_yellow_id; - -alter table mprinter drop foreign key fk_mprinter_last_swap_black_id; - -alter table mprinter_state drop foreign key fk_mprinter_state_printer_id; -drop index ix_mprinter_state_printer_id on mprinter_state; - -alter table mprofile drop foreign key fk_mprofile_picture_id; -drop index ix_mprofile_picture_id on mprofile; - -alter table mrole_muser drop foreign key fk_mrole_muser_mrole; -drop index ix_mrole_muser_mrole on mrole_muser; - -alter table mrole_muser drop foreign key fk_mrole_muser_muser; -drop index ix_mrole_muser_muser on mrole_muser; - -alter table muser drop foreign key fk_muser_user_type_id; -drop index ix_muser_user_type_id on muser; - -alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_user; -drop index ix_mail_user_inbox_mail_user on mail_user_inbox; - -alter table mail_user_inbox drop foreign key fk_mail_user_inbox_mail_box; -drop index ix_mail_user_inbox_mail_box on mail_user_inbox; - -alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_user; -drop index ix_mail_user_outbox_mail_user on mail_user_outbox; - -alter table mail_user_outbox drop foreign key fk_mail_user_outbox_mail_box; -drop index ix_mail_user_outbox_mail_box on mail_user_outbox; - -alter table c_message drop foreign key fk_c_message_conversation_id; -drop index ix_c_message_conversation_id on c_message; - -alter table c_message drop foreign key fk_c_message_user_id; -drop index ix_c_message_user_id on c_message; - -alter table meter_contract_data drop foreign key fk_meter_contract_data_special_needs_client_id; - -alter table meter_special_needs_client drop foreign key fk_meter_special_needs_client_primary_id; - -alter table meter_version drop foreign key fk_meter_version_address_data_id; - -alter table meter_version drop foreign key fk_meter_version_contract_data_id; - -alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_user; -drop index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role; - -alter table mnoc_user_mnoc_role drop foreign key fk_mnoc_user_mnoc_role_mnoc_role; -drop index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role; - -alter table mny_b drop foreign key fk_mny_b_a_id; -drop index ix_mny_b_a_id on mny_b; - -alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_b; -drop index ix_mny_b_mny_c_mny_b on mny_b_mny_c; - -alter table mny_b_mny_c drop foreign key fk_mny_b_mny_c_mny_c; -drop index ix_mny_b_mny_c_mny_c on mny_b_mny_c; - -alter table subtopics drop foreign key fk_subtopics_mny_topic_1; -drop index ix_subtopics_mny_topic_1 on subtopics; - -alter table subtopics drop foreign key fk_subtopics_mny_topic_2; -drop index ix_subtopics_mny_topic_2 on subtopics; - -alter table mp_role drop foreign key fk_mp_role_mp_user_id; -drop index ix_mp_role_mp_user_id on mp_role; - -alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_a; -drop index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b; - -alter table ms_many_a_many_b drop foreign key fk_ms_many_a_many_b_ms_many_b; -drop index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b; - -alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_b; -drop index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a; - -alter table ms_many_b_many_a drop foreign key fk_ms_many_b_many_a_ms_many_a; -drop index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a; - -alter table my_lob_size_join_many drop foreign key fk_my_lob_size_join_many_parent_id; -drop index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many; - -alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_cached_bean; -drop index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country; - -alter table o_cached_bean_country drop foreign key fk_o_cached_bean_country_o_country; -drop index ix_o_cached_bean_country_o_country on o_cached_bean_country; - -alter table o_cached_bean_child drop foreign key fk_o_cached_bean_child_cached_bean_id; -drop index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child; - -alter table oengine drop foreign key fk_oengine_car_id; - -alter table ogear_box drop foreign key fk_ogear_box_car_id; - -alter table oroad_show_msg drop foreign key fk_oroad_show_msg_company_id; - -alter table om_ordered_detail drop foreign key fk_om_ordered_detail_master_id; -drop index ix_om_ordered_detail_master_id on om_ordered_detail; - -alter table o_order drop foreign key fk_o_order_kcustomer_id; -drop index ix_o_order_kcustomer_id on o_order; - -alter table o_order_detail drop foreign key fk_o_order_detail_order_id; -drop index ix_o_order_detail_order_id on o_order_detail; - -alter table o_order_detail drop foreign key fk_o_order_detail_product_id; -drop index ix_o_order_detail_product_id on o_order_detail; - -alter table s_order_items drop foreign key fk_s_order_items_order_uuid; -drop index ix_s_order_items_order_uuid on s_order_items; - -alter table or_order_ship drop foreign key fk_or_order_ship_order_id; -drop index ix_or_order_ship_order_id on or_order_ship; - -alter table organization_node drop foreign key fk_organization_node_parent_tree_node_id; - -alter table orp_detail drop foreign key fk_orp_detail_master_id; -drop index ix_orp_detail_master_id on orp_detail; - -alter table orp_detail2 drop foreign key fk_orp_detail2_orp_master2_id; -drop index ix_orp_detail2_orp_master2_id on orp_detail2; - -alter table oto_atwo drop foreign key fk_oto_atwo_aone_id; - -alter table oto_bchild drop foreign key fk_oto_bchild_master_id; - -alter table oto_child drop foreign key fk_oto_child_master_id; - -alter table oto_cust_address drop foreign key fk_oto_cust_address_customer_cid; - -alter table oto_level_a drop foreign key fk_oto_level_a_b_id; - -alter table oto_level_b drop foreign key fk_oto_level_b_c_id; - -alter table oto_prime_extra drop foreign key fk_oto_prime_extra_eid; - -alter table oto_sd_child drop foreign key fk_oto_sd_child_master_id; - -alter table oto_th_many drop foreign key fk_oto_th_many_oto_th_top_id; -drop index ix_oto_th_many_oto_th_top_id on oto_th_many; - -alter table oto_th_one drop foreign key fk_oto_th_one_many_id; - -alter table oto_ubprime_extra drop foreign key fk_oto_ubprime_extra_eid; - -alter table oto_user_model drop foreign key fk_oto_user_model_user_optional_id; - -alter table pfile drop foreign key fk_pfile_file_content_id; - -alter table pfile drop foreign key fk_pfile_file_content2_id; - -alter table paggview drop foreign key fk_paggview_pview_id; - -alter table pallet_location drop foreign key fk_pallet_location_zone_sid; -drop index ix_pallet_location_zone_sid on pallet_location; - -alter table parcel_location drop foreign key fk_parcel_location_parcelid; - -alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_parent; -drop index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data; - -alter table rawinherit_parent_rawinherit_data drop foreign key fk_rawinherit_parent_rawinherit_data_rawinherit_data; -drop index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data; - -alter table parent_person drop foreign key fk_parent_person_some_bean_id; -drop index ix_parent_person_some_bean_id on parent_person; - -alter table parent_person drop foreign key fk_parent_person_parent_identifier; -drop index ix_parent_person_parent_identifier on parent_person; - -alter table c_participation drop foreign key fk_c_participation_conversation_id; -drop index ix_c_participation_conversation_id on c_participation; - -alter table c_participation drop foreign key fk_c_participation_user_id; -drop index ix_c_participation_user_id on c_participation; - -alter table persistent_file_content drop foreign key fk_persistent_file_content_persistent_file_id; - -alter table person drop foreign key fk_person_default_address_oid; -drop index ix_person_default_address_oid on person; - -alter table person_cache_email drop foreign key fk_person_cache_email_person_info_person_id; -drop index ix_person_cache_email_person_info_person_id on person_cache_email; - -alter table phones drop foreign key fk_phones_person_id; -drop index ix_phones_person_id on phones; - -alter table e_position drop foreign key fk_e_position_contract_id; -drop index ix_e_position_contract_id on e_position; - -alter table pp_to_ww drop foreign key fk_pp_to_ww_pp; -drop index ix_pp_to_ww_pp on pp_to_ww; - -alter table pp_to_ww drop foreign key fk_pp_to_ww_wview; -drop index ix_pp_to_ww_wview on pp_to_ww; - -alter table question drop foreign key fk_question_groupobjectid; -drop index ix_question_groupobjectid on question; - -alter table r_orders drop foreign key fk_r_orders_customer; -drop index ix_r_orders_customer on r_orders; - -alter table rel_master drop foreign key fk_rel_master_detail_id; -drop index ix_rel_master_detail_id on rel_master; - -alter table resourcefile drop foreign key fk_resourcefile_parentresourcefileid; -drop index ix_resourcefile_parentresourcefileid on resourcefile; - -alter table mt_role drop foreign key fk_mt_role_tenant_id; -drop index ix_mt_role_tenant_id on mt_role; - -alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_role; -drop index ix_mt_role_permission_mt_role on mt_role_permission; - -alter table mt_role_permission drop foreign key fk_mt_role_permission_mt_permission; -drop index ix_mt_role_permission_mt_permission on mt_role_permission; - -alter table f_second drop foreign key fk_f_second_first; - -alter table section drop foreign key fk_section_article_id; -drop index ix_section_article_id on section; - -alter table self_parent drop foreign key fk_self_parent_parent_id; -drop index ix_self_parent_parent_id on self_parent; - -alter table self_ref_customer drop foreign key fk_self_ref_customer_referred_by_id; -drop index ix_self_ref_customer_referred_by_id on self_ref_customer; - -alter table self_ref_example drop foreign key fk_self_ref_example_parent_id; -drop index ix_self_ref_example_parent_id on self_ref_example; - -alter table e_save_test_b drop foreign key fk_e_save_test_b_sibling_a_id; - -alter table site drop foreign key fk_site_parent_id; -drop index ix_site_parent_id on site; - -alter table site drop foreign key fk_site_data_container_id; - -alter table site drop foreign key fk_site_site_address_id; - -alter table stockforecast drop foreign key fk_stockforecast_inner_report_id; -drop index ix_stockforecast_inner_report_id on stockforecast; - -alter table sub_section drop foreign key fk_sub_section_section_id; -drop index ix_sub_section_section_id on sub_section; - -alter table tevent_many drop foreign key fk_tevent_many_event_id; -drop index ix_tevent_many_event_id on tevent_many; - -alter table tevent_one drop foreign key fk_tevent_one_event_id; - -alter table t_detail_with_other_namexxxyy drop foreign key fk_t_detail_with_other_namexxxyy_master_id; -drop index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy; - -alter table ts_detail_two drop foreign key fk_ts_detail_two_master_id; -drop index ix_ts_detail_two_master_id on ts_detail_two; - -alter table twheel drop foreign key fk_twheel_owner_plate_no; -drop index ix_twheel_owner_plate_no on twheel; - -alter table tire drop foreign key fk_tire_wheel; - -alter table trip drop foreign key fk_trip_vehicle_driver_id; -drop index ix_trip_vehicle_driver_id on trip; - -alter table trip drop foreign key fk_trip_address_id; -drop index ix_trip_address_id on trip; - -alter table `type` drop foreign key fk_type_sub_type_id; -drop index ix_type_sub_type_id on `type`; - -alter table usib_child drop foreign key fk_usib_child_parent_id; -drop index ix_usib_child_parent_id on usib_child; - -alter table usib_child_sibling drop foreign key fk_usib_child_sibling_child_id; - -alter table ut_detail drop foreign key fk_ut_detail_utmaster_id; -drop index ix_ut_detail_utmaster_id on ut_detail; - -alter table uutwo drop foreign key fk_uutwo_master_id; -drop index ix_uutwo_master_id on uutwo; - -alter table oto_user drop foreign key fk_oto_user_account_id; - -alter table c_user drop foreign key fk_c_user_group_id; -drop index ix_c_user_group_id on c_user; - -alter table em_user_role drop foreign key fk_em_user_role_user_id; -drop index ix_em_user_role_user_id on em_user_role; - -alter table em_user_role drop foreign key fk_em_user_role_role_id; -drop index ix_em_user_role_role_id on em_user_role; - -alter table vehicle drop foreign key fk_vehicle_lease_id; -drop index ix_vehicle_lease_id on vehicle; - -alter table vehicle drop foreign key fk_vehicle_car_ref_id; -drop index ix_vehicle_car_ref_id on vehicle; - -alter table vehicle drop foreign key fk_vehicle_truck_ref_id; -drop index ix_vehicle_truck_ref_id on vehicle; - -alter table vehicle_driver drop foreign key fk_vehicle_driver_vehicle_id; -drop index ix_vehicle_driver_vehicle_id on vehicle_driver; - -alter table vehicle_driver drop foreign key fk_vehicle_driver_address_id; -drop index ix_vehicle_driver_address_id on vehicle_driver; - -alter table warehouses drop foreign key fk_warehouses_officezoneid; -drop index ix_warehouses_officezoneid on warehouses; - -alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_warehouses; -drop index ix_warehousesshippingzones_warehouses on warehousesshippingzones; - -alter table warehousesshippingzones drop foreign key fk_warehousesshippingzones_zones; -drop index ix_warehousesshippingzones_zones on warehousesshippingzones; - -alter table sa_wheel drop foreign key fk_sa_wheel_tire; -drop index ix_sa_wheel_tire on sa_wheel; - -alter table sa_wheel drop foreign key fk_sa_wheel_car; -drop index ix_sa_wheel_car on sa_wheel; - -alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_created_id; -drop index ix_g_who_props_otm_who_created_id on g_who_props_otm; - -alter table g_who_props_otm drop foreign key fk_g_who_props_otm_who_modified_id; -drop index ix_g_who_props_otm_who_modified_id on g_who_props_otm; - -alter table with_zero drop foreign key fk_with_zero_parent_id; -drop index ix_with_zero_parent_id on with_zero; - -drop table if exists asimple_bean; - -drop table if exists bar; - -drop table if exists block; - -drop table if exists oto_account; - -drop table if exists acl; - -drop table if exists acl_container_relation; - -drop table if exists addr; - -drop table if exists address; - -drop table if exists o_address; - -drop table if exists album; - -drop table if exists animal; - -drop table if exists animal_shelter; - -drop table if exists article; - -drop table if exists attribute; - -drop table if exists attribute_holder; - -drop table if exists audit_log; - -drop table if exists bbookmark; - -drop table if exists bbookmark_org; - -drop table if exists bbookmark_user; - -drop table if exists bsimple_with_gen; - -drop table if exists bsite; - -drop table if exists bsite_user_a; - -drop table if exists bsite_user_b; - -drop table if exists bsite_user_c; - -drop table if exists bsite_user_d; - -drop table if exists bsite_user_e; - -drop table if exists buser; - -drop table if exists bwith_qident; - -drop table if exists basic_draftable_bean; - -drop table if exists basic_draftable_bean_draft; - -drop table if exists basic_joda_entity; - -drop table if exists bean_with_time_zone; - -drop table if exists drel_booking; - -drop table if exists bw_bean; - -drop table if exists cepcategory; - -drop table if exists cepproduct; - -drop table if exists cepproduct_category; - -drop table if exists cinh_ref; - -drop table if exists cinh_root; - -drop table if exists ckey_assoc; - -drop table if exists ckey_detail; - -drop table if exists ckey_parent; - -drop table if exists calculation_result; - -drop table if exists cao_bean; - -drop table if exists sp_car_car; - -drop table if exists sp_car_car_wheels; - -drop table if exists sp_car_car_doors; - -drop table if exists sa_car; - -drop table if exists car_accessory; - -drop table if exists car_fuse; - -drop table if exists category; - -drop table if exists e_save_test_d; - -drop table if exists child_person; - -drop table if exists cke_client; - -drop table if exists cke_user; - -drop table if exists class_super; - -drop table if exists class_super_monkey; - -drop table if exists configuration; - -drop table if exists configurations; - -drop table if exists contact; - -drop table if exists contact_group; - -drop table if exists contact_note; - -drop table if exists contract; - -drop table if exists contract_costs; - -drop table if exists c_conversation; - -drop table if exists o_country; - -drop table if exists cover; - -drop table if exists o_customer; - -drop table if exists dcredit; - -drop table if exists dcredit_drol; - -drop table if exists dexh_entity; - -drop table if exists dmachine; - -drop table if exists d_machine_aux_use; - -drop table if exists d_machine_stats; - -drop table if exists d_machine_use; - -drop table if exists dorg; - -drop table if exists dperson; - -drop table if exists drol; - -drop table if exists drot; - -drop table if exists drot_drol; - -drop table if exists rawinherit_data; - -drop table if exists data_container; - -drop table if exists dc_detail; - -drop table if exists dc_master; - -drop table if exists dfk_cascade; - -drop table if exists dfk_cascade_one; - -drop table if exists dfk_none; - -drop table if exists dfk_none_via_join; - -drop table if exists dfk_none_via_mto_m; - -drop table if exists dfk_none_via_mto_m_dfk_one; - -drop table if exists dfk_one; - -drop table if exists dfk_set_null; - -drop table if exists doc; - -drop table if exists doc_link; - -drop table if exists doc_link_draft; - -drop table if exists doc_draft; - -drop table if exists document; - -drop table if exists document_draft; - -drop table if exists document_media; - -drop table if exists document_media_draft; - -drop table if exists sp_car_door; - -drop table if exists earray_bean; - -drop table if exists earray_set_bean; - -drop table if exists e_basic; - -drop table if exists ebasic_change_log; - -drop table if exists ebasic_clob; - -drop table if exists ebasic_clob_fetch_eager; - -drop table if exists ebasic_clob_no_ver; - -drop table if exists e_basicenc; - -drop table if exists e_basicenc_bin; - -drop table if exists e_basicenc_client; - -drop table if exists e_basic_enum_id; - -drop table if exists e_basic_eni; - -drop table if exists ebasic_hstore; - -drop table if exists ebasic_json_jackson; - -drop table if exists ebasic_json_jackson2; - -drop table if exists ebasic_json_list; - -drop table if exists ebasic_json_map; - -drop table if exists ebasic_json_map_blob; - -drop table if exists ebasic_json_map_clob; - -drop table if exists ebasic_json_map_detail; - -drop table if exists ebasic_json_map_json_b; - -drop table if exists ebasic_json_map_varchar; - -drop table if exists ebasic_json_node; - -drop table if exists ebasic_json_node_blob; - -drop table if exists ebasic_json_node_json_b; - -drop table if exists ebasic_json_node_varchar; - -drop table if exists ebasic_json_unmapped; - -drop table if exists e_basic_ndc; - -drop table if exists ebasic_no_sdchild; - -drop table if exists ebasic_sdchild; - -drop table if exists ebasic_soft_delete; - -drop table if exists e_basicver; - -drop table if exists e_basic_withlife; - -drop table if exists e_basic_with_ex; - -drop table if exists e_basicverucon; - -drop table if exists ecache_child; - -drop table if exists ecache_root; - -drop table if exists e_col_ab; - -drop table if exists ecustom_id; - -drop table if exists edefault_prop; - -drop table if exists eemb_inner; - -drop table if exists eemb_outer; - -drop table if exists efile2_no_fk; - -drop table if exists efile_no_fk; - -drop table if exists efile_no_fk_euser_no_fk; - -drop table if exists efile_no_fk_euser_no_fk_soft_del; - -drop table if exists egen_props; - -drop table if exists einvoice; - -drop table if exists e_main; - -drop table if exists enull_collection; - -drop table if exists enull_collection_detail; - -drop table if exists eopt_one_a; - -drop table if exists eopt_one_b; - -drop table if exists eopt_one_c; - -drop table if exists eper_addr; - -drop table if exists eperson; - -drop table if exists e_person_online; - -drop table if exists esimple; - -drop table if exists esoft_del_book; - -drop table if exists esoft_del_book_esoft_del_user; - -drop table if exists esoft_del_down; - -drop table if exists esoft_del_mid; - -drop table if exists esoft_del_one_a; - -drop table if exists esoft_del_one_b; - -drop table if exists esoft_del_role; - -drop table if exists esoft_del_role_esoft_del_user; - -drop table if exists esoft_del_top; - -drop table if exists esoft_del_up; - -drop table if exists esoft_del_user; - -drop table if exists esoft_del_user_esoft_del_role; - -drop table if exists esome_convert_type; - -drop table if exists esome_type; - -drop table if exists etrans_many; - -drop table if exists rawinherit_uncle; - -drop table if exists euser_no_fk; - -drop table if exists euser_no_fk_soft_del; - -drop table if exists evanilla_collection; - -drop table if exists evanilla_collection_detail; - -drop table if exists ewho_props; - -drop table if exists e_withinet; - -drop table if exists ec_enum_person; - -drop table if exists ec_enum_person_tags; - -drop table if exists ec_person; - -drop table if exists ec_person_phone; - -drop table if exists ecbl_person; - -drop table if exists ecbl_person_phone_numbers; - -drop table if exists ecbm_person; - -drop table if exists ecbm_person_phone_numbers; - -drop table if exists ecm_person; - -drop table if exists ecm_person_phone_numbers; - -drop table if exists ecmc_person; - -drop table if exists ecmc_person_phone_numbers; - -drop table if exists ecs_person; - -drop table if exists ecs_person_phone; - -drop table if exists td_child; - -drop table if exists td_parent; - -drop table if exists empl; - -drop table if exists esd_detail; - -drop table if exists esd_master; - -drop table if exists feature_desc; - -drop table if exists f_first; - -drop table if exists foo; - -drop table if exists gen_key_identity; - -drop table if exists gen_key_sequence; - -drop table if exists gen_key_table; - -drop table if exists grand_parent_person; - -drop table if exists survey_group; - -drop table if exists c_group; - -drop table if exists he_doc; - -drop trigger hx_link_history_upd; -drop trigger hx_link_history_del; -drop view hx_link_with_history; -CALL usp_ebean_drop_column('hx_link', 'sys_period_start'); -CALL usp_ebean_drop_column('hx_link', 'sys_period_end'); -drop table hx_link_history; - -drop table if exists hx_link; - -drop table if exists hx_link_doc; - -drop table if exists hi_doc; - -drop trigger hi_link_history_upd; -drop trigger hi_link_history_del; -drop view hi_link_with_history; -CALL usp_ebean_drop_column('hi_link', 'sys_period_start'); -CALL usp_ebean_drop_column('hi_link', 'sys_period_end'); -drop table hi_link_history; - -drop table if exists hi_link; - -drop trigger hi_link_doc_history_upd; -drop trigger hi_link_doc_history_del; -drop view hi_link_doc_with_history; -CALL usp_ebean_drop_column('hi_link_doc', 'sys_period_start'); -CALL usp_ebean_drop_column('hi_link_doc', 'sys_period_end'); -drop table hi_link_doc_history; - -drop table if exists hi_link_doc; - -drop trigger hi_tone_history_upd; -drop trigger hi_tone_history_del; -drop view hi_tone_with_history; -CALL usp_ebean_drop_column('hi_tone', 'sys_period_start'); -CALL usp_ebean_drop_column('hi_tone', 'sys_period_end'); -drop table hi_tone_history; - -drop table if exists hi_tone; - -drop trigger hi_tthree_history_upd; -drop trigger hi_tthree_history_del; -drop view hi_tthree_with_history; -CALL usp_ebean_drop_column('hi_tthree', 'sys_period_start'); -CALL usp_ebean_drop_column('hi_tthree', 'sys_period_end'); -drop table hi_tthree_history; - -drop table if exists hi_tthree; - -drop trigger hi_ttwo_history_upd; -drop trigger hi_ttwo_history_del; -drop view hi_ttwo_with_history; -CALL usp_ebean_drop_column('hi_ttwo', 'sys_period_start'); -CALL usp_ebean_drop_column('hi_ttwo', 'sys_period_end'); -drop table hi_ttwo_history; - -drop table if exists hi_ttwo; - -drop trigger hsd_setting_history_upd; -drop trigger hsd_setting_history_del; -drop view hsd_setting_with_history; -CALL usp_ebean_drop_column('hsd_setting', 'sys_period_start'); -CALL usp_ebean_drop_column('hsd_setting', 'sys_period_end'); -drop table hsd_setting_history; - -drop table if exists hsd_setting; - -drop trigger hsd_user_history_upd; -drop trigger hsd_user_history_del; -drop view hsd_user_with_history; -CALL usp_ebean_drop_column('hsd_user', 'sys_period_start'); -CALL usp_ebean_drop_column('hsd_user', 'sys_period_end'); -drop table hsd_user_history; - -drop table if exists hsd_user; - -drop table if exists iaf_segment; - -drop table if exists iaf_segment_status; - -drop table if exists imrelated; - -drop table if exists imroot; - -drop table if exists ixresource; - -drop table if exists info_company; - -drop table if exists info_contact; - -drop table if exists info_customer; - -drop table if exists inner_report; - -drop table if exists drel_invoice; - -drop table if exists item; - -drop table if exists monkey; - -drop table if exists mkeygroup; - -drop table if exists mkeygroup_monkey; - -drop table if exists trainer; - -drop table if exists trainer_monkey; - -drop table if exists troop; - -drop table if exists troop_monkey; - -drop table if exists l2_cldf_reset_bean; - -drop table if exists l2_cldf_reset_bean_child; - -drop table if exists level1; - -drop table if exists level1_level4; - -drop table if exists level1_level2; - -drop table if exists level2; - -drop table if exists level2_level3; - -drop table if exists level3; - -drop table if exists level4; - -drop trigger link_history_upd; -drop trigger link_history_del; -drop view link_with_history; -CALL usp_ebean_drop_column('link', 'sys_period_start'); -CALL usp_ebean_drop_column('link', 'sys_period_end'); -drop table link_history; - -drop table if exists link; - -drop table if exists link_draft; - -drop table if exists la_attr_value; - -drop table if exists la_attr_value_attribute; - -drop table if exists looney; - -drop table if exists maddress; - -drop table if exists mcontact; - -drop table if exists mcontact_message; - -drop table if exists mcustomer; - -drop table if exists mgroup; - -drop table if exists mmachine; - -drop table if exists mmachine_mgroup; - -drop table if exists mmedia; - -drop table if exists non_updateprop; - -drop table if exists mprinter; - -drop table if exists mprinter_state; - -drop table if exists mprofile; - -drop table if exists mprotected_construct_bean; - -drop table if exists mrole; - -drop table if exists mrole_muser; - -drop table if exists msome_other; - -drop table if exists muser; - -drop table if exists muser_type; - -drop table if exists mail_box; - -drop table if exists mail_user; - -drop table if exists mail_user_inbox; - -drop table if exists mail_user_outbox; - -drop table if exists main_entity; - -drop table if exists main_entity_relation; - -drop table if exists map_super_actual; - -drop table if exists c_message; - -drop table if exists meter_address_data; - -drop table if exists meter_contract_data; - -drop table if exists meter_special_needs_client; - -drop table if exists meter_special_needs_contact; - -drop table if exists meter_version; - -drop table if exists mnoc_role; - -drop table if exists mnoc_user; - -drop table if exists mnoc_user_mnoc_role; - -drop table if exists mny_a; - -drop table if exists mny_b; - -drop table if exists mny_b_mny_c; - -drop table if exists mny_c; - -drop table if exists mny_topic; - -drop table if exists subtopics; - -drop table if exists mp_role; - -drop table if exists mp_user; - -drop table if exists ms_many_a; - -drop table if exists ms_many_a_many_b; - -drop table if exists ms_many_b; - -drop table if exists ms_many_b_many_a; - -drop table if exists my_lob_size; - -drop table if exists my_lob_size_join_many; - -drop table if exists noidbean; - -drop table if exists o_cached_bean; - -drop table if exists o_cached_bean_country; - -drop table if exists o_cached_bean_child; - -drop table if exists o_cached_inherit; - -drop table if exists o_cached_natkey; - -drop table if exists o_cached_natkey3; - -drop table if exists ocar; - -drop table if exists ocompany; - -drop table if exists oengine; - -drop table if exists ogear_box; - -drop table if exists oroad_show_msg; - -drop table if exists om_ordered_detail; - -drop table if exists om_ordered_master; - -drop table if exists only_id_entity; - -drop table if exists o_order; - -drop table if exists o_order_detail; - -drop table if exists s_orders; - -drop table if exists s_order_items; - -drop table if exists or_order_ship; - -drop table if exists organisation; - -drop table if exists organization_node; - -drop table if exists organization_tree_node; - -drop table if exists orp_detail; - -drop table if exists orp_detail2; - -drop table if exists orp_master; - -drop table if exists orp_master2; - -drop table if exists oto_aone; - -drop table if exists oto_atwo; - -drop table if exists oto_bchild; - -drop table if exists oto_bmaster; - -drop table if exists oto_child; - -drop table if exists oto_cust; - -drop table if exists oto_cust_address; - -drop table if exists oto_level_a; - -drop table if exists oto_level_b; - -drop table if exists oto_level_c; - -drop table if exists oto_master; - -drop table if exists oto_prime; - -drop table if exists oto_prime_extra; - -drop table if exists oto_sd_child; - -drop table if exists oto_sd_master; - -drop table if exists oto_th_many; - -drop table if exists oto_th_one; - -drop table if exists oto_th_top; - -drop table if exists oto_ubprime; - -drop table if exists oto_ubprime_extra; - -drop table if exists oto_uprime; - -drop table if exists oto_uprime_extra; - -drop table if exists oto_user_model; - -drop table if exists oto_user_model_optional; - -drop table if exists pfile; - -drop table if exists pfile_content; - -drop table if exists paggview; - -drop table if exists pallet_location; - -drop table if exists parcel; - -drop table if exists parcel_location; - -drop table if exists rawinherit_parent; - -drop table if exists rawinherit_parent_rawinherit_data; - -drop table if exists e_save_test_c; - -drop table if exists parent_person; - -drop table if exists c_participation; - -drop table if exists password_store_model; - -drop table if exists mt_permission; - -drop table if exists persistent_file; - -drop table if exists persistent_file_content; - -drop table if exists person; - -drop table if exists persons; - -drop table if exists person_cache_email; - -drop table if exists person_cache_info; - -drop table if exists phones; - -drop table if exists e_position; - -drop table if exists primary_revision; - -drop table if exists o_product; - -drop table if exists pp; - -drop table if exists pp_to_ww; - -drop table if exists question; - -drop table if exists rcustomer; - -drop table if exists r_orders; - -drop table if exists region; - -drop table if exists rel_detail; - -drop table if exists rel_master; - -drop table if exists resourcefile; - -drop table if exists mt_role; - -drop table if exists mt_role_permission; - -drop table if exists em_role; - -drop table if exists f_second; - -drop table if exists section; - -drop table if exists self_parent; - -drop table if exists self_ref_customer; - -drop table if exists self_ref_example; - -drop table if exists e_save_test_a; - -drop table if exists e_save_test_b; - -drop table if exists site; - -drop table if exists site_address; - -drop table if exists some_enum_bean; - -drop table if exists some_file_bean; - -drop table if exists some_new_types_bean; - -drop table if exists some_period_bean; - -drop table if exists stockforecast; - -drop table if exists sub_section; - -drop table if exists sub_type; - -drop table if exists survey; - -drop table if exists tbytes_only; - -drop table if exists tcar; - -drop table if exists tevent; - -drop table if exists tevent_many; - -drop table if exists tevent_one; - -drop table if exists tint_root; - -drop table if exists tjoda_entity; - -drop table if exists t_mapsuper1; - -drop table if exists t_oneb; - -drop table if exists t_detail_with_other_namexxxyy; - -drop table if exists ts_detail_two; - -drop table if exists t_atable_thatisrelatively; - -drop table if exists ts_master_two; - -drop table if exists tuuid_entity; - -drop table if exists twheel; - -drop table if exists twith_pre_insert; - -drop table if exists mt_tenant; - -drop table if exists test_annotation_base_entity; - -drop table if exists tire; - -drop table if exists sa_tire; - -drop table if exists trip; - -drop table if exists truck_ref; - -drop table if exists tune; - -drop table if exists `type`; - -drop table if exists tz_bean; - -drop table if exists usib_child; - -drop table if exists usib_child_sibling; - -drop table if exists usib_parent; - -drop table if exists ut_detail; - -drop table if exists ut_master; - -drop table if exists uuone; - -drop table if exists uutwo; - -drop table if exists oto_user; - -drop trigger c_user_history_upd; -drop trigger c_user_history_del; -drop view c_user_with_history; -CALL usp_ebean_drop_column('c_user', 'sys_period_start'); -CALL usp_ebean_drop_column('c_user', 'sys_period_end'); -drop table c_user_history; - -drop table if exists c_user; - -drop table if exists tx_user; - -drop table if exists g_user; - -drop table if exists em_user; - -drop table if exists em_user_role; - -drop table if exists vehicle; - -drop table if exists vehicle_driver; - -drop table if exists vehicle_lease; - -drop table if exists warehouses; - -drop table if exists warehousesshippingzones; - -drop table if exists wheel; - -drop table if exists sa_wheel; - -drop table if exists sp_car_wheel; - -drop table if exists g_who_props_otm; - -drop table if exists with_zero; - -drop table if exists parent; - -drop table if exists wview; - -drop table if exists zones; - -drop index ix_contact_last_name_first_name on contact; -drop index ix_e_basic_name on e_basic; -drop index ix_efile2_no_fk_owner_id on efile2_no_fk; -drop index ix_organization_node_kind on organization_node; diff --git a/ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql deleted file mode 100644 index cc4dc83..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_nuodb/1.1__initial.sql +++ /dev/null @@ -1,45 +0,0 @@ -create table m1 -( - id integer, - acol varchar(20) -); - -create table m2 -( - id integer, - acol varchar(20), - bcol timestamp -); - - -create table orp_master ( -id varchar(100) not null, -name varchar(255), -version bigint not null, -constraint pk_orp_master primary key (id) -); - -alter table orp_master add column sys_period_start datetime(6) default now(); -alter table orp_master add column sys_period_end datetime(6); - -create table orp_master_history ( -id varchar(100) not null, -name varchar(255), -version bigint not null, -sys_period_start datetime(6), -sys_period_end datetime(6) -); - -create view orp_master_with_history as - select * from orp_master union all - select * from orp_master_history; - -delimiter $$ -create or replace trigger orp_master_history_upd - for orp_master - before update for each row as - NEW.sys_period_start = greatest(current_timestamp , date_add(OLD.sys_period_start,interval 1 microsecond)); - insert into orp_master_history (sys_period_start,sys_period_end,id, name, version) - values (OLD.sys_period_start, NEW.sys_period_start, OLD.id, OLD.name, OLD.version); - end_trigger -$$ diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_oracle/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql deleted file mode 100644 index 76a6be8..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_oracle/1.2__add_m3.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m3 (id integer, acol varchar(20)); - -alter table m1 add addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql deleted file mode 100644 index 63a4934..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_oracle/I__hello.sql +++ /dev/null @@ -1 +0,0 @@ --- do nothing diff --git a/ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql deleted file mode 100644 index 6a7c4df..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_oracle/R__m2_view.sql +++ /dev/null @@ -1 +0,0 @@ -create or replace view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql b/ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql deleted file mode 100644 index 7bd7082..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres/ex1.sql +++ /dev/null @@ -1,14 +0,0 @@ -create or replace function hx_link_history_version() returns trigger as $$ -begin - -end; -$$ LANGUAGE plpgsql; - -create trigger hx_link_history_upd - before update or delete on hx_link - for each row execute procedure hx_link_history_version(); - -create or replace function hi_link_history_version() returns trigger as $$ -begin -end; -$$ LANGUAGE plpgsql; diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql b/ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql deleted file mode 100644 index 30e9b2e..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres/pg-create-all.sql +++ /dev/null @@ -1,4745 +0,0 @@ --- Generated by ebean unknown at 2019-07-24T11:42:58.489Z -create table asimple_bean ( - id bigserial not null, - name varchar(255), - constraint pk_asimple_bean primary key (id) -); - -create table bar ( - bar_type varchar(31) not null, - bar_id serial not null, - foo_id integer not null, - version integer not null, - constraint pk_bar primary key (bar_id) -); - -create table block ( - case_type integer not null, - id bigserial not null, - name varchar(255), - version bigint not null, - notes varchar(255), - constraint pk_block primary key (id) -); - -create table oto_account ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_oto_account primary key (id) -); - -create table acl ( - id bigserial not null, - name varchar(255), - constraint pk_acl primary key (id) -); - -create table acl_container_relation ( - id bigserial not null, - container_id bigint not null, - acl_entry_id bigint not null, - constraint pk_acl_container_relation primary key (id) -); - -create table addr ( - id bigserial not null, - employee_id bigint, - name varchar(255), - address_line1 varchar(255), - address_line2 varchar(255), - city varchar(255), - version bigint not null, - constraint pk_addr primary key (id) -); - -create table address ( - oid bigserial not null, - street varchar(255), - version integer not null, - constraint pk_address primary key (oid) -); - -create table o_address ( - id smallserial not null, - line_1 varchar(100), - line_2 varchar(100), - city varchar(100), - cretime timestamptz, - country_code varchar(2), - updtime timestamptz not null, - constraint pk_o_address primary key (id) -); - -create table album ( - id bigserial not null, - name varchar(255), - cover_id bigint, - deleted boolean default false not null, - created_at timestamptz not null, - last_update timestamptz not null, - constraint uq_album_cover_id unique (cover_id), - constraint pk_album primary key (id) -); - -create table animal ( - species varchar(255) not null, - id bigserial not null, - shelter_id bigint, - version bigint not null, - name varchar(255), - registration_number varchar(255), - date_of_birth date, - dog_size varchar(255), - constraint pk_animal primary key (id) -); - -create table animal_shelter ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_animal_shelter primary key (id) -); - -create table article ( - id serial not null, - name varchar(255), - author varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_article primary key (id) -); - -create table attribute ( - option_type integer not null, - id serial not null, - attribute_holder_id integer, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_attribute primary key (id) -); - -create table attribute_holder ( - id serial not null, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_attribute_holder primary key (id) -); - -create table audit_log ( - id bigserial not null, - description varchar(255), - modified_description varchar(255), - constraint pk_audit_log primary key (id) -); - -create table bbookmark ( - id serial not null, - bookmark_reference varchar(255), - user_id integer, - constraint pk_bbookmark primary key (id) -); - -create table bbookmark_org ( - id serial not null, - name varchar(255), - constraint pk_bbookmark_org primary key (id) -); - -create table bbookmark_user ( - id serial not null, - name varchar(255), - password varchar(255), - email_address varchar(255), - country varchar(255), - org_id integer, - constraint pk_bbookmark_user primary key (id) -); - -create table bsimple_with_gen ( - id serial not null, - name varchar(255), - constraint pk_bsimple_with_gen primary key (id) -); - -create table bsite ( - id uuid not null, - name varchar(255), - constraint pk_bsite primary key (id) -); - -create table bsite_user_a ( - site_id uuid not null, - user_id uuid not null, - access_level integer, - version bigint not null, - constraint ck_bsite_user_a_access_level check ( access_level in (0,1,2)), - constraint pk_bsite_user_a primary key (site_id,user_id) -); - -create table bsite_user_b ( - site uuid not null, - usr uuid not null, - access_level integer, - constraint ck_bsite_user_b_access_level check ( access_level in (0,1,2)), - constraint pk_bsite_user_b primary key (site,usr) -); - -create table bsite_user_c ( - site_uid uuid not null, - user_uid uuid not null, - access_level integer, - constraint ck_bsite_user_c_access_level check ( access_level in (0,1,2)), - constraint pk_bsite_user_c primary key (site_uid,user_uid) -); - -create table bsite_user_d ( - site_id uuid not null, - user_id uuid not null, - access_level integer, - version bigint not null, - constraint ck_bsite_user_d_access_level check ( access_level in (0,1,2)) -); - -create table bsite_user_e ( - site_id uuid not null, - user_id uuid not null, - access_level integer, - constraint ck_bsite_user_e_access_level check ( access_level in (0,1,2)) -); - -create table buser ( - id uuid not null, - name varchar(255), - constraint pk_buser primary key (id) -); - -create table bwith_qident ( - id serial not null, - "Name" varchar(191), - "CODE" varchar(255), - last_updated timestamptz not null, - constraint uq_bwith_qident_name unique ("Name"), - constraint pk_bwith_qident primary key (id) -); - -create table basic_draftable_bean ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_basic_draftable_bean primary key (id) -); - -create table basic_draftable_bean_draft ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_basic_draftable_bean_draft primary key (id) -); - -create table basic_joda_entity ( - id bigserial not null, - name varchar(255), - period varchar(50), - local_date date, - created timestamptz not null, - updated timestamptz not null, - version timestamptz not null, - constraint pk_basic_joda_entity primary key (id) -); - -create table bean_with_time_zone ( - id bigserial not null, - name varchar(255), - timezone varchar(20), - constraint pk_bean_with_time_zone primary key (id) -); - -create table drel_booking ( - id bigint not null, - booking_uid bigint, - agent_invoice bigint, - client_invoice bigint, - version integer not null, - constraint uq_drel_booking_booking_uid unique (booking_uid), - constraint uq_drel_booking_agent_invoice unique (agent_invoice), - constraint uq_drel_booking_client_invoice unique (client_invoice), - constraint pk_drel_booking primary key (id) -); -create sequence drel_booking_seq; - -create table bw_bean ( - id bigserial not null, - name varchar(255), - flags integer not null, - version bigint not null, - constraint pk_bw_bean primary key (id) -); - -create table cepcategory ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_cepcategory primary key (id) -); - -create table cepproduct ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_cepproduct primary key (id) -); - -create table cepproduct_category ( - customer_id bigint not null, - address_id bigint not null, - category_id bigint not null, - product_id bigint not null, - priority integer -); - -create table cinh_ref ( - id serial not null, - ref_id integer, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_cinh_ref primary key (id) -); - -create table cinh_root ( - dtype varchar(3) not null, - id serial not null, - license_number varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - driver varchar(255), - notes varchar(255), - action varchar(255), - constraint pk_cinh_root primary key (id) -); - -create table ckey_assoc ( - id serial not null, - assoc_one varchar(255), - constraint pk_ckey_assoc primary key (id) -); - -create table ckey_detail ( - id serial not null, - something varchar(255), - one_key integer, - two_key varchar(127), - constraint pk_ckey_detail primary key (id) -); - -create table ckey_parent ( - one_key integer not null, - two_key varchar(127) not null, - name varchar(255), - assoc_id integer, - version integer not null, - constraint pk_ckey_parent primary key (one_key,two_key) -); - -create table calculation_result ( - id serial not null, - charge float not null, - product_configuration_id integer, - group_configuration_id integer, - constraint pk_calculation_result primary key (id) -); - -create table cao_bean ( - x_cust_id integer not null, - x_type_id integer not null, - description varchar(255), - version bigint not null, - constraint pk_cao_bean primary key (x_cust_id,x_type_id) -); - -create table sp_car_car ( - id bigint not null, - name varchar(255), - version integer not null, - constraint pk_sp_car_car primary key (id) -); -create sequence sp_car_car_seq; - -create table sp_car_car_wheels ( - car bigint not null, - wheel bigint not null, - constraint pk_sp_car_car_wheels primary key (car,wheel) -); - -create table sp_car_car_doors ( - car bigint not null, - door bigint not null, - constraint pk_sp_car_car_doors primary key (car,door) -); - -create table sa_car ( - id bigint not null, - version integer not null, - constraint pk_sa_car primary key (id) -); -create sequence sa_car_seq; - -create table car_accessory ( - id serial not null, - name varchar(255), - fuse_id bigint not null, - car_id integer, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_car_accessory primary key (id) -); - -create table car_fuse ( - id bigserial not null, - location_code varchar(255), - constraint pk_car_fuse primary key (id) -); - -create table category ( - id bigserial not null, - name varchar(255), - surveyobjectid bigint, - sequence_number integer not null, - constraint pk_category primary key (id) -); - -create table e_save_test_d ( - id bigserial not null, - parent_id bigint, - test_property boolean default false not null, - version bigint not null, - constraint uq_e_save_test_d_parent_id unique (parent_id), - constraint pk_e_save_test_d primary key (id) -); - -create table child_person ( - identifier serial not null, - name varchar(255), - age integer, - some_bean_id integer, - parent_identifier integer, - family_name varchar(255), - address varchar(255), - constraint pk_child_person primary key (identifier) -); - -create table cke_client ( - cod_cpny integer not null, - cod_client varchar(100) not null, - username varchar(100) not null, - notes varchar(255), - constraint pk_cke_client primary key (cod_cpny,cod_client) -); - -create table cke_user ( - username varchar(100) not null, - cod_cpny integer not null, - name varchar(255), - constraint pk_cke_user primary key (username,cod_cpny) -); - -create table class_super ( - dtype varchar(31) not null, - sid bigserial not null, - constraint pk_class_super primary key (sid) -); - -create table class_super_monkey ( - class_super_sid bigint not null, - monkey_mid bigint not null, - constraint uq_class_super_monkey_mid unique (monkey_mid), - constraint pk_class_super_monkey primary key (class_super_sid,monkey_mid) -); - -create table configuration ( - type varchar(21) not null, - id serial not null, - name varchar(255), - configurations_id integer, - group_name varchar(255), - product_name varchar(255), - constraint pk_configuration primary key (id) -); - -create table configurations ( - id serial not null, - name varchar(255), - constraint pk_configurations primary key (id) -); - -create table contact ( - id serial not null, - first_name varchar(127), - last_name varchar(127), - phone varchar(255), - mobile varchar(255), - email varchar(255), - customer_id integer not null, - group_id integer, - cretime timestamptz not null, - updtime timestamptz not null, - constraint pk_contact primary key (id) -); - -create table contact_group ( - id serial not null, - name varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_contact_group primary key (id) -); - -create table contact_note ( - id serial not null, - contact_id integer, - title varchar(255), - note text, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_contact_note primary key (id) -); - -create table contract ( - id bigserial not null, - name varchar(255), - constraint pk_contract primary key (id) -); - -create table contract_costs ( - id bigserial not null, - status varchar(255), - position_id bigint not null, - constraint pk_contract_costs primary key (id) -); - -create table c_conversation ( - id bigserial not null, - title varchar(255), - isopen boolean default false not null, - group_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_c_conversation primary key (id) -); - -create table o_country ( - code varchar(2) not null, - name varchar(60), - constraint pk_o_country primary key (code) -); - -create table cover ( - id bigserial not null, - s3_url varchar(255), - deleted boolean default false not null, - constraint pk_cover primary key (id) -); - -create table o_customer ( - id serial not null, - status varchar(1), - name varchar(40) not null, - smallnote varchar(100), - anniversary date, - billing_address_id smallint, - shipping_address_id smallint, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint ck_o_customer_status check ( status in ('N','A','I')), - constraint pk_o_customer primary key (id) -); -comment on table o_customer is 'Holds external customers'; -comment on column o_customer.status is 'status of the customer'; -comment on column o_customer.smallnote is 'Short notes regarding the customer'; -comment on column o_customer.anniversary is 'Join date of the customer'; - -create table dcredit ( - id bigserial not null, - credit varchar(255), - constraint pk_dcredit primary key (id) -); - -create table dcredit_drol ( - dcredit_id bigint not null, - drol_id bigint not null, - constraint pk_dcredit_drol primary key (dcredit_id,drol_id) -); - -create table dexh_entity ( - oid bigserial not null, - exhange varchar(255), - an_enum_type varchar(255), - last_updated timestamptz not null, - constraint pk_dexh_entity primary key (oid) -); - -create table dmachine ( - id bigserial not null, - name varchar(255), - organisation_id bigint, - version bigint not null, - constraint pk_dmachine primary key (id) -); - -create table d_machine_aux_use ( - id bigserial not null, - machine_id bigint not null, - name varchar(255), - date date, - use_secs bigint not null, - fuel decimal(38), - version bigint not null, - constraint pk_d_machine_aux_use primary key (id) -); - -create table d_machine_stats ( - id bigserial not null, - machine_id bigint not null, - date date, - total_kms bigint not null, - hours bigint not null, - rate decimal(38), - cost decimal(38), - version bigint not null, - constraint pk_d_machine_stats primary key (id) -); - -create table d_machine_use ( - id bigserial not null, - machine_id bigint not null, - date date, - distance_kms bigint not null, - time_secs bigint not null, - fuel decimal(38), - version bigint not null, - constraint pk_d_machine_use primary key (id) -); - -create table dorg ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_dorg primary key (id) -); - -create table dperson ( - id bigserial not null, - first_name varchar(255), - last_name varchar(255), - salary decimal(38), - constraint pk_dperson primary key (id) -); - -create table drol ( - id bigserial not null, - name varchar(255), - constraint pk_drol primary key (id) -); - -create table drot ( - id bigserial not null, - name varchar(255), - constraint pk_drot primary key (id) -); - -create table drot_drol ( - drot_id bigint not null, - drol_id bigint not null, - constraint pk_drot_drol primary key (drot_id,drol_id) -); - -create table rawinherit_data ( - id bigserial not null, - val integer, - constraint pk_rawinherit_data primary key (id) -); - -create table data_container ( - id uuid not null, - content varchar(255), - constraint pk_data_container primary key (id) -); - -create table dc_detail ( - id bigserial not null, - master_id bigint, - description varchar(255), - version bigint not null, - constraint pk_dc_detail primary key (id) -); - -create table dc_master ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_dc_master primary key (id) -); - -create table dfk_cascade ( - id bigserial not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_cascade primary key (id) -); - -create table dfk_cascade_one ( - id bigserial not null, - name varchar(255), - constraint pk_dfk_cascade_one primary key (id) -); - -create table dfk_none ( - id bigserial not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_none primary key (id) -); - -create table dfk_none_via_join ( - id bigserial not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_none_via_join primary key (id) -); - -create table dfk_none_via_mto_m ( - id bigserial not null, - name varchar(255), - constraint pk_dfk_none_via_mto_m primary key (id) -); - -create table dfk_none_via_mto_m_dfk_one ( - dfk_none_via_mto_m_id bigint not null, - dfk_one_id bigint not null, - constraint pk_dfk_none_via_mto_m_dfk_one primary key (dfk_none_via_mto_m_id,dfk_one_id) -); - -create table dfk_one ( - id bigserial not null, - name varchar(255), - constraint pk_dfk_one primary key (id) -); - -create table dfk_set_null ( - id bigserial not null, - name varchar(255), - one_id bigint, - constraint pk_dfk_set_null primary key (id) -); - -create table doc ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_doc primary key (id) -); - -create table doc_link ( - doc_id bigint not null, - link_id bigint not null, - constraint pk_doc_link primary key (doc_id,link_id) -); - -create table doc_link_draft ( - doc_id bigint not null, - link_id bigint not null, - constraint pk_doc_link_draft primary key (doc_id,link_id) -); - -create table doc_draft ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_doc_draft primary key (id) -); - -create table document ( - id bigserial not null, - title varchar(127), - body varchar(255), - organisation_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint uq_document_title unique (title), - constraint pk_document primary key (id) -); - -create table document_draft ( - id bigserial not null, - title varchar(127), - body varchar(255), - when_publish timestamptz, - organisation_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint uq_document_draft_title unique (title), - constraint pk_document_draft primary key (id) -); - -create table document_media ( - id bigserial not null, - document_id bigint, - name varchar(255), - description varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_document_media primary key (id) -); - -create table document_media_draft ( - id bigserial not null, - document_id bigint, - name varchar(255), - description varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_document_media_draft primary key (id) -); - -create table sp_car_door ( - id bigint not null, - name varchar(255), - version integer not null, - constraint pk_sp_car_door primary key (id) -); -create sequence sp_car_door_seq; - -create table earray_bean ( - id bigserial not null, - foo integer, - name varchar(255), - phone_numbers varchar[], - uids uuid[], - other_ids bigint[], - doubs float[], - statuses integer[], - vc_enums varchar[], - int_enums integer[], - status2 integer[], - version bigint not null, - constraint ck_earray_bean_foo check ( foo in (100,101,102)), - constraint pk_earray_bean primary key (id) -); - -create table earray_set_bean ( - id bigserial not null, - name varchar(255), - phone_numbers varchar[], - uids uuid[], - other_ids bigint[], - doubs float[], - version bigint not null, - constraint pk_earray_set_bean primary key (id) -); - -create table e_basic ( - id serial not null, - status varchar(1), - name varchar(127), - description varchar(255), - some_date timestamptz, - constraint ck_e_basic_status check ( status in ('N','A','I')), - constraint pk_e_basic primary key (id) -); - -create table ebasic_change_log ( - id bigserial not null, - name varchar(20), - short_description varchar(50), - long_description varchar(100), - who_created varchar(255) not null, - who_modified varchar(255) not null, - when_created timestamptz not null, - when_modified timestamptz not null, - version bigint not null, - constraint pk_ebasic_change_log primary key (id) -); - -create table ebasic_clob ( - id bigserial not null, - name varchar(255), - title varchar(255), - description text, - last_update timestamptz not null, - constraint pk_ebasic_clob primary key (id) -); - -create table ebasic_clob_fetch_eager ( - id bigserial not null, - name varchar(255), - title varchar(255), - description text, - last_update timestamptz not null, - constraint pk_ebasic_clob_fetch_eager primary key (id) -); - -create table ebasic_clob_no_ver ( - id bigserial not null, - name varchar(255), - description text, - constraint pk_ebasic_clob_no_ver primary key (id) -); - -create table e_basicenc ( - id serial not null, - name varchar(255), - description bytea, - dob bytea, - status bytea, - last_update timestamptz, - constraint pk_e_basicenc primary key (id) -); - -create table e_basicenc_bin ( - id serial not null, - name varchar(255), - description varchar(255), - data bytea, - some_time bytea, - last_update timestamptz not null, - constraint pk_e_basicenc_bin primary key (id) -); - -create table e_basicenc_client ( - id bigserial not null, - name varchar(255), - description bytea, - dob bytea, - status bytea, - version bigint not null, - constraint pk_e_basicenc_client primary key (id) -); - -create table e_basic_enum_id ( - status varchar(1) not null, - name varchar(255), - description varchar(255), - constraint ck_e_basic_enum_id_status check ( status in ('N','A','I')), - constraint pk_e_basic_enum_id primary key (status) -); - -create table e_basic_eni ( - id serial not null, - status integer, - name varchar(255), - description varchar(255), - some_date timestamptz, - constraint ck_e_basic_eni_status check ( status in (1,2,3)), - constraint pk_e_basic_eni primary key (id) -); - -create table ebasic_hstore ( - id bigserial not null, - name varchar(255), - map hstore, - version bigint not null, - constraint pk_ebasic_hstore primary key (id) -); - -create table ebasic_json_jackson ( - id bigserial not null, - name varchar(255), - value_set json, - value_list jsonb, - value_map json, - plain_value json, - version bigint not null, - constraint pk_ebasic_json_jackson primary key (id) -); - -create table ebasic_json_jackson2 ( - id bigserial not null, - name varchar(255), - value_set json, - value_list jsonb, - value_map json, - plain_value json, - version bigint not null, - constraint pk_ebasic_json_jackson2 primary key (id) -); - -create table ebasic_json_list ( - id bigserial not null, - name varchar(255), - bean_set json, - bean_list jsonb, - bean_map json, - plain_bean json, - flags json, - tags varchar(100), - version bigint not null, - constraint pk_ebasic_json_list primary key (id) -); - -create table ebasic_json_map ( - id bigserial not null, - name varchar(255), - content json, - version bigint not null, - constraint pk_ebasic_json_map primary key (id) -); - -create table ebasic_json_map_blob ( - id bigserial not null, - name varchar(255), - content bytea, - version bigint not null, - constraint pk_ebasic_json_map_blob primary key (id) -); - -create table ebasic_json_map_clob ( - id bigserial not null, - name varchar(255), - content text, - version bigint not null, - constraint pk_ebasic_json_map_clob primary key (id) -); - -create table ebasic_json_map_detail ( - id bigserial not null, - owner_id bigint, - name varchar(255), - content json, - version bigint not null, - constraint pk_ebasic_json_map_detail primary key (id) -); - -create table ebasic_json_map_json_b ( - id bigserial not null, - name varchar(255), - content jsonb, - version bigint not null, - constraint pk_ebasic_json_map_json_b primary key (id) -); - -create table ebasic_json_map_varchar ( - id bigserial not null, - name varchar(255), - content varchar(3000), - version bigint not null, - constraint pk_ebasic_json_map_varchar primary key (id) -); - -create table ebasic_json_node ( - id bigserial not null, - name varchar(255), - content json, - version bigint not null, - constraint pk_ebasic_json_node primary key (id) -); - -create table ebasic_json_node_blob ( - id bigserial not null, - name varchar(255), - content bytea, - version bigint not null, - constraint pk_ebasic_json_node_blob primary key (id) -); - -create table ebasic_json_node_json_b ( - id bigserial not null, - name varchar(255), - content jsonb, - version bigint not null, - constraint pk_ebasic_json_node_json_b primary key (id) -); - -create table ebasic_json_node_varchar ( - id bigserial not null, - name varchar(255), - content varchar(1000), - version bigint not null, - constraint pk_ebasic_json_node_varchar primary key (id) -); - -create table ebasic_json_unmapped ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ebasic_json_unmapped primary key (id) -); - -create table e_basic_ndc ( - id serial not null, - name varchar(255), - constraint pk_e_basic_ndc primary key (id) -); - -create table ebasic_no_sdchild ( - id bigserial not null, - owner_id bigint not null, - child_name varchar(255), - amount bigint not null, - version bigint not null, - constraint pk_ebasic_no_sdchild primary key (id) -); - -create table ebasic_sdchild ( - id bigserial not null, - owner_id bigint not null, - child_name varchar(255), - amount bigint not null, - version bigint not null, - deleted boolean default false not null, - constraint pk_ebasic_sdchild primary key (id) -); - -create table ebasic_soft_delete ( - id bigserial not null, - name varchar(255), - description varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_ebasic_soft_delete primary key (id) -); - -create table e_basicver ( - id serial not null, - name varchar(255), - description varchar(255), - other varchar(255), - last_update timestamptz not null, - constraint pk_e_basicver primary key (id) -); - -create table e_basic_withlife ( - id bigserial not null, - name varchar(255), - deleted boolean default false not null, - version bigint not null, - constraint pk_e_basic_withlife primary key (id) -); - -create table e_basic_with_ex ( - id bigserial not null, - deleted boolean default false not null, - version bigint not null, - constraint pk_e_basic_with_ex primary key (id) -); - -create table e_basicverucon ( - id serial not null, - name varchar(127), - other varchar(127), - other_one varchar(127), - description varchar(255), - last_update timestamptz not null, - constraint uq_e_basicverucon_name unique (name), - constraint uq_e_basicverucon_other_other_one unique (other,other_one), - constraint pk_e_basicverucon primary key (id) -); - -create table ecache_child ( - id uuid not null, - name varchar(100), - root_id uuid not null, - constraint pk_ecache_child primary key (id) -); - -create table ecache_root ( - id uuid not null, - name varchar(100), - constraint pk_ecache_root primary key (id) -); - -create table e_col_ab ( - id bigserial not null, - column_a varchar(255), - column_b varchar(255), - constraint pk_e_col_ab primary key (id) -); - -create table ecustom_id ( - id varchar(127) not null, - name varchar(255), - constraint pk_ecustom_id primary key (id) -); - -create table edefault_prop ( - id serial not null, - e_simple_usertypeid integer, - name varchar(255), - constraint uq_edefault_prop_e_simple_usertypeid unique (e_simple_usertypeid), - constraint pk_edefault_prop primary key (id) -); - -create table eemb_inner ( - id serial not null, - nome_inner varchar(255), - outer_id integer, - update_count integer not null, - constraint pk_eemb_inner primary key (id) -); - -create table eemb_outer ( - id serial not null, - nome_outer varchar(255), - date1 timestamptz, - date2 timestamptz, - update_count integer not null, - constraint pk_eemb_outer primary key (id) -); - -create table efile2_no_fk ( - file_name varchar(64) not null, - owner_id integer not null, - constraint pk_efile2_no_fk primary key (file_name) -); - -create table efile_no_fk ( - file_name varchar(64) not null, - owner_user_id integer, - owner_soft_del_user_id integer, - constraint pk_efile_no_fk primary key (file_name) -); - -create table efile_no_fk_euser_no_fk ( - efile_no_fk_file_name varchar(64) not null, - euser_no_fk_user_id integer not null, - constraint pk_efile_no_fk_euser_no_fk primary key (efile_no_fk_file_name,euser_no_fk_user_id) -); - -create table efile_no_fk_euser_no_fk_soft_del ( - efile_no_fk_file_name varchar(64) not null, - euser_no_fk_soft_del_user_id integer not null, - constraint pk_efile_no_fk_euser_no_fk_soft_del primary key (efile_no_fk_file_name,euser_no_fk_soft_del_user_id) -); - -create table egen_props ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - ts_created timestamptz not null, - ts_updated timestamptz not null, - ldt_created timestamptz not null, - ldt_updated timestamptz not null, - odt_created timestamptz not null, - odt_updated timestamptz not null, - zdt_created timestamptz not null, - zdt_updated timestamptz not null, - instant_created timestamptz not null, - instant_updated timestamptz not null, - long_created bigint not null, - long_updated bigint not null, - constraint pk_egen_props primary key (id) -); - -create table einvoice ( - id bigserial not null, - invoice_date timestamptz, - state integer, - person_id bigint, - ship_street varchar(255), - ship_suburb varchar(255), - ship_city varchar(255), - ship_status varchar(3), - bill_street varchar(255), - bill_suburb varchar(255), - bill_city varchar(255), - bill_status varchar(3), - version bigint not null, - constraint ck_einvoice_state check ( state in (0,1,2)), - constraint ck_einvoice_ship_status check ( ship_status in ('ONE','TWO')), - constraint ck_einvoice_bill_status check ( bill_status in ('ONE','TWO')), - constraint pk_einvoice primary key (id) -); - -create table e_main ( - id serial not null, - name varchar(255), - description varchar(255), - version bigint not null, - constraint pk_e_main primary key (id) -); - -create table enull_collection ( - id serial not null, - name varchar(255), - constraint pk_enull_collection primary key (id) -); - -create table enull_collection_detail ( - id serial not null, - enull_collection_id integer not null, - something varchar(255), - constraint pk_enull_collection_detail primary key (id) -); - -create table eopt_one_a ( - id serial not null, - name_for_a varchar(255), - b_id integer, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_eopt_one_a primary key (id) -); - -create table eopt_one_b ( - id serial not null, - name_for_b varchar(255), - c_id integer not null, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_eopt_one_b primary key (id) -); - -create table eopt_one_c ( - id serial not null, - name_for_c varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_eopt_one_c primary key (id) -); - -create table eper_addr ( - id bigserial not null, - name varchar(255), - ma_street varchar(255), - ma_suburb varchar(255), - ma_city varchar(255), - ma_country_code varchar(2), - version bigint not null, - constraint pk_eper_addr primary key (id) -); - -create table eperson ( - id bigserial not null, - name varchar(255), - notes varchar(255), - street varchar(255), - suburb varchar(255), - addr_city varchar(255), - addr_status varchar(3), - version bigint not null, - constraint ck_eperson_addr_status check ( addr_status in ('ONE','TWO')), - constraint pk_eperson primary key (id) -); - -create table e_person_online ( - id bigserial not null, - email varchar(127), - online_status boolean default false not null, - when_updated timestamptz not null, - constraint uq_e_person_online_email unique (email), - constraint pk_e_person_online primary key (id) -); - -create table esimple ( - usertypeid serial not null, - name varchar(255), - constraint pk_esimple primary key (usertypeid) -); - -create table esoft_del_book ( - id bigserial not null, - book_title varchar(255), - lend_by_id bigint, - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_book primary key (id) -); - -create table esoft_del_book_esoft_del_user ( - esoft_del_book_id bigint not null, - esoft_del_user_id bigint not null, - constraint pk_esoft_del_book_esoft_del_user primary key (esoft_del_book_id,esoft_del_user_id) -); - -create table esoft_del_down ( - id bigserial not null, - esoft_del_mid_id bigint not null, - down varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_down primary key (id) -); - -create table esoft_del_mid ( - id bigserial not null, - top_id bigint, - mid varchar(255), - up_id bigint, - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_mid primary key (id) -); - -create table esoft_del_one_a ( - id bigserial not null, - name varchar(255), - oneb_id bigint, - deleted boolean default false not null, - version bigint not null, - constraint uq_esoft_del_one_a_oneb_id unique (oneb_id), - constraint pk_esoft_del_one_a primary key (id) -); - -create table esoft_del_one_b ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_esoft_del_one_b primary key (id) -); - -create table esoft_del_role ( - id bigserial not null, - role_name varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_role primary key (id) -); - -create table esoft_del_role_esoft_del_user ( - esoft_del_role_id bigint not null, - esoft_del_user_id bigint not null, - constraint pk_esoft_del_role_esoft_del_user primary key (esoft_del_role_id,esoft_del_user_id) -); - -create table esoft_del_top ( - id bigserial not null, - name varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_top primary key (id) -); - -create table esoft_del_up ( - id bigserial not null, - up varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_up primary key (id) -); - -create table esoft_del_user ( - id bigserial not null, - user_name varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_esoft_del_user primary key (id) -); - -create table esoft_del_user_esoft_del_role ( - esoft_del_user_id bigint not null, - esoft_del_role_id bigint not null, - constraint pk_esoft_del_user_esoft_del_role primary key (esoft_del_user_id,esoft_del_role_id) -); - -create table esome_convert_type ( - id bigserial not null, - name varchar(255), - money decimal(38), - constraint pk_esome_convert_type primary key (id) -); - -create table esome_type ( - id serial not null, - currency varchar(3), - locale varchar(20), - time_zone varchar(20), - constraint pk_esome_type primary key (id) -); - -create table etrans_many ( - id serial not null, - name varchar(255), - constraint pk_etrans_many primary key (id) -); - -create table rawinherit_uncle ( - id serial not null, - name varchar(255), - parent_id bigint not null, - version bigint not null, - constraint pk_rawinherit_uncle primary key (id) -); - -create table euser_no_fk ( - user_id serial not null, - user_name varchar(255), - constraint pk_euser_no_fk primary key (user_id) -); - -create table euser_no_fk_soft_del ( - user_id serial not null, - user_name varchar(255), - constraint pk_euser_no_fk_soft_del primary key (user_id) -); - -create table evanilla_collection ( - id serial not null, - name varchar(255), - constraint pk_evanilla_collection primary key (id) -); - -create table evanilla_collection_detail ( - id serial not null, - evanilla_collection_id integer not null, - something varchar(255), - constraint pk_evanilla_collection_detail primary key (id) -); - -create table ewho_props ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - who_created varchar(255) not null, - who_modified varchar(255) not null, - constraint pk_ewho_props primary key (id) -); - -create table e_withinet ( - id bigserial not null, - name varchar(255), - inet_address inet, - inet2 inet, - cdir inet, - version bigint not null, - constraint pk_e_withinet primary key (id) -); - -create table ec_enum_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ec_enum_person primary key (id) -); - -create table ec_enum_person_tags ( - ec_enum_person_id bigint not null, - value varchar(5) not null, - constraint ck_ec_enum_person_tags_value check ( value in ('RED','BLUE','GREEN')) -); - -create table ec_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ec_person primary key (id) -); - -create table ec_person_phone ( - owner_id bigint not null, - phone varchar(255) not null -); - -create table ecbl_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ecbl_person primary key (id) -); - -create table ecbl_person_phone_numbers ( - person_id bigint not null, - country_code varchar(2), - area varchar(6), - number varchar(20) -); - -create table ecbm_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ecbm_person primary key (id) -); - -create table ecbm_person_phone_numbers ( - person_id bigint not null, - mkey varchar(255) not null, - country_code varchar(2), - area varchar(6), - number varchar(20) -); - -create table ecm_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ecm_person primary key (id) -); - -create table ecm_person_phone_numbers ( - ecm_person_id bigint not null, - type varchar(4) not null, - number varchar(10) not null -); - -create table ecmc_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ecmc_person primary key (id) -); - -create table ecmc_person_phone_numbers ( - ecmc_person_id bigint not null, - type varchar(4) not null, - value text not null -); - -create table ecs_person ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_ecs_person primary key (id) -); - -create table ecs_person_phone ( - ecs_person_id bigint not null, - phone varchar(255) not null -); - -create table td_child ( - child_id serial not null, - child_name varchar(255), - parent_id integer not null, - constraint pk_td_child primary key (child_id) -); - -create table td_parent ( - parent_type varchar(31) not null, - parent_id serial not null, - parent_name varchar(255), - extended_name varchar(255), - constraint pk_td_parent primary key (parent_id) -); - -create table empl ( - id bigserial not null, - name varchar(255), - age integer, - default_address_id bigint, - constraint pk_empl primary key (id) -); - -create table esd_detail ( - id bigserial not null, - name varchar(255), - master_id bigint not null, - version bigint not null, - deleted boolean default false not null, - constraint pk_esd_detail primary key (id) -); - -create table esd_master ( - id bigserial not null, - name varchar(255), - version bigint not null, - deleted boolean default false not null, - constraint pk_esd_master primary key (id) -); - -create table feature_desc ( - id serial not null, - name varchar(255), - description varchar(255), - constraint pk_feature_desc primary key (id) -); - -create table f_first ( - id bigserial not null, - name varchar(255), - constraint pk_f_first primary key (id) -); - -create table foo ( - foo_id serial not null, - important_text varchar(255), - version integer not null, - constraint pk_foo primary key (foo_id) -); - -create table gen_key_identity ( - id bigserial not null, - description varchar(255), - constraint pk_gen_key_identity primary key (id) -); - -create table gen_key_sequence ( - id bigint not null, - description varchar(255), - constraint pk_gen_key_sequence primary key (id) -); -create sequence SEQ; - -create table gen_key_table ( - id bigserial not null, - description varchar(255), - constraint pk_gen_key_table primary key (id) -); - -create table grand_parent_person ( - identifier serial not null, - name varchar(255), - age integer, - some_bean_id integer, - family_name varchar(255), - address varchar(255), - constraint pk_grand_parent_person primary key (identifier) -); - -create table survey_group ( - id bigserial not null, - name varchar(255), - categoryobjectid bigint, - sequence_number integer not null, - constraint pk_survey_group primary key (id) -); - -create table c_group ( - id bigserial not null, - inactive boolean default false not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_c_group primary key (id) -); - -create table he_doc ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_he_doc primary key (id) -); - -create table hx_link ( - id bigserial not null, - name varchar(255), - location varchar(255), - comments varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - deleted boolean default false not null, - constraint pk_hx_link primary key (id) -); - -create table hx_link_doc ( - hx_link_id bigint not null, - he_doc_id bigint not null, - constraint pk_hx_link_doc primary key (hx_link_id,he_doc_id) -); - -create table hi_doc ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_hi_doc primary key (id) -); - -create table hi_link ( - id bigserial not null, - name varchar(255), - location varchar(255), - comments varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_hi_link primary key (id) -); - -create table hi_link_doc ( - hi_link_id bigint not null, - hi_doc_id bigint not null, - constraint pk_hi_link_doc primary key (hi_link_id,hi_doc_id) -); - -create table hi_tone ( - id bigserial not null, - name varchar(255), - comments varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_hi_tone primary key (id) -); - -create table hi_tthree ( - id bigserial not null, - hi_ttwo_id bigint not null, - three varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_hi_tthree primary key (id) -); - -create table hi_ttwo ( - id bigserial not null, - hi_tone_id bigint not null, - two varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_hi_ttwo primary key (id) -); - -create table hsd_setting ( - id bigserial not null, - code varchar(255), - content varchar(255), - user_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - deleted boolean default false not null, - constraint uq_hsd_setting_user_id unique (user_id), - constraint pk_hsd_setting primary key (id) -); - -create table hsd_user ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - deleted boolean default false not null, - constraint pk_hsd_user primary key (id) -); - -create table iaf_segment ( - ptype varchar(31) not null, - id bigserial not null, - segment_id_zat bigint not null, - status_id bigint not null, - constraint pk_iaf_segment primary key (id) -); - -create table iaf_segment_status ( - id bigserial not null, - name varchar(255), - constraint pk_iaf_segment_status primary key (id) -); - -create table imrelated ( - id bigserial not null, - name varchar(255), - owner_id bigint not null, - constraint pk_imrelated primary key (id) -); - -create table imroot ( - dtype varchar(31) not null, - id bigserial not null, - name varchar(255), - title varchar(255), - when_title timestamptz, - constraint pk_imroot primary key (id) -); - -create table ixresource ( - dtype varchar(255), - id uuid not null, - name varchar(255), - constraint pk_ixresource primary key (id) -); - -create table info_company ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_info_company primary key (id) -); - -create table info_contact ( - id bigserial not null, - name varchar(255), - company_id bigint not null, - version bigint not null, - constraint pk_info_contact primary key (id) -); - -create table info_customer ( - id bigserial not null, - name varchar(255), - company_id bigint, - version bigint not null, - constraint uq_info_customer_company_id unique (company_id), - constraint pk_info_customer primary key (id) -); - -create table inner_report ( - id bigserial not null, - name varchar(255), - forecast_id bigint, - constraint uq_inner_report_forecast_id unique (forecast_id), - constraint pk_inner_report primary key (id) -); - -create table drel_invoice ( - id bigint not null, - booking bigint, - version integer not null, - constraint pk_drel_invoice primary key (id) -); -create sequence drel_invoice_seq; - -create table item ( - customer integer not null, - itemnumber varchar(127) not null, - description varchar(255), - units varchar(255), - type integer not null, - region integer not null, - date_modified timestamptz, - date_created timestamptz, - modified_by varchar(255), - created_by varchar(255), - version bigint not null, - constraint pk_item primary key (customer,itemnumber) -); - -create table monkey ( - mid bigserial not null, - name varchar(255), - food_preference varchar(255), - version bigint not null, - constraint pk_monkey primary key (mid) -); - -create table mkeygroup ( - pid bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_mkeygroup primary key (pid) -); - -create table mkeygroup_monkey ( - mkeygroup_pid bigint not null, - monkey_mid bigint not null, - constraint uq_mkeygroup_monkey_mid unique (monkey_mid), - constraint pk_mkeygroup_monkey primary key (mkeygroup_pid,monkey_mid) -); - -create table trainer ( - tid bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_trainer primary key (tid) -); - -create table trainer_monkey ( - trainer_tid bigint not null, - monkey_mid bigint not null, - constraint uq_trainer_monkey_mid unique (monkey_mid), - constraint pk_trainer_monkey primary key (trainer_tid,monkey_mid) -); - -create table troop ( - pid bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_troop primary key (pid) -); - -create table troop_monkey ( - troop_pid bigint not null, - monkey_mid bigint not null, - constraint uq_troop_monkey_mid unique (monkey_mid), - constraint pk_troop_monkey primary key (troop_pid,monkey_mid) -); - -create table l2_cldf_reset_bean ( - id bigserial not null, - name varchar(255), - constraint pk_l2_cldf_reset_bean primary key (id) -); - -create table l2_cldf_reset_bean_child ( - id bigserial not null, - parent_id bigint, - constraint pk_l2_cldf_reset_bean_child primary key (id) -); - -create table level1 ( - id bigserial not null, - name varchar(255), - constraint pk_level1 primary key (id) -); - -create table level1_level4 ( - level1_id bigint not null, - level4_id bigint not null, - constraint pk_level1_level4 primary key (level1_id,level4_id) -); - -create table level1_level2 ( - level1_id bigint not null, - level2_id bigint not null, - constraint pk_level1_level2 primary key (level1_id,level2_id) -); - -create table level2 ( - id bigserial not null, - name varchar(255), - constraint pk_level2 primary key (id) -); - -create table level2_level3 ( - level2_id bigint not null, - level3_id bigint not null, - constraint pk_level2_level3 primary key (level2_id,level3_id) -); - -create table level3 ( - id bigserial not null, - name varchar(255), - constraint pk_level3 primary key (id) -); - -create table level4 ( - id bigserial not null, - name varchar(255), - constraint pk_level4 primary key (id) -); - -create table link ( - id bigserial not null, - name varchar(255), - location varchar(255), - when_publish timestamptz, - link_comment varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - deleted boolean default false not null, - constraint pk_link primary key (id) -); - -create table link_draft ( - id bigserial not null, - name varchar(255), - location varchar(255), - when_publish timestamptz, - link_comment varchar(255), - dirty boolean default false not null, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - deleted boolean default false not null, - constraint pk_link_draft primary key (id) -); - -create table la_attr_value ( - id serial not null, - name varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_la_attr_value primary key (id) -); - -create table la_attr_value_attribute ( - la_attr_value_id integer not null, - attribute_id integer not null, - constraint pk_la_attr_value_attribute primary key (la_attr_value_id,attribute_id) -); - -create table looney ( - id bigserial not null, - tune_id bigint, - name varchar(255), - constraint pk_looney primary key (id) -); - -create table maddress ( - id uuid not null, - street varchar(255), - city varchar(255), - version bigint not null, - constraint pk_maddress primary key (id) -); - -create table mcontact ( - id uuid not null, - email varchar(255), - first_name varchar(255), - last_name varchar(255), - customer_id uuid, - version bigint not null, - constraint pk_mcontact primary key (id) -); - -create table mcontact_message ( - id uuid not null, - title varchar(255), - subject varchar(255), - notes varchar(255), - contact_id uuid not null, - version bigint not null, - constraint pk_mcontact_message primary key (id) -); - -create table mcustomer ( - id uuid not null, - name varchar(255), - notes varchar(255), - shipping_address_id uuid, - billing_address_id uuid, - version bigint not null, - constraint pk_mcustomer primary key (id) -); - -create table mgroup ( - id bigserial not null, - name varchar(255), - constraint pk_mgroup primary key (id) -); - -create table mmachine ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_mmachine primary key (id) -); - -create table mmachine_mgroup ( - mmachine_id bigint not null, - mgroup_id bigint not null, - constraint pk_mmachine_mgroup primary key (mmachine_id,mgroup_id) -); - -create table mmedia ( - type varchar(31) not null, - id bigserial not null, - url varchar(255), - note varchar(255), - constraint pk_mmedia primary key (id) -); - -create table non_updateprop ( - id serial not null, - non_enum varchar(5), - name varchar(255), - note varchar(255), - constraint ck_non_updateprop_non_enum check ( non_enum in ('BEGIN','END')), - constraint pk_non_updateprop primary key (id) -); - -create table mprinter ( - id bigserial not null, - name varchar(255), - flags bigint not null, - current_state_id bigint, - last_swap_cyan_id bigint, - last_swap_magenta_id bigint, - last_swap_yellow_id bigint, - last_swap_black_id bigint, - version bigint not null, - constraint uq_mprinter_last_swap_cyan_id unique (last_swap_cyan_id), - constraint uq_mprinter_last_swap_magenta_id unique (last_swap_magenta_id), - constraint uq_mprinter_last_swap_yellow_id unique (last_swap_yellow_id), - constraint uq_mprinter_last_swap_black_id unique (last_swap_black_id), - constraint pk_mprinter primary key (id) -); - -create table mprinter_state ( - id bigserial not null, - flags bigint not null, - printer_id bigint, - version bigint not null, - constraint pk_mprinter_state primary key (id) -); - -create table mprofile ( - id bigserial not null, - picture_id bigint, - name varchar(255), - constraint pk_mprofile primary key (id) -); - -create table mprotected_construct_bean ( - id bigserial not null, - name varchar(255), - constraint pk_mprotected_construct_bean primary key (id) -); - -create table mrole ( - roleid serial not null, - role_name varchar(255), - constraint pk_mrole primary key (roleid) -); - -create table mrole_muser ( - mrole_roleid integer not null, - muser_userid integer not null, - constraint pk_mrole_muser primary key (mrole_roleid,muser_userid) -); - -create table msome_other ( - id bigserial not null, - name varchar(255), - constraint pk_msome_other primary key (id) -); - -create table muser ( - userid serial not null, - user_name varchar(255), - user_type_id integer, - constraint pk_muser primary key (userid) -); - -create table muser_type ( - id serial not null, - name varchar(255), - constraint pk_muser_type primary key (id) -); - -create table mail_box ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_mail_box primary key (id) -); - -create table mail_user ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_mail_user primary key (id) -); - -create table mail_user_inbox ( - mail_user_id bigint not null, - mail_box_id bigint not null, - constraint pk_mail_user_inbox primary key (mail_user_id,mail_box_id) -); - -create table mail_user_outbox ( - mail_user_id bigint not null, - mail_box_id bigint not null, - constraint pk_mail_user_outbox primary key (mail_user_id,mail_box_id) -); - -create table main_entity ( - id varchar(255) not null, - attr1 varchar(255), - attr2 varchar(255), - constraint pk_main_entity primary key (id) -); - -create table main_entity_relation ( - id uuid not null, - id1 varchar(255), - id2 varchar(255), - attr1 varchar(255), - constraint pk_main_entity_relation primary key (id) -); - -create table map_super_actual ( - id bigserial not null, - name varchar(255), - when_created timestamptz not null, - when_updated timestamptz not null, - constraint pk_map_super_actual primary key (id) -); - -create table c_message ( - id bigserial not null, - title varchar(255), - body varchar(255), - conversation_id bigint, - user_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_c_message primary key (id) -); - -create table meter_address_data ( - id uuid not null, - street varchar(255) not null, - constraint pk_meter_address_data primary key (id) -); - -create table meter_contract_data ( - id uuid not null, - special_needs_client_id uuid not null, - constraint uq_meter_contract_data_special_needs_client_id unique (special_needs_client_id), - constraint pk_meter_contract_data primary key (id) -); - -create table meter_special_needs_client ( - id uuid not null, - name varchar(255), - primary_id uuid, - constraint uq_meter_special_needs_client_primary_id unique (primary_id), - constraint pk_meter_special_needs_client primary key (id) -); - -create table meter_special_needs_contact ( - id uuid not null, - name varchar(255), - constraint pk_meter_special_needs_contact primary key (id) -); - -create table meter_version ( - id uuid not null, - address_data_id uuid, - contract_data_id uuid not null, - constraint uq_meter_version_address_data_id unique (address_data_id), - constraint uq_meter_version_contract_data_id unique (contract_data_id), - constraint pk_meter_version primary key (id) -); - -create table mnoc_role ( - role_id serial not null, - role_name varchar(255), - version integer not null, - constraint pk_mnoc_role primary key (role_id) -); - -create table mnoc_user ( - user_id serial not null, - user_name varchar(255), - version integer not null, - constraint pk_mnoc_user primary key (user_id) -); - -create table mnoc_user_mnoc_role ( - mnoc_user_user_id integer not null, - mnoc_role_role_id integer not null, - constraint pk_mnoc_user_mnoc_role primary key (mnoc_user_user_id,mnoc_role_role_id) -); - -create table mny_a ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_mny_a primary key (id) -); - -create table mny_b ( - id bigserial not null, - name varchar(255), - a_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_mny_b primary key (id) -); - -create table mny_b_mny_c ( - mny_b_id bigint not null, - mny_c_id bigint not null, - constraint pk_mny_b_mny_c primary key (mny_b_id,mny_c_id) -); - -create table mny_c ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_mny_c primary key (id) -); - -create table mny_topic ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_mny_topic primary key (id) -); - -create table subtopics ( - topic bigint not null, - subtopic bigint not null, - constraint pk_subtopics primary key (topic,subtopic) -); - -create table mp_role ( - id bigserial not null, - mp_user_id bigint not null, - code varchar(255), - organization_id bigint, - constraint pk_mp_role primary key (id) -); - -create table mp_user ( - id bigserial not null, - name varchar(255), - constraint pk_mp_user primary key (id) -); - -create table ms_many_a ( - aid bigserial not null, - name varchar(255), - ms_many_a_many_b boolean default false not null, - ms_many_b boolean default false not null, - deleted boolean default false not null, - constraint pk_ms_many_a primary key (aid) -); - -create table ms_many_a_many_b ( - ms_many_a_aid bigint not null, - ms_many_b_bid bigint not null, - constraint pk_ms_many_a_many_b primary key (ms_many_a_aid,ms_many_b_bid) -); - -create table ms_many_b ( - bid bigserial not null, - name varchar(255), - deleted boolean default false not null, - constraint pk_ms_many_b primary key (bid) -); - -create table ms_many_b_many_a ( - ms_many_b_bid bigint not null, - ms_many_a_aid bigint not null, - constraint pk_ms_many_b_many_a primary key (ms_many_b_bid,ms_many_a_aid) -); - -create table my_lob_size ( - id serial not null, - name varchar(255), - my_count integer not null, - my_lob text, - constraint pk_my_lob_size primary key (id) -); - -create table my_lob_size_join_many ( - id serial not null, - something varchar(255), - other varchar(255), - parent_id integer, - constraint pk_my_lob_size_join_many primary key (id) -); - -create table noidbean ( - name varchar(255), - subject varchar(255), - when_created timestamptz not null -); - -create table o_cached_bean ( - id bigserial not null, - name varchar(255), - constraint pk_o_cached_bean primary key (id) -); - -create table o_cached_bean_country ( - o_cached_bean_id bigint not null, - o_country_code varchar(2) not null, - constraint pk_o_cached_bean_country primary key (o_cached_bean_id,o_country_code) -); - -create table o_cached_bean_child ( - id bigserial not null, - cached_bean_id bigint, - constraint pk_o_cached_bean_child primary key (id) -); - -create table o_cached_inherit ( - dtype varchar(31) not null, - id bigserial not null, - name varchar(255), - child_adata varchar(255), - child_bdata varchar(255), - constraint pk_o_cached_inherit primary key (id) -); - -create table o_cached_natkey ( - id bigserial not null, - store varchar(255), - sku varchar(255), - description varchar(255), - constraint pk_o_cached_natkey primary key (id) -); - -create table o_cached_natkey3 ( - id bigserial not null, - store varchar(255), - code integer not null, - sku varchar(255), - description varchar(255), - constraint pk_o_cached_natkey3 primary key (id) -); - -create table ocar ( - id serial not null, - vin varchar(255), - name varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_ocar primary key (id) -); - -create table ocompany ( - id serial not null, - corp_id varchar(50), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint uq_ocompany_corp_id unique (corp_id), - constraint pk_ocompany primary key (id) -); - -create table oengine ( - engine_id uuid not null, - short_desc varchar(255), - car_id integer, - version integer not null, - constraint uq_oengine_car_id unique (car_id), - constraint pk_oengine primary key (engine_id) -); - -create table ogear_box ( - id uuid not null, - box_desc varchar(255), - box_size integer, - car_id integer, - version integer not null, - constraint uq_ogear_box_car_id unique (car_id), - constraint pk_ogear_box primary key (id) -); - -create table oroad_show_msg ( - id serial not null, - company_id integer not null, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint uq_oroad_show_msg_company_id unique (company_id), - constraint pk_oroad_show_msg primary key (id) -); - -create table om_ordered_detail ( - id bigserial not null, - name varchar(255), - master_id bigint, - version bigint not null, - sort_order integer, - constraint pk_om_ordered_detail primary key (id) -); - -create table om_ordered_master ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_om_ordered_master primary key (id) -); - -create table only_id_entity ( - id bigserial not null, - constraint pk_only_id_entity primary key (id) -); - -create table o_order ( - id serial not null, - status integer, - order_date date, - ship_date date, - kcustomer_id integer not null, - cretime timestamptz not null, - updtime timestamptz not null, - constraint ck_o_order_status check ( status in (0,1,2,3)), - constraint pk_o_order primary key (id) -); - -create table o_order_detail ( - id serial not null, - order_id integer not null, - order_qty integer, - ship_qty integer, - unit_price float, - product_id integer, - cretime timestamptz, - updtime timestamptz not null, - constraint pk_o_order_detail primary key (id) -); - -create table s_orders ( - uuid varchar(40) not null, - constraint pk_s_orders primary key (uuid) -); - -create table s_order_items ( - uuid varchar(40) not null, - product_variant_uuid varchar(255), - order_uuid varchar(40), - quantity integer not null, - amount decimal(38), - constraint pk_s_order_items primary key (uuid) -); - -create table or_order_ship ( - id serial not null, - order_id integer, - ship_time timestamptz, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_or_order_ship primary key (id) -); - -create table organisation ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_organisation primary key (id) -); - -create table organization_node ( - kind varchar(31) not null, - id bigserial not null, - parent_tree_node_id bigint not null, - title varchar(255), - constraint uq_organization_node_parent_tree_node_id unique (parent_tree_node_id), - constraint pk_organization_node primary key (id) -); - -create table organization_tree_node ( - id bigserial not null, - name varchar(255), - constraint pk_organization_tree_node primary key (id) -); - -create table orp_detail ( - id varchar(100) not null, - detail varchar(255), - master_id varchar(100), - version bigint not null, - constraint pk_orp_detail primary key (id) -); - -create table orp_detail2 ( - id varchar(100) not null, - orp_master2_id varchar(100) not null, - detail varchar(255), - master_id varchar(255), - version bigint not null, - constraint pk_orp_detail2 primary key (id) -); - -create table orp_master ( - id varchar(100) not null, - name varchar(255), - version bigint not null, - constraint pk_orp_master primary key (id) -); - -create table orp_master2 ( - id varchar(100) not null, - name varchar(255), - version bigint not null, - constraint pk_orp_master2 primary key (id) -); - -create table oto_aone ( - id varchar(100) not null, - description varchar(255), - constraint pk_oto_aone primary key (id) -); - -create table oto_atwo ( - id varchar(100) not null, - description varchar(255), - aone_id varchar(100), - constraint uq_oto_atwo_aone_id unique (aone_id), - constraint pk_oto_atwo primary key (id) -); - -create table oto_bchild ( - master_id bigint not null, - child varchar(255), - constraint pk_oto_bchild primary key (master_id) -); - -create table oto_bmaster ( - id bigserial not null, - name varchar(255), - constraint pk_oto_bmaster primary key (id) -); - -create table oto_child ( - id serial not null, - name varchar(255), - master_id bigint, - constraint uq_oto_child_master_id unique (master_id), - constraint pk_oto_child primary key (id) -); - -create table oto_cust ( - cid bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_oto_cust primary key (cid) -); - -create table oto_cust_address ( - aid bigserial not null, - line1 varchar(255), - line2 varchar(255), - line3 varchar(255), - customer_cid bigint, - version bigint not null, - constraint uq_oto_cust_address_customer_cid unique (customer_cid), - constraint pk_oto_cust_address primary key (aid) -); - -create table oto_level_a ( - id bigserial not null, - name varchar(255), - b_id bigint, - constraint uq_oto_level_a_b_id unique (b_id), - constraint pk_oto_level_a primary key (id) -); - -create table oto_level_b ( - id bigserial not null, - name varchar(255), - c_id bigint, - constraint uq_oto_level_b_c_id unique (c_id), - constraint pk_oto_level_b primary key (id) -); - -create table oto_level_c ( - id bigserial not null, - name varchar(255), - constraint pk_oto_level_c primary key (id) -); - -create table oto_master ( - id bigserial not null, - name varchar(255), - constraint pk_oto_master primary key (id) -); - -create table oto_prime ( - pid bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_oto_prime primary key (pid) -); - -create table oto_prime_extra ( - eid bigint not null, - extra varchar(255), - version bigint not null, - constraint pk_oto_prime_extra primary key (eid) -); - -create table oto_sd_child ( - id bigserial not null, - child varchar(255), - master_id bigint, - deleted boolean default false not null, - version bigint not null, - constraint uq_oto_sd_child_master_id unique (master_id), - constraint pk_oto_sd_child primary key (id) -); - -create table oto_sd_master ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_oto_sd_master primary key (id) -); - -create table oto_th_many ( - id bigserial not null, - oto_th_top_id bigint not null, - many varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_oto_th_many primary key (id) -); - -create table oto_th_one ( - id bigserial not null, - one boolean default false not null, - many_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint uq_oto_th_one_many_id unique (many_id), - constraint pk_oto_th_one primary key (id) -); - -create table oto_th_top ( - id bigserial not null, - topp varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_oto_th_top primary key (id) -); - -create table oto_ubprime ( - pid uuid not null, - name varchar(255), - version bigint not null, - constraint pk_oto_ubprime primary key (pid) -); - -create table oto_ubprime_extra ( - eid uuid not null, - extra varchar(255), - version bigint not null, - constraint pk_oto_ubprime_extra primary key (eid) -); - -create table oto_uprime ( - pid uuid not null, - name varchar(255), - version bigint not null, - constraint pk_oto_uprime primary key (pid) -); - -create table oto_uprime_extra ( - eid uuid not null, - extra varchar(255), - version bigint not null, - constraint pk_oto_uprime_extra primary key (eid) -); - -create table oto_user_model ( - id bigserial not null, - name varchar(255), - user_optional_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint uq_oto_user_model_user_optional_id unique (user_optional_id), - constraint pk_oto_user_model primary key (id) -); - -create table oto_user_model_optional ( - id bigserial not null, - optional varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_oto_user_model_optional primary key (id) -); - -create table pfile ( - id serial not null, - name varchar(255), - file_content_id integer, - file_content2_id integer, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint uq_pfile_file_content_id unique (file_content_id), - constraint uq_pfile_file_content2_id unique (file_content2_id), - constraint pk_pfile primary key (id) -); - -create table pfile_content ( - id serial not null, - content bytea, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_pfile_content primary key (id) -); - -create table paggview ( - pview_id uuid, - amount integer not null, - constraint uq_paggview_pview_id unique (pview_id) -); - -create table pallet_location ( - type varchar(31) not null, - id serial not null, - zone_sid integer not null, - attribute varchar(255), - constraint pk_pallet_location primary key (id) -); - -create table parcel ( - parcelid bigserial not null, - description varchar(255), - constraint pk_parcel primary key (parcelid) -); - -create table parcel_location ( - parcellocid bigserial not null, - location varchar(255), - parcelid bigint, - constraint uq_parcel_location_parcelid unique (parcelid), - constraint pk_parcel_location primary key (parcellocid) -); - -create table rawinherit_parent ( - type varchar(31) not null, - id bigserial not null, - val integer, - more varchar(255), - constraint pk_rawinherit_parent primary key (id) -); - -create table rawinherit_parent_rawinherit_data ( - rawinherit_parent_id bigint not null, - rawinherit_data_id bigint not null, - constraint pk_rawinherit_parent_rawinherit_data primary key (rawinherit_parent_id,rawinherit_data_id) -); - -create table e_save_test_c ( - id bigserial not null, - version bigint not null, - constraint pk_e_save_test_c primary key (id) -); - -create table parent_person ( - identifier serial not null, - name varchar(255), - age integer, - some_bean_id integer, - parent_identifier integer, - family_name varchar(255), - address varchar(255), - constraint pk_parent_person primary key (identifier) -); - -create table c_participation ( - id bigserial not null, - rating integer, - type integer, - conversation_id bigint not null, - user_id bigint not null, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint ck_c_participation_type check ( type in (0,1)), - constraint pk_c_participation primary key (id) -); - -create table password_store_model ( - id bigserial not null, - enc1 varchar(30), - enc2 varchar(40), - enc3 text, - enc4 bytea, - enc5 bytea, - enc6 bytea, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_password_store_model primary key (id) -); - -create table mt_permission ( - id uuid not null, - name varchar(255), - constraint pk_mt_permission primary key (id) -); - -create table persistent_file ( - id serial not null, - name varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_persistent_file primary key (id) -); - -create table persistent_file_content ( - id serial not null, - persistent_file_id integer, - content bytea, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint uq_persistent_file_content_persistent_file_id unique (persistent_file_id), - constraint pk_persistent_file_content primary key (id) -); - -create table person ( - oid bigserial not null, - default_address_oid bigint, - version integer not null, - constraint pk_person primary key (oid) -); - -create table persons ( - id bigserial not null, - surname varchar(64) not null, - name varchar(64) not null, - constraint pk_persons primary key (id) -); - -create table person_cache_email ( - id varchar(128) not null, - person_info_person_id varchar(128), - email varchar(255), - constraint pk_person_cache_email primary key (id) -); - -create table person_cache_info ( - person_id varchar(128) not null, - name varchar(255), - constraint pk_person_cache_info primary key (person_id) -); - -create table phones ( - id bigserial not null, - phone_number varchar(7) not null, - person_id bigint not null, - constraint uq_phones_phone_number unique (phone_number), - constraint pk_phones primary key (id) -); - -create table e_position ( - id bigserial not null, - name varchar(255), - contract_id bigint not null, - constraint pk_e_position primary key (id) -); - -create table primary_revision ( - id bigint not null, - revision integer not null, - name varchar(255), - version bigint not null, - constraint pk_primary_revision primary key (id,revision) -); - -create table o_product ( - id serial not null, - sku varchar(20), - name varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - constraint pk_o_product primary key (id) -); - -create table pp ( - id uuid not null, - name varchar(255), - value varchar(100) not null, - constraint pk_pp primary key (id) -); - -create table pp_to_ww ( - pp_id uuid not null, - ww_id uuid not null, - constraint pk_pp_to_ww primary key (pp_id,ww_id) -); - -create table question ( - id bigserial not null, - name varchar(255), - groupobjectid bigint, - sequence_number integer not null, - constraint pk_question primary key (id) -); - -create table rcustomer ( - company varchar(127) not null, - name varchar(127) not null, - description varchar(255), - constraint pk_rcustomer primary key (company,name) -); - -create table r_orders ( - company varchar(127) not null, - order_number integer not null, - customername varchar(127), - item varchar(255), - constraint pk_r_orders primary key (company,order_number) -); - -create table region ( - customer integer not null, - type integer not null, - description varchar(255), - version bigint not null, - constraint pk_region primary key (customer,type) -); - -create table rel_detail ( - id bigserial not null, - name varchar(255), - version integer not null, - constraint pk_rel_detail primary key (id) -); - -create table rel_master ( - id bigserial not null, - name varchar(255), - detail_id bigint, - version integer not null, - constraint pk_rel_master primary key (id) -); - -create table resourcefile ( - id varchar(64) not null, - parentresourcefileid varchar(64), - name varchar(128) not null, - constraint pk_resourcefile primary key (id) -); - -create table mt_role ( - id uuid not null, - name varchar(50), - tenant_id uuid, - version bigint not null, - constraint pk_mt_role primary key (id) -); - -create table mt_role_permission ( - mt_role_id uuid not null, - mt_permission_id uuid not null, - constraint pk_mt_role_permission primary key (mt_role_id,mt_permission_id) -); - -create table em_role ( - id bigserial not null, - name varchar(255), - constraint pk_em_role primary key (id) -); - -create table f_second ( - id bigserial not null, - mod_name varchar(255), - first bigint, - title varchar(255), - constraint uq_f_second_first unique (first), - constraint pk_f_second primary key (id) -); - -create table section ( - id serial not null, - article_id integer, - type integer, - content text, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint ck_section_type check ( type in (0,1)), - constraint pk_section primary key (id) -); - -create table self_parent ( - id bigserial not null, - name varchar(255), - parent_id bigint, - version bigint not null, - constraint pk_self_parent primary key (id) -); - -create table self_ref_customer ( - id bigserial not null, - name varchar(255), - referred_by_id bigint, - constraint pk_self_ref_customer primary key (id) -); - -create table self_ref_example ( - id bigserial not null, - name varchar(255) not null, - parent_id bigint, - constraint pk_self_ref_example primary key (id) -); - -create table e_save_test_a ( - id bigserial not null, - version bigint not null, - constraint pk_e_save_test_a primary key (id) -); - -create table e_save_test_b ( - id bigserial not null, - sibling_a_id bigint, - test_property boolean default false not null, - version bigint not null, - constraint uq_e_save_test_b_sibling_a_id unique (sibling_a_id), - constraint pk_e_save_test_b primary key (id) -); - -create table site ( - id uuid not null, - name varchar(255), - parent_id uuid, - data_container_id uuid, - site_address_id uuid, - constraint uq_site_data_container_id unique (data_container_id), - constraint uq_site_site_address_id unique (site_address_id), - constraint pk_site primary key (id) -); - -create table site_address ( - id uuid not null, - street varchar(255), - city varchar(255), - zip_code varchar(255), - constraint pk_site_address primary key (id) -); - -create table some_enum_bean ( - id bigserial not null, - some_enum integer, - name varchar(255), - constraint ck_some_enum_bean_some_enum check ( some_enum in (0,1)), - constraint pk_some_enum_bean primary key (id) -); - -create table some_file_bean ( - id bigserial not null, - name varchar(255), - content bytea, - version bigint not null, - constraint pk_some_file_bean primary key (id) -); - -create table some_new_types_bean ( - id bigserial not null, - dow integer, - mth integer, - yr integer, - yr_mth date, - month_day date, - local_date date, - local_date_time timestamptz, - offset_date_time timestamptz, - zoned_date_time timestamptz, - local_time time, - instant timestamptz, - zone_id varchar(60), - zone_offset varchar(60), - path varchar(255), - period varchar(20), - duration bigint, - version bigint not null, - constraint ck_some_new_types_bean_dow check ( dow in (1,2,3,4,5,6,7)), - constraint ck_some_new_types_bean_mth check ( mth in (1,2,3,4,5,6,7,8,9,10,11,12)), - constraint pk_some_new_types_bean primary key (id) -); - -create table some_period_bean ( - id bigserial not null, - anniversary date, - version bigint not null, - constraint pk_some_period_bean primary key (id) -); - -create table stockforecast ( - type varchar(31) not null, - id bigserial not null, - inner_report_id bigint, - constraint pk_stockforecast primary key (id) -); - -create table sub_section ( - id serial not null, - section_id integer, - title varchar(255), - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_sub_section primary key (id) -); - -create table sub_type ( - sub_type_id serial not null, - description varchar(255), - version bigint not null, - constraint pk_sub_type primary key (sub_type_id) -); - -create table survey ( - id bigserial not null, - name varchar(255), - constraint pk_survey primary key (id) -); - -create table tbytes_only ( - id serial not null, - content bytea, - constraint pk_tbytes_only primary key (id) -); - -create table tcar ( - type varchar(31) not null, - plate_no varchar(32) not null, - truckload bigint, - constraint pk_tcar primary key (plate_no) -); - -create table tevent ( - id bigserial not null, - name varchar(255), - version bigint not null, - constraint pk_tevent primary key (id) -); - -create table tevent_many ( - id bigserial not null, - description varchar(255), - event_id bigint, - units integer not null, - amount float not null, - version bigint not null, - constraint pk_tevent_many primary key (id) -); - -create table tevent_one ( - id bigserial not null, - name varchar(255), - status integer, - event_id bigint, - version bigint not null, - constraint ck_tevent_one_status check ( status in (0,1)), - constraint uq_tevent_one_event_id unique (event_id), - constraint pk_tevent_one primary key (id) -); - -create table tint_root ( - my_type integer not null, - id serial not null, - name varchar(255), - child_property varchar(255), - constraint pk_tint_root primary key (id) -); - -create table tjoda_entity ( - id serial not null, - local_time time, - constraint pk_tjoda_entity primary key (id) -); - -create table t_mapsuper1 ( - id serial not null, - something varchar(255), - name varchar(255), - version integer not null, - constraint pk_t_mapsuper1 primary key (id) -); - -create table t_oneb ( - id serial not null, - name varchar(255), - description varchar(255), - active boolean default false not null, - constraint pk_t_oneb primary key (id) -); - -create table t_detail_with_other_namexxxyy ( - id integer not null, - name varchar(255), - description varchar(255), - some_unique_value varchar(127), - active boolean default false not null, - master_id integer, - constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value), - constraint pk_t_detail_with_other_namexxxyy primary key (id) -); -create sequence t_atable_detail_seq; - -create table ts_detail_two ( - id serial not null, - name varchar(255), - description varchar(255), - active boolean default false not null, - master_id integer, - constraint pk_ts_detail_two primary key (id) -); - -create table t_atable_thatisrelatively ( - id integer not null, - name varchar(255), - description varchar(255), - active boolean default false not null, - constraint pk_t_atable_thatisrelatively primary key (id) -); -create sequence t_atable_master_seq; - -create table ts_master_two ( - id serial not null, - name varchar(255), - description varchar(255), - active boolean default false not null, - constraint pk_ts_master_two primary key (id) -); - -create table tuuid_entity ( - id uuid not null, - name varchar(255), - constraint pk_tuuid_entity primary key (id) -); - -create table twheel ( - id bigserial not null, - owner_plate_no varchar(32) not null, - constraint pk_twheel primary key (id) -); - -create table twith_pre_insert ( - id serial not null, - name varchar(255) not null, - title varchar(255), - constraint pk_twith_pre_insert primary key (id) -); - -create table mt_tenant ( - id uuid not null, - name varchar(255), - version bigint not null, - constraint pk_mt_tenant primary key (id) -); - -create table test_annotation_base_entity ( - direct varchar(255), - meta varchar(255), - mixed varchar(255), - constraint_annotation varchar(40), - null1 varchar(255) not null, - null2 varchar(255), - null3 varchar(255) -); - -create table tire ( - id bigint not null, - wheel bigint, - version integer not null, - constraint uq_tire_wheel unique (wheel), - constraint pk_tire primary key (id) -); -create sequence tire_seq; - -create table sa_tire ( - id bigint not null, - version integer not null, - constraint pk_sa_tire primary key (id) -); -create sequence sa_tire_seq; - -create table trip ( - id serial not null, - vehicle_driver_id integer, - destination varchar(255), - address_id smallint, - star_date timestamptz, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_trip primary key (id) -); - -create table truck_ref ( - id serial not null, - something varchar(255), - constraint pk_truck_ref primary key (id) -); - -create table tune ( - id bigserial not null, - name varchar(255), - constraint pk_tune primary key (id) -); - -create table "type" ( - customer integer not null, - type integer not null, - description varchar(255), - sub_type_id integer, - version bigint not null, - constraint pk_type primary key (customer,type) -); - -create table tz_bean ( - id bigserial not null, - moda varchar(255), - ts timestamptz, - tstz timestamptz, - constraint pk_tz_bean primary key (id) -); - -create table usib_child ( - id uuid not null, - parent_id bigint, - deleted boolean default false not null, - constraint pk_usib_child primary key (id) -); - -create table usib_child_sibling ( - id bigserial not null, - child_id uuid, - deleted boolean default false not null, - constraint uq_usib_child_sibling_child_id unique (child_id), - constraint pk_usib_child_sibling primary key (id) -); - -create table usib_parent ( - id bigserial not null, - deleted boolean default false not null, - constraint pk_usib_parent primary key (id) -); - -create table ut_detail ( - id serial not null, - utmaster_id integer not null, - name varchar(255), - qty integer, - amount float, - version integer not null, - constraint pk_ut_detail primary key (id) -); - -create table ut_master ( - id serial not null, - name varchar(255), - description varchar(255), - date date, - version integer not null, - constraint pk_ut_master primary key (id) -); - -create table uuone ( - id uuid not null, - name varchar(255), - description varchar(255), - version bigint not null, - constraint pk_uuone primary key (id) -); - -create table uutwo ( - id uuid not null, - name varchar(255), - notes varchar(255), - master_id uuid, - version bigint not null, - constraint pk_uutwo primary key (id) -); - -create table oto_user ( - id bigserial not null, - name varchar(255), - account_id bigint not null, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint uq_oto_user_account_id unique (account_id), - constraint pk_oto_user primary key (id) -); - -create table c_user ( - id bigserial not null, - inactive boolean default false not null, - name varchar(255), - email varchar(255), - password_hash varchar(255), - group_id bigint, - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - constraint pk_c_user primary key (id) -); - -create table tx_user ( - id bigserial not null, - name varchar(255), - constraint pk_tx_user primary key (id) -); - -create table g_user ( - id bigserial not null, - username varchar(255), - version bigint not null, - constraint pk_g_user primary key (id) -); - -create table em_user ( - id bigserial not null, - name varchar(255), - constraint pk_em_user primary key (id) -); - -create table em_user_role ( - user_id bigint not null, - role_id bigint not null, - constraint pk_em_user_role primary key (user_id,role_id) -); - -create table vehicle ( - dtype varchar(3) not null, - id serial not null, - license_number varchar(255), - registration_date timestamptz, - lease_id bigint, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - siz varchar(3), - driver varchar(255), - car_ref_id integer, - notes varchar(255), - truck_ref_id integer, - capacity float, - constraint ck_vehicle_siz check ( siz in ('S','M','L','H')), - constraint pk_vehicle primary key (id) -); - -create table vehicle_driver ( - id serial not null, - name varchar(255), - vehicle_id integer, - address_id smallint, - license_issued_on timestamptz, - cretime timestamptz not null, - updtime timestamptz not null, - version bigint not null, - constraint pk_vehicle_driver primary key (id) -); - -create table vehicle_lease ( - dtype varchar(31) not null, - id bigserial not null, - name varchar(255), - active_start date, - active_end date, - version bigint not null, - bond decimal(38), - min_duration integer not null, - day_rate decimal(38), - max_days integer, - constraint pk_vehicle_lease primary key (id) -); - -create table warehouses ( - id serial not null, - officezoneid integer, - constraint pk_warehouses primary key (id) -); - -create table warehousesshippingzones ( - warehouseid integer not null, - shippingzoneid integer not null, - constraint pk_warehousesshippingzones primary key (warehouseid,shippingzoneid) -); - -create table wheel ( - id bigint not null, - version integer not null, - constraint pk_wheel primary key (id) -); -create sequence wheel_seq; - -create table sa_wheel ( - id bigint not null, - tire bigint, - car bigint, - version integer not null, - constraint pk_sa_wheel primary key (id) -); -create sequence sa_wheel_seq; - -create table sp_car_wheel ( - id bigint not null, - name varchar(255), - version integer not null, - constraint pk_sp_car_wheel primary key (id) -); -create sequence sp_car_wheel_seq; - -create table g_who_props_otm ( - id bigserial not null, - name varchar(255), - version bigint not null, - when_created timestamptz not null, - when_modified timestamptz not null, - who_created_id bigint, - who_modified_id bigint, - constraint pk_g_who_props_otm primary key (id) -); - -create table with_zero ( - id bigserial not null, - name varchar(255), - parent_id integer, - lang varchar(2) default 'en' not null, - version bigint not null, - constraint pk_with_zero primary key (id) -); - -create table parent ( - id serial not null, - name varchar(255), - constraint pk_parent primary key (id) -); - -create table wview ( - id uuid not null, - name varchar(127) not null, - constraint uq_wview_name unique (name), - constraint pk_wview primary key (id) -); - -create table zones ( - type varchar(31) not null, - id serial not null, - attribute varchar(255), - constraint pk_zones primary key (id) -); - -create index ix_contact_last_name_first_name on contact (last_name,first_name); -create index ix_e_basic_name on e_basic (name); -create index ix_efile2_no_fk_owner_id on efile2_no_fk (owner_id); -create index ix_organization_node_kind on organization_node (kind); -create index ix_bar_foo_id on bar (foo_id); -alter table bar add constraint fk_bar_foo_id foreign key (foo_id) references foo (foo_id) on delete restrict on update restrict; - -create index ix_acl_container_relation_container_id on acl_container_relation (container_id); -alter table acl_container_relation add constraint fk_acl_container_relation_container_id foreign key (container_id) references contract (id) on delete restrict on update restrict; - -create index ix_acl_container_relation_acl_entry_id on acl_container_relation (acl_entry_id); -alter table acl_container_relation add constraint fk_acl_container_relation_acl_entry_id foreign key (acl_entry_id) references acl (id) on delete restrict on update restrict; - -create index ix_addr_employee_id on addr (employee_id); -alter table addr add constraint fk_addr_employee_id foreign key (employee_id) references empl (id) on delete restrict on update restrict; - -create index ix_o_address_country_code on o_address (country_code); -alter table o_address add constraint fk_o_address_country_code foreign key (country_code) references o_country (code) on delete restrict on update restrict; - -alter table album add constraint fk_album_cover_id foreign key (cover_id) references cover (id) on delete restrict on update restrict; - -create index ix_animal_shelter_id on animal (shelter_id); -alter table animal add constraint fk_animal_shelter_id foreign key (shelter_id) references animal_shelter (id) on delete restrict on update restrict; - -create index ix_attribute_attribute_holder_id on attribute (attribute_holder_id); -alter table attribute add constraint fk_attribute_attribute_holder_id foreign key (attribute_holder_id) references attribute_holder (id) on delete restrict on update restrict; - -create index ix_bbookmark_user_id on bbookmark (user_id); -alter table bbookmark add constraint fk_bbookmark_user_id foreign key (user_id) references bbookmark_user (id) on delete restrict on update restrict; - -create index ix_bbookmark_user_org_id on bbookmark_user (org_id); -alter table bbookmark_user add constraint fk_bbookmark_user_org_id foreign key (org_id) references bbookmark_org (id) on delete restrict on update restrict; - -create index ix_bsite_user_a_site_id on bsite_user_a (site_id); -alter table bsite_user_a add constraint fk_bsite_user_a_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_a_user_id on bsite_user_a (user_id); -alter table bsite_user_a add constraint fk_bsite_user_a_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; - -create index ix_bsite_user_b_site on bsite_user_b (site); -alter table bsite_user_b add constraint fk_bsite_user_b_site foreign key (site) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_b_usr on bsite_user_b (usr); -alter table bsite_user_b add constraint fk_bsite_user_b_usr foreign key (usr) references buser (id) on delete restrict on update restrict; - -create index ix_bsite_user_c_site_uid on bsite_user_c (site_uid); -alter table bsite_user_c add constraint fk_bsite_user_c_site_uid foreign key (site_uid) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_c_user_uid on bsite_user_c (user_uid); -alter table bsite_user_c add constraint fk_bsite_user_c_user_uid foreign key (user_uid) references buser (id) on delete restrict on update restrict; - -create index ix_bsite_user_e_site_id on bsite_user_e (site_id); -alter table bsite_user_e add constraint fk_bsite_user_e_site_id foreign key (site_id) references bsite (id) on delete restrict on update restrict; - -create index ix_bsite_user_e_user_id on bsite_user_e (user_id); -alter table bsite_user_e add constraint fk_bsite_user_e_user_id foreign key (user_id) references buser (id) on delete restrict on update restrict; - -alter table basic_draftable_bean add constraint fk_basic_draftable_bean_id foreign key (id) references basic_draftable_bean_draft (id) on delete restrict on update restrict; - -alter table drel_booking add constraint fk_drel_booking_agent_invoice foreign key (agent_invoice) references drel_invoice (id) on delete restrict on update restrict; - -alter table drel_booking add constraint fk_drel_booking_client_invoice foreign key (client_invoice) references drel_invoice (id) on delete restrict on update restrict; - -create index ix_cepproduct_category_category_id on cepproduct_category (category_id); -alter table cepproduct_category add constraint fk_cepproduct_category_category_id foreign key (category_id) references cepcategory (id) on delete restrict on update restrict; - -create index ix_cepproduct_category_product_id on cepproduct_category (product_id); -alter table cepproduct_category add constraint fk_cepproduct_category_product_id foreign key (product_id) references cepproduct (id) on delete restrict on update restrict; - -create index ix_cinh_ref_ref_id on cinh_ref (ref_id); -alter table cinh_ref add constraint fk_cinh_ref_ref_id foreign key (ref_id) references cinh_root (id) on delete restrict on update restrict; - -create index ix_ckey_detail_parent on ckey_detail (one_key,two_key); -alter table ckey_detail add constraint fk_ckey_detail_parent foreign key (one_key,two_key) references ckey_parent (one_key,two_key) on delete restrict on update restrict; - -create index ix_ckey_parent_assoc_id on ckey_parent (assoc_id); -alter table ckey_parent add constraint fk_ckey_parent_assoc_id foreign key (assoc_id) references ckey_assoc (id) on delete restrict on update restrict; - -create index ix_calculation_result_product_configuration_id on calculation_result (product_configuration_id); -alter table calculation_result add constraint fk_calculation_result_product_configuration_id foreign key (product_configuration_id) references configuration (id) on delete restrict on update restrict; - -create index ix_calculation_result_group_configuration_id on calculation_result (group_configuration_id); -alter table calculation_result add constraint fk_calculation_result_group_configuration_id foreign key (group_configuration_id) references configuration (id) on delete restrict on update restrict; - -create index ix_sp_car_car_wheels_sp_car_car on sp_car_car_wheels (car); -alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; - -create index ix_sp_car_car_wheels_sp_car_wheel on sp_car_car_wheels (wheel); -alter table sp_car_car_wheels add constraint fk_sp_car_car_wheels_sp_car_wheel foreign key (wheel) references sp_car_wheel (id) on delete restrict on update restrict; - -create index ix_sp_car_car_doors_sp_car_car on sp_car_car_doors (car); -alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_car foreign key (car) references sp_car_car (id) on delete restrict on update restrict; - -create index ix_sp_car_car_doors_sp_car_door on sp_car_car_doors (door); -alter table sp_car_car_doors add constraint fk_sp_car_car_doors_sp_car_door foreign key (door) references sp_car_door (id) on delete restrict on update restrict; - -create index ix_car_accessory_fuse_id on car_accessory (fuse_id); -alter table car_accessory add constraint fk_car_accessory_fuse_id foreign key (fuse_id) references car_fuse (id) on delete restrict on update restrict; - -create index ix_car_accessory_car_id on car_accessory (car_id); -alter table car_accessory add constraint fk_car_accessory_car_id foreign key (car_id) references vehicle (id) on delete restrict on update restrict; - -create index ix_category_surveyobjectid on category (surveyobjectid); -alter table category add constraint fk_category_surveyobjectid foreign key (surveyobjectid) references survey (id) on delete restrict on update restrict; - -alter table e_save_test_d add constraint fk_e_save_test_d_parent_id foreign key (parent_id) references e_save_test_c (id) on delete restrict on update restrict; - -create index ix_child_person_some_bean_id on child_person (some_bean_id); -alter table child_person add constraint fk_child_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; - -create index ix_child_person_parent_identifier on child_person (parent_identifier); -alter table child_person add constraint fk_child_person_parent_identifier foreign key (parent_identifier) references parent_person (identifier) on delete restrict on update restrict; - -create index ix_cke_client_user on cke_client (username,cod_cpny); -alter table cke_client add constraint fk_cke_client_user foreign key (username,cod_cpny) references cke_user (username,cod_cpny) on delete restrict on update restrict; - -alter table class_super_monkey add constraint fk_class_super_monkey_class_super foreign key (class_super_sid) references class_super (sid) on delete restrict on update restrict; - -alter table class_super_monkey add constraint fk_class_super_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -create index ix_configuration_configurations_id on configuration (configurations_id); -alter table configuration add constraint fk_configuration_configurations_id foreign key (configurations_id) references configurations (id) on delete restrict on update restrict; - -create index ix_contact_customer_id on contact (customer_id); -alter table contact add constraint fk_contact_customer_id foreign key (customer_id) references o_customer (id) on delete restrict on update restrict; - -create index ix_contact_group_id on contact (group_id); -alter table contact add constraint fk_contact_group_id foreign key (group_id) references contact_group (id) on delete restrict on update restrict; - -create index ix_contact_note_contact_id on contact_note (contact_id); -alter table contact_note add constraint fk_contact_note_contact_id foreign key (contact_id) references contact (id) on delete restrict on update restrict; - -create index ix_contract_costs_position_id on contract_costs (position_id); -alter table contract_costs add constraint fk_contract_costs_position_id foreign key (position_id) references e_position (id) on delete restrict on update restrict; - -create index ix_c_conversation_group_id on c_conversation (group_id); -alter table c_conversation add constraint fk_c_conversation_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; - -create index ix_o_customer_billing_address_id on o_customer (billing_address_id); -alter table o_customer add constraint fk_o_customer_billing_address_id foreign key (billing_address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_o_customer_shipping_address_id on o_customer (shipping_address_id); -alter table o_customer add constraint fk_o_customer_shipping_address_id foreign key (shipping_address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_dcredit_drol_dcredit on dcredit_drol (dcredit_id); -alter table dcredit_drol add constraint fk_dcredit_drol_dcredit foreign key (dcredit_id) references dcredit (id) on delete restrict on update restrict; - -create index ix_dcredit_drol_drol on dcredit_drol (drol_id); -alter table dcredit_drol add constraint fk_dcredit_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; - -create index ix_dmachine_organisation_id on dmachine (organisation_id); -alter table dmachine add constraint fk_dmachine_organisation_id foreign key (organisation_id) references dorg (id) on delete restrict on update restrict; - -create index ix_d_machine_aux_use_machine_id on d_machine_aux_use (machine_id); -alter table d_machine_aux_use add constraint fk_d_machine_aux_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; - -create index ix_d_machine_stats_machine_id on d_machine_stats (machine_id); -alter table d_machine_stats add constraint fk_d_machine_stats_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; - -create index ix_d_machine_use_machine_id on d_machine_use (machine_id); -alter table d_machine_use add constraint fk_d_machine_use_machine_id foreign key (machine_id) references dmachine (id) on delete restrict on update restrict; - -create index ix_drot_drol_drot on drot_drol (drot_id); -alter table drot_drol add constraint fk_drot_drol_drot foreign key (drot_id) references drot (id) on delete restrict on update restrict; - -create index ix_drot_drol_drol on drot_drol (drol_id); -alter table drot_drol add constraint fk_drot_drol_drol foreign key (drol_id) references drol (id) on delete restrict on update restrict; - -create index ix_dc_detail_master_id on dc_detail (master_id); -alter table dc_detail add constraint fk_dc_detail_master_id foreign key (master_id) references dc_master (id) on delete restrict on update restrict; - -create index ix_dfk_cascade_one_id on dfk_cascade (one_id); -alter table dfk_cascade add constraint fk_dfk_cascade_one_id foreign key (one_id) references dfk_cascade_one (id) on delete cascade on update cascade; - -create index ix_dfk_set_null_one_id on dfk_set_null (one_id); -alter table dfk_set_null add constraint fk_dfk_set_null_one_id foreign key (one_id) references dfk_one (id) on delete set null on update set null; - -alter table doc add constraint fk_doc_id foreign key (id) references doc_draft (id) on delete restrict on update restrict; - -create index ix_doc_link_doc on doc_link (doc_id); -alter table doc_link add constraint fk_doc_link_doc foreign key (doc_id) references doc (id) on delete restrict on update restrict; - -create index ix_doc_link_link on doc_link (link_id); -alter table doc_link add constraint fk_doc_link_link foreign key (link_id) references link (id) on delete restrict on update restrict; - -alter table document add constraint fk_document_id foreign key (id) references document_draft (id) on delete restrict on update restrict; - -create index ix_document_organisation_id on document (organisation_id); -alter table document add constraint fk_document_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; - -create index ix_document_draft_organisation_id on document_draft (organisation_id); -alter table document_draft add constraint fk_document_draft_organisation_id foreign key (organisation_id) references organisation (id) on delete restrict on update restrict; - -create index ix_document_media_document_id on document_media (document_id); -alter table document_media add constraint fk_document_media_document_id foreign key (document_id) references document (id) on delete restrict on update restrict; - -create index ix_document_media_draft_document_id on document_media_draft (document_id); -alter table document_media_draft add constraint fk_document_media_draft_document_id foreign key (document_id) references document_draft (id) on delete restrict on update restrict; - -create index ix_ebasic_json_map_detail_owner_id on ebasic_json_map_detail (owner_id); -alter table ebasic_json_map_detail add constraint fk_ebasic_json_map_detail_owner_id foreign key (owner_id) references ebasic_json_map (id) on delete restrict on update restrict; - -create index ix_ebasic_no_sdchild_owner_id on ebasic_no_sdchild (owner_id); -alter table ebasic_no_sdchild add constraint fk_ebasic_no_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; - -create index ix_ebasic_sdchild_owner_id on ebasic_sdchild (owner_id); -alter table ebasic_sdchild add constraint fk_ebasic_sdchild_owner_id foreign key (owner_id) references ebasic_soft_delete (id) on delete restrict on update restrict; - -create index ix_ecache_child_root_id on ecache_child (root_id); -alter table ecache_child add constraint fk_ecache_child_root_id foreign key (root_id) references ecache_root (id) on delete restrict on update restrict; - -alter table edefault_prop add constraint fk_edefault_prop_e_simple_usertypeid foreign key (e_simple_usertypeid) references esimple (usertypeid) on delete restrict on update restrict; - -create index ix_eemb_inner_outer_id on eemb_inner (outer_id); -alter table eemb_inner add constraint fk_eemb_inner_outer_id foreign key (outer_id) references eemb_outer (id) on delete restrict on update restrict; - -create index ix_einvoice_person_id on einvoice (person_id); -alter table einvoice add constraint fk_einvoice_person_id foreign key (person_id) references eperson (id) on delete restrict on update restrict; - -create index ix_enull_collection_detail_enull_collection_id on enull_collection_detail (enull_collection_id); -alter table enull_collection_detail add constraint fk_enull_collection_detail_enull_collection_id foreign key (enull_collection_id) references enull_collection (id) on delete restrict on update restrict; - -create index ix_eopt_one_a_b_id on eopt_one_a (b_id); -alter table eopt_one_a add constraint fk_eopt_one_a_b_id foreign key (b_id) references eopt_one_b (id) on delete restrict on update restrict; - -create index ix_eopt_one_b_c_id on eopt_one_b (c_id); -alter table eopt_one_b add constraint fk_eopt_one_b_c_id foreign key (c_id) references eopt_one_c (id) on delete restrict on update restrict; - -create index ix_eper_addr_ma_country_code on eper_addr (ma_country_code); -alter table eper_addr add constraint fk_eper_addr_ma_country_code foreign key (ma_country_code) references o_country (code) on delete restrict on update restrict; - -create index ix_esoft_del_book_lend_by_id on esoft_del_book (lend_by_id); -alter table esoft_del_book add constraint fk_esoft_del_book_lend_by_id foreign key (lend_by_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_book_esoft_del_user_esoft_del_book on esoft_del_book_esoft_del_user (esoft_del_book_id); -alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_book foreign key (esoft_del_book_id) references esoft_del_book (id) on delete restrict on update restrict; - -create index ix_esoft_del_book_esoft_del_user_esoft_del_user on esoft_del_book_esoft_del_user (esoft_del_user_id); -alter table esoft_del_book_esoft_del_user add constraint fk_esoft_del_book_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_down_esoft_del_mid_id on esoft_del_down (esoft_del_mid_id); -alter table esoft_del_down add constraint fk_esoft_del_down_esoft_del_mid_id foreign key (esoft_del_mid_id) references esoft_del_mid (id) on delete restrict on update restrict; - -create index ix_esoft_del_mid_top_id on esoft_del_mid (top_id); -alter table esoft_del_mid add constraint fk_esoft_del_mid_top_id foreign key (top_id) references esoft_del_top (id) on delete restrict on update restrict; - -create index ix_esoft_del_mid_up_id on esoft_del_mid (up_id); -alter table esoft_del_mid add constraint fk_esoft_del_mid_up_id foreign key (up_id) references esoft_del_up (id) on delete restrict on update restrict; - -alter table esoft_del_one_a add constraint fk_esoft_del_one_a_oneb_id foreign key (oneb_id) references esoft_del_one_b (id) on delete restrict on update restrict; - -create index ix_esoft_del_role_esoft_del_user_esoft_del_role on esoft_del_role_esoft_del_user (esoft_del_role_id); -alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; - -create index ix_esoft_del_role_esoft_del_user_esoft_del_user on esoft_del_role_esoft_del_user (esoft_del_user_id); -alter table esoft_del_role_esoft_del_user add constraint fk_esoft_del_role_esoft_del_user_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_user_esoft_del_role_esoft_del_user on esoft_del_user_esoft_del_role (esoft_del_user_id); -alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_user foreign key (esoft_del_user_id) references esoft_del_user (id) on delete restrict on update restrict; - -create index ix_esoft_del_user_esoft_del_role_esoft_del_role on esoft_del_user_esoft_del_role (esoft_del_role_id); -alter table esoft_del_user_esoft_del_role add constraint fk_esoft_del_user_esoft_del_role_esoft_del_role foreign key (esoft_del_role_id) references esoft_del_role (id) on delete restrict on update restrict; - -create index ix_rawinherit_uncle_parent_id on rawinherit_uncle (parent_id); -alter table rawinherit_uncle add constraint fk_rawinherit_uncle_parent_id foreign key (parent_id) references rawinherit_parent (id) on delete restrict on update restrict; - -create index ix_evanilla_collection_detail_evanilla_collection_id on evanilla_collection_detail (evanilla_collection_id); -alter table evanilla_collection_detail add constraint fk_evanilla_collection_detail_evanilla_collection_id foreign key (evanilla_collection_id) references evanilla_collection (id) on delete restrict on update restrict; - -create index ix_ec_enum_person_tags_ec_enum_person_id on ec_enum_person_tags (ec_enum_person_id); -alter table ec_enum_person_tags add constraint fk_ec_enum_person_tags_ec_enum_person_id foreign key (ec_enum_person_id) references ec_enum_person (id) on delete restrict on update restrict; - -create index ix_ec_person_phone_owner_id on ec_person_phone (owner_id); -alter table ec_person_phone add constraint fk_ec_person_phone_owner_id foreign key (owner_id) references ec_person (id) on delete restrict on update restrict; - -create index ix_ecbl_person_phone_numbers_person_id on ecbl_person_phone_numbers (person_id); -alter table ecbl_person_phone_numbers add constraint fk_ecbl_person_phone_numbers_person_id foreign key (person_id) references ecbl_person (id) on delete restrict on update restrict; - -create index ix_ecbm_person_phone_numbers_person_id on ecbm_person_phone_numbers (person_id); -alter table ecbm_person_phone_numbers add constraint fk_ecbm_person_phone_numbers_person_id foreign key (person_id) references ecbm_person (id) on delete restrict on update restrict; - -create index ix_ecm_person_phone_numbers_ecm_person_id on ecm_person_phone_numbers (ecm_person_id); -alter table ecm_person_phone_numbers add constraint fk_ecm_person_phone_numbers_ecm_person_id foreign key (ecm_person_id) references ecm_person (id) on delete restrict on update restrict; - -create index ix_ecmc_person_phone_numbers_ecmc_person_id on ecmc_person_phone_numbers (ecmc_person_id); -alter table ecmc_person_phone_numbers add constraint fk_ecmc_person_phone_numbers_ecmc_person_id foreign key (ecmc_person_id) references ecmc_person (id) on delete restrict on update restrict; - -create index ix_ecs_person_phone_ecs_person_id on ecs_person_phone (ecs_person_id); -alter table ecs_person_phone add constraint fk_ecs_person_phone_ecs_person_id foreign key (ecs_person_id) references ecs_person (id) on delete restrict on update restrict; - -create index ix_td_child_parent_id on td_child (parent_id); -alter table td_child add constraint fk_td_child_parent_id foreign key (parent_id) references td_parent (parent_id) on delete restrict on update restrict; - -create index ix_empl_default_address_id on empl (default_address_id); -alter table empl add constraint fk_empl_default_address_id foreign key (default_address_id) references addr (id) on delete restrict on update restrict; - -create index ix_esd_detail_master_id on esd_detail (master_id); -alter table esd_detail add constraint fk_esd_detail_master_id foreign key (master_id) references esd_master (id) on delete restrict on update restrict; - -create index ix_grand_parent_person_some_bean_id on grand_parent_person (some_bean_id); -alter table grand_parent_person add constraint fk_grand_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; - -create index ix_survey_group_categoryobjectid on survey_group (categoryobjectid); -alter table survey_group add constraint fk_survey_group_categoryobjectid foreign key (categoryobjectid) references category (id) on delete restrict on update restrict; - -create index ix_hx_link_doc_hx_link on hx_link_doc (hx_link_id); -alter table hx_link_doc add constraint fk_hx_link_doc_hx_link foreign key (hx_link_id) references hx_link (id) on delete restrict on update restrict; - -create index ix_hx_link_doc_he_doc on hx_link_doc (he_doc_id); -alter table hx_link_doc add constraint fk_hx_link_doc_he_doc foreign key (he_doc_id) references he_doc (id) on delete restrict on update restrict; - -create index ix_hi_link_doc_hi_link on hi_link_doc (hi_link_id); -alter table hi_link_doc add constraint fk_hi_link_doc_hi_link foreign key (hi_link_id) references hi_link (id) on delete restrict on update restrict; - -create index ix_hi_link_doc_hi_doc on hi_link_doc (hi_doc_id); -alter table hi_link_doc add constraint fk_hi_link_doc_hi_doc foreign key (hi_doc_id) references hi_doc (id) on delete restrict on update restrict; - -create index ix_hi_tthree_hi_ttwo_id on hi_tthree (hi_ttwo_id); -alter table hi_tthree add constraint fk_hi_tthree_hi_ttwo_id foreign key (hi_ttwo_id) references hi_ttwo (id) on delete restrict on update restrict; - -create index ix_hi_ttwo_hi_tone_id on hi_ttwo (hi_tone_id); -alter table hi_ttwo add constraint fk_hi_ttwo_hi_tone_id foreign key (hi_tone_id) references hi_tone (id) on delete restrict on update restrict; - -alter table hsd_setting add constraint fk_hsd_setting_user_id foreign key (user_id) references hsd_user (id) on delete restrict on update restrict; - -create index ix_iaf_segment_status_id on iaf_segment (status_id); -alter table iaf_segment add constraint fk_iaf_segment_status_id foreign key (status_id) references iaf_segment_status (id) on delete restrict on update restrict; - -create index ix_imrelated_owner_id on imrelated (owner_id); -alter table imrelated add constraint fk_imrelated_owner_id foreign key (owner_id) references imroot (id) on delete restrict on update restrict; - -create index ix_info_contact_company_id on info_contact (company_id); -alter table info_contact add constraint fk_info_contact_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; - -alter table info_customer add constraint fk_info_customer_company_id foreign key (company_id) references info_company (id) on delete restrict on update restrict; - -alter table inner_report add constraint fk_inner_report_forecast_id foreign key (forecast_id) references stockforecast (id) on delete restrict on update restrict; - -create index ix_drel_invoice_booking on drel_invoice (booking); -alter table drel_invoice add constraint fk_drel_invoice_booking foreign key (booking) references drel_booking (id) on delete restrict on update restrict; - -create index ix_item_etype on item (customer,type); -alter table item add constraint fk_item_etype foreign key (customer,type) references "type" (customer,type) on delete restrict on update restrict; - -create index ix_item_eregion on item (customer,region); -alter table item add constraint fk_item_eregion foreign key (customer,region) references region (customer,type) on delete restrict on update restrict; - -alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_mkeygroup foreign key (mkeygroup_pid) references mkeygroup (pid) on delete restrict on update restrict; - -alter table mkeygroup_monkey add constraint fk_mkeygroup_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -alter table trainer_monkey add constraint fk_trainer_monkey_trainer foreign key (trainer_tid) references trainer (tid) on delete restrict on update restrict; - -alter table trainer_monkey add constraint fk_trainer_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -alter table troop_monkey add constraint fk_troop_monkey_troop foreign key (troop_pid) references troop (pid) on delete restrict on update restrict; - -alter table troop_monkey add constraint fk_troop_monkey_monkey foreign key (monkey_mid) references monkey (mid) on delete restrict on update restrict; - -create index ix_l2_cldf_reset_bean_child_parent_id on l2_cldf_reset_bean_child (parent_id); -alter table l2_cldf_reset_bean_child add constraint fk_l2_cldf_reset_bean_child_parent_id foreign key (parent_id) references l2_cldf_reset_bean (id) on delete restrict on update restrict; - -create index ix_level1_level4_level1 on level1_level4 (level1_id); -alter table level1_level4 add constraint fk_level1_level4_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; - -create index ix_level1_level4_level4 on level1_level4 (level4_id); -alter table level1_level4 add constraint fk_level1_level4_level4 foreign key (level4_id) references level4 (id) on delete restrict on update restrict; - -create index ix_level1_level2_level1 on level1_level2 (level1_id); -alter table level1_level2 add constraint fk_level1_level2_level1 foreign key (level1_id) references level1 (id) on delete restrict on update restrict; - -create index ix_level1_level2_level2 on level1_level2 (level2_id); -alter table level1_level2 add constraint fk_level1_level2_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; - -create index ix_level2_level3_level2 on level2_level3 (level2_id); -alter table level2_level3 add constraint fk_level2_level3_level2 foreign key (level2_id) references level2 (id) on delete restrict on update restrict; - -create index ix_level2_level3_level3 on level2_level3 (level3_id); -alter table level2_level3 add constraint fk_level2_level3_level3 foreign key (level3_id) references level3 (id) on delete restrict on update restrict; - -alter table link add constraint fk_link_id foreign key (id) references link_draft (id) on delete restrict on update restrict; - -create index ix_la_attr_value_attribute_la_attr_value on la_attr_value_attribute (la_attr_value_id); -alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_la_attr_value foreign key (la_attr_value_id) references la_attr_value (id) on delete restrict on update restrict; - -create index ix_la_attr_value_attribute_attribute on la_attr_value_attribute (attribute_id); -alter table la_attr_value_attribute add constraint fk_la_attr_value_attribute_attribute foreign key (attribute_id) references attribute (id) on delete restrict on update restrict; - -create index ix_looney_tune_id on looney (tune_id); -alter table looney add constraint fk_looney_tune_id foreign key (tune_id) references tune (id) on delete restrict on update restrict; - -create index ix_mcontact_customer_id on mcontact (customer_id); -alter table mcontact add constraint fk_mcontact_customer_id foreign key (customer_id) references mcustomer (id) on delete restrict on update restrict; - -create index ix_mcontact_message_contact_id on mcontact_message (contact_id); -alter table mcontact_message add constraint fk_mcontact_message_contact_id foreign key (contact_id) references mcontact (id) on delete restrict on update restrict; - -create index ix_mcustomer_shipping_address_id on mcustomer (shipping_address_id); -alter table mcustomer add constraint fk_mcustomer_shipping_address_id foreign key (shipping_address_id) references maddress (id) on delete restrict on update restrict; - -create index ix_mcustomer_billing_address_id on mcustomer (billing_address_id); -alter table mcustomer add constraint fk_mcustomer_billing_address_id foreign key (billing_address_id) references maddress (id) on delete restrict on update restrict; - -create index ix_mmachine_mgroup_mmachine on mmachine_mgroup (mmachine_id); -alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mmachine foreign key (mmachine_id) references mmachine (id) on delete restrict on update restrict; - -create index ix_mmachine_mgroup_mgroup on mmachine_mgroup (mgroup_id); -alter table mmachine_mgroup add constraint fk_mmachine_mgroup_mgroup foreign key (mgroup_id) references mgroup (id) on delete restrict on update restrict; - -create index ix_mprinter_current_state_id on mprinter (current_state_id); -alter table mprinter add constraint fk_mprinter_current_state_id foreign key (current_state_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_cyan_id foreign key (last_swap_cyan_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_magenta_id foreign key (last_swap_magenta_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_yellow_id foreign key (last_swap_yellow_id) references mprinter_state (id) on delete restrict on update restrict; - -alter table mprinter add constraint fk_mprinter_last_swap_black_id foreign key (last_swap_black_id) references mprinter_state (id) on delete restrict on update restrict; - -create index ix_mprinter_state_printer_id on mprinter_state (printer_id); -alter table mprinter_state add constraint fk_mprinter_state_printer_id foreign key (printer_id) references mprinter (id) on delete restrict on update restrict; - -create index ix_mprofile_picture_id on mprofile (picture_id); -alter table mprofile add constraint fk_mprofile_picture_id foreign key (picture_id) references mmedia (id) on delete restrict on update restrict; - -create index ix_mrole_muser_mrole on mrole_muser (mrole_roleid); -alter table mrole_muser add constraint fk_mrole_muser_mrole foreign key (mrole_roleid) references mrole (roleid) on delete restrict on update restrict; - -create index ix_mrole_muser_muser on mrole_muser (muser_userid); -alter table mrole_muser add constraint fk_mrole_muser_muser foreign key (muser_userid) references muser (userid) on delete restrict on update restrict; - -create index ix_muser_user_type_id on muser (user_type_id); -alter table muser add constraint fk_muser_user_type_id foreign key (user_type_id) references muser_type (id) on delete restrict on update restrict; - -create index ix_mail_user_inbox_mail_user on mail_user_inbox (mail_user_id); -alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; - -create index ix_mail_user_inbox_mail_box on mail_user_inbox (mail_box_id); -alter table mail_user_inbox add constraint fk_mail_user_inbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; - -create index ix_mail_user_outbox_mail_user on mail_user_outbox (mail_user_id); -alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_user foreign key (mail_user_id) references mail_user (id) on delete restrict on update restrict; - -create index ix_mail_user_outbox_mail_box on mail_user_outbox (mail_box_id); -alter table mail_user_outbox add constraint fk_mail_user_outbox_mail_box foreign key (mail_box_id) references mail_box (id) on delete restrict on update restrict; - -create index ix_c_message_conversation_id on c_message (conversation_id); -alter table c_message add constraint fk_c_message_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; - -create index ix_c_message_user_id on c_message (user_id); -alter table c_message add constraint fk_c_message_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; - -alter table meter_contract_data add constraint fk_meter_contract_data_special_needs_client_id foreign key (special_needs_client_id) references meter_special_needs_client (id) on delete restrict on update restrict; - -alter table meter_special_needs_client add constraint fk_meter_special_needs_client_primary_id foreign key (primary_id) references meter_special_needs_contact (id) on delete restrict on update restrict; - -alter table meter_version add constraint fk_meter_version_address_data_id foreign key (address_data_id) references meter_address_data (id) on delete restrict on update restrict; - -alter table meter_version add constraint fk_meter_version_contract_data_id foreign key (contract_data_id) references meter_contract_data (id) on delete restrict on update restrict; - -create index ix_mnoc_user_mnoc_role_mnoc_user on mnoc_user_mnoc_role (mnoc_user_user_id); -alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_user foreign key (mnoc_user_user_id) references mnoc_user (user_id) on delete restrict on update restrict; - -create index ix_mnoc_user_mnoc_role_mnoc_role on mnoc_user_mnoc_role (mnoc_role_role_id); -alter table mnoc_user_mnoc_role add constraint fk_mnoc_user_mnoc_role_mnoc_role foreign key (mnoc_role_role_id) references mnoc_role (role_id) on delete restrict on update restrict; - -create index ix_mny_b_a_id on mny_b (a_id); -alter table mny_b add constraint fk_mny_b_a_id foreign key (a_id) references mny_a (id) on delete restrict on update restrict; - -create index ix_mny_b_mny_c_mny_b on mny_b_mny_c (mny_b_id); -alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_b foreign key (mny_b_id) references mny_b (id) on delete restrict on update restrict; - -create index ix_mny_b_mny_c_mny_c on mny_b_mny_c (mny_c_id); -alter table mny_b_mny_c add constraint fk_mny_b_mny_c_mny_c foreign key (mny_c_id) references mny_c (id) on delete restrict on update restrict; - -create index ix_subtopics_mny_topic_1 on subtopics (topic); -alter table subtopics add constraint fk_subtopics_mny_topic_1 foreign key (topic) references mny_topic (id) on delete restrict on update restrict; - -create index ix_subtopics_mny_topic_2 on subtopics (subtopic); -alter table subtopics add constraint fk_subtopics_mny_topic_2 foreign key (subtopic) references mny_topic (id) on delete restrict on update restrict; - -create index ix_mp_role_mp_user_id on mp_role (mp_user_id); -alter table mp_role add constraint fk_mp_role_mp_user_id foreign key (mp_user_id) references mp_user (id) on delete restrict on update restrict; - -create index ix_ms_many_a_many_b_ms_many_a on ms_many_a_many_b (ms_many_a_aid); -alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; - -create index ix_ms_many_a_many_b_ms_many_b on ms_many_a_many_b (ms_many_b_bid); -alter table ms_many_a_many_b add constraint fk_ms_many_a_many_b_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; - -create index ix_ms_many_b_many_a_ms_many_b on ms_many_b_many_a (ms_many_b_bid); -alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_b foreign key (ms_many_b_bid) references ms_many_b (bid) on delete restrict on update restrict; - -create index ix_ms_many_b_many_a_ms_many_a on ms_many_b_many_a (ms_many_a_aid); -alter table ms_many_b_many_a add constraint fk_ms_many_b_many_a_ms_many_a foreign key (ms_many_a_aid) references ms_many_a (aid) on delete restrict on update restrict; - -create index ix_my_lob_size_join_many_parent_id on my_lob_size_join_many (parent_id); -alter table my_lob_size_join_many add constraint fk_my_lob_size_join_many_parent_id foreign key (parent_id) references my_lob_size (id) on delete restrict on update restrict; - -create index ix_o_cached_bean_country_o_cached_bean on o_cached_bean_country (o_cached_bean_id); -alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_cached_bean foreign key (o_cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; - -create index ix_o_cached_bean_country_o_country on o_cached_bean_country (o_country_code); -alter table o_cached_bean_country add constraint fk_o_cached_bean_country_o_country foreign key (o_country_code) references o_country (code) on delete restrict on update restrict; - -create index ix_o_cached_bean_child_cached_bean_id on o_cached_bean_child (cached_bean_id); -alter table o_cached_bean_child add constraint fk_o_cached_bean_child_cached_bean_id foreign key (cached_bean_id) references o_cached_bean (id) on delete restrict on update restrict; - -alter table oengine add constraint fk_oengine_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; - -alter table ogear_box add constraint fk_ogear_box_car_id foreign key (car_id) references ocar (id) on delete restrict on update restrict; - -alter table oroad_show_msg add constraint fk_oroad_show_msg_company_id foreign key (company_id) references ocompany (id) on delete restrict on update restrict; - -create index ix_om_ordered_detail_master_id on om_ordered_detail (master_id); -alter table om_ordered_detail add constraint fk_om_ordered_detail_master_id foreign key (master_id) references om_ordered_master (id) on delete restrict on update restrict; - -create index ix_o_order_kcustomer_id on o_order (kcustomer_id); -alter table o_order add constraint fk_o_order_kcustomer_id foreign key (kcustomer_id) references o_customer (id) on delete restrict on update restrict; - -create index ix_o_order_detail_order_id on o_order_detail (order_id); -alter table o_order_detail add constraint fk_o_order_detail_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; - -create index ix_o_order_detail_product_id on o_order_detail (product_id); -alter table o_order_detail add constraint fk_o_order_detail_product_id foreign key (product_id) references o_product (id) on delete restrict on update restrict; - -create index ix_s_order_items_order_uuid on s_order_items (order_uuid); -alter table s_order_items add constraint fk_s_order_items_order_uuid foreign key (order_uuid) references s_orders (uuid) on delete restrict on update restrict; - -create index ix_or_order_ship_order_id on or_order_ship (order_id); -alter table or_order_ship add constraint fk_or_order_ship_order_id foreign key (order_id) references o_order (id) on delete restrict on update restrict; - -alter table organization_node add constraint fk_organization_node_parent_tree_node_id foreign key (parent_tree_node_id) references organization_tree_node (id) on delete restrict on update restrict; - -create index ix_orp_detail_master_id on orp_detail (master_id); -alter table orp_detail add constraint fk_orp_detail_master_id foreign key (master_id) references orp_master (id) on delete restrict on update restrict; - -create index ix_orp_detail2_orp_master2_id on orp_detail2 (orp_master2_id); -alter table orp_detail2 add constraint fk_orp_detail2_orp_master2_id foreign key (orp_master2_id) references orp_master2 (id) on delete restrict on update restrict; - -alter table oto_atwo add constraint fk_oto_atwo_aone_id foreign key (aone_id) references oto_aone (id) on delete restrict on update restrict; - -alter table oto_bchild add constraint fk_oto_bchild_master_id foreign key (master_id) references oto_bmaster (id) on delete restrict on update restrict; - -alter table oto_child add constraint fk_oto_child_master_id foreign key (master_id) references oto_master (id) on delete restrict on update restrict; - -alter table oto_cust_address add constraint fk_oto_cust_address_customer_cid foreign key (customer_cid) references oto_cust (cid) on delete restrict on update restrict; - -alter table oto_level_a add constraint fk_oto_level_a_b_id foreign key (b_id) references oto_level_b (id) on delete restrict on update restrict; - -alter table oto_level_b add constraint fk_oto_level_b_c_id foreign key (c_id) references oto_level_c (id) on delete restrict on update restrict; - -alter table oto_prime_extra add constraint fk_oto_prime_extra_eid foreign key (eid) references oto_prime (pid) on delete restrict on update restrict; - -alter table oto_sd_child add constraint fk_oto_sd_child_master_id foreign key (master_id) references oto_sd_master (id) on delete restrict on update restrict; - -create index ix_oto_th_many_oto_th_top_id on oto_th_many (oto_th_top_id); -alter table oto_th_many add constraint fk_oto_th_many_oto_th_top_id foreign key (oto_th_top_id) references oto_th_top (id) on delete restrict on update restrict; - -alter table oto_th_one add constraint fk_oto_th_one_many_id foreign key (many_id) references oto_th_many (id) on delete restrict on update restrict; - -alter table oto_ubprime_extra add constraint fk_oto_ubprime_extra_eid foreign key (eid) references oto_ubprime (pid) on delete restrict on update restrict; - -alter table oto_user_model add constraint fk_oto_user_model_user_optional_id foreign key (user_optional_id) references oto_user_model_optional (id) on delete restrict on update restrict; - -alter table pfile add constraint fk_pfile_file_content_id foreign key (file_content_id) references pfile_content (id) on delete restrict on update restrict; - -alter table pfile add constraint fk_pfile_file_content2_id foreign key (file_content2_id) references pfile_content (id) on delete restrict on update restrict; - -alter table paggview add constraint fk_paggview_pview_id foreign key (pview_id) references pp (id) on delete restrict on update restrict; - -create index ix_pallet_location_zone_sid on pallet_location (zone_sid); -alter table pallet_location add constraint fk_pallet_location_zone_sid foreign key (zone_sid) references zones (id) on delete restrict on update restrict; - -alter table parcel_location add constraint fk_parcel_location_parcelid foreign key (parcelid) references parcel (parcelid) on delete restrict on update restrict; - -create index ix_rawinherit_parent_rawinherit_data_rawinherit_parent on rawinherit_parent_rawinherit_data (rawinherit_parent_id); -alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_parent foreign key (rawinherit_parent_id) references rawinherit_parent (id) on delete restrict on update restrict; - -create index ix_rawinherit_parent_rawinherit_data_rawinherit_data on rawinherit_parent_rawinherit_data (rawinherit_data_id); -alter table rawinherit_parent_rawinherit_data add constraint fk_rawinherit_parent_rawinherit_data_rawinherit_data foreign key (rawinherit_data_id) references rawinherit_data (id) on delete restrict on update restrict; - -create index ix_parent_person_some_bean_id on parent_person (some_bean_id); -alter table parent_person add constraint fk_parent_person_some_bean_id foreign key (some_bean_id) references e_basic (id) on delete restrict on update restrict; - -create index ix_parent_person_parent_identifier on parent_person (parent_identifier); -alter table parent_person add constraint fk_parent_person_parent_identifier foreign key (parent_identifier) references grand_parent_person (identifier) on delete restrict on update restrict; - -create index ix_c_participation_conversation_id on c_participation (conversation_id); -alter table c_participation add constraint fk_c_participation_conversation_id foreign key (conversation_id) references c_conversation (id) on delete restrict on update restrict; - -create index ix_c_participation_user_id on c_participation (user_id); -alter table c_participation add constraint fk_c_participation_user_id foreign key (user_id) references c_user (id) on delete restrict on update restrict; - -alter table persistent_file_content add constraint fk_persistent_file_content_persistent_file_id foreign key (persistent_file_id) references persistent_file (id) on delete restrict on update restrict; - -create index ix_person_default_address_oid on person (default_address_oid); -alter table person add constraint fk_person_default_address_oid foreign key (default_address_oid) references address (oid) on delete restrict on update restrict; - -create index ix_person_cache_email_person_info_person_id on person_cache_email (person_info_person_id); -alter table person_cache_email add constraint fk_person_cache_email_person_info_person_id foreign key (person_info_person_id) references person_cache_info (person_id) on delete restrict on update restrict; - -create index ix_phones_person_id on phones (person_id); -alter table phones add constraint fk_phones_person_id foreign key (person_id) references persons (id) on delete restrict on update restrict; - -create index ix_e_position_contract_id on e_position (contract_id); -alter table e_position add constraint fk_e_position_contract_id foreign key (contract_id) references contract (id) on delete restrict on update restrict; - -create index ix_pp_to_ww_pp on pp_to_ww (pp_id); -alter table pp_to_ww add constraint fk_pp_to_ww_pp foreign key (pp_id) references pp (id) on delete restrict on update restrict; - -create index ix_pp_to_ww_wview on pp_to_ww (ww_id); -alter table pp_to_ww add constraint fk_pp_to_ww_wview foreign key (ww_id) references wview (id) on delete restrict on update restrict; - -create index ix_question_groupobjectid on question (groupobjectid); -alter table question add constraint fk_question_groupobjectid foreign key (groupobjectid) references survey_group (id) on delete restrict on update restrict; - -create index ix_r_orders_customer on r_orders (company,customername); -alter table r_orders add constraint fk_r_orders_customer foreign key (company,customername) references rcustomer (company,name) on delete restrict on update restrict; - -create index ix_rel_master_detail_id on rel_master (detail_id); -alter table rel_master add constraint fk_rel_master_detail_id foreign key (detail_id) references rel_detail (id) on delete restrict on update restrict; - -create index ix_resourcefile_parentresourcefileid on resourcefile (parentresourcefileid); -alter table resourcefile add constraint fk_resourcefile_parentresourcefileid foreign key (parentresourcefileid) references resourcefile (id) on delete restrict on update restrict; - -create index ix_mt_role_tenant_id on mt_role (tenant_id); -alter table mt_role add constraint fk_mt_role_tenant_id foreign key (tenant_id) references mt_tenant (id) on delete restrict on update restrict; - -create index ix_mt_role_permission_mt_role on mt_role_permission (mt_role_id); -alter table mt_role_permission add constraint fk_mt_role_permission_mt_role foreign key (mt_role_id) references mt_role (id) on delete restrict on update restrict; - -create index ix_mt_role_permission_mt_permission on mt_role_permission (mt_permission_id); -alter table mt_role_permission add constraint fk_mt_role_permission_mt_permission foreign key (mt_permission_id) references mt_permission (id) on delete restrict on update restrict; - -alter table f_second add constraint fk_f_second_first foreign key (first) references f_first (id) on delete restrict on update restrict; - -create index ix_section_article_id on section (article_id); -alter table section add constraint fk_section_article_id foreign key (article_id) references article (id) on delete restrict on update restrict; - -create index ix_self_parent_parent_id on self_parent (parent_id); -alter table self_parent add constraint fk_self_parent_parent_id foreign key (parent_id) references self_parent (id) on delete restrict on update restrict; - -create index ix_self_ref_customer_referred_by_id on self_ref_customer (referred_by_id); -alter table self_ref_customer add constraint fk_self_ref_customer_referred_by_id foreign key (referred_by_id) references self_ref_customer (id) on delete restrict on update restrict; - -create index ix_self_ref_example_parent_id on self_ref_example (parent_id); -alter table self_ref_example add constraint fk_self_ref_example_parent_id foreign key (parent_id) references self_ref_example (id) on delete restrict on update restrict; - -alter table e_save_test_b add constraint fk_e_save_test_b_sibling_a_id foreign key (sibling_a_id) references e_save_test_a (id) on delete restrict on update restrict; - -create index ix_site_parent_id on site (parent_id); -alter table site add constraint fk_site_parent_id foreign key (parent_id) references site (id) on delete restrict on update restrict; - -alter table site add constraint fk_site_data_container_id foreign key (data_container_id) references data_container (id) on delete restrict on update restrict; - -alter table site add constraint fk_site_site_address_id foreign key (site_address_id) references site_address (id) on delete restrict on update restrict; - -create index ix_stockforecast_inner_report_id on stockforecast (inner_report_id); -alter table stockforecast add constraint fk_stockforecast_inner_report_id foreign key (inner_report_id) references inner_report (id) on delete restrict on update restrict; - -create index ix_sub_section_section_id on sub_section (section_id); -alter table sub_section add constraint fk_sub_section_section_id foreign key (section_id) references section (id) on delete restrict on update restrict; - -create index ix_tevent_many_event_id on tevent_many (event_id); -alter table tevent_many add constraint fk_tevent_many_event_id foreign key (event_id) references tevent_one (id) on delete restrict on update restrict; - -alter table tevent_one add constraint fk_tevent_one_event_id foreign key (event_id) references tevent (id) on delete restrict on update restrict; - -create index ix_t_detail_with_other_namexxxyy_master_id on t_detail_with_other_namexxxyy (master_id); -alter table t_detail_with_other_namexxxyy add constraint fk_t_detail_with_other_namexxxyy_master_id foreign key (master_id) references t_atable_thatisrelatively (id) on delete restrict on update restrict; - -create index ix_ts_detail_two_master_id on ts_detail_two (master_id); -alter table ts_detail_two add constraint fk_ts_detail_two_master_id foreign key (master_id) references ts_master_two (id) on delete restrict on update restrict; - -create index ix_twheel_owner_plate_no on twheel (owner_plate_no); -alter table twheel add constraint fk_twheel_owner_plate_no foreign key (owner_plate_no) references tcar (plate_no) on delete restrict on update restrict; - -alter table tire add constraint fk_tire_wheel foreign key (wheel) references wheel (id) on delete restrict on update restrict; - -create index ix_trip_vehicle_driver_id on trip (vehicle_driver_id); -alter table trip add constraint fk_trip_vehicle_driver_id foreign key (vehicle_driver_id) references vehicle_driver (id) on delete restrict on update restrict; - -create index ix_trip_address_id on trip (address_id); -alter table trip add constraint fk_trip_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_type_sub_type_id on "type" (sub_type_id); -alter table "type" add constraint fk_type_sub_type_id foreign key (sub_type_id) references sub_type (sub_type_id) on delete restrict on update restrict; - -create index ix_usib_child_parent_id on usib_child (parent_id); -alter table usib_child add constraint fk_usib_child_parent_id foreign key (parent_id) references usib_parent (id) on delete restrict on update restrict; - -alter table usib_child_sibling add constraint fk_usib_child_sibling_child_id foreign key (child_id) references usib_child (id) on delete restrict on update restrict; - -create index ix_ut_detail_utmaster_id on ut_detail (utmaster_id); -alter table ut_detail add constraint fk_ut_detail_utmaster_id foreign key (utmaster_id) references ut_master (id) on delete restrict on update restrict; - -create index ix_uutwo_master_id on uutwo (master_id); -alter table uutwo add constraint fk_uutwo_master_id foreign key (master_id) references uuone (id) on delete restrict on update restrict; - -alter table oto_user add constraint fk_oto_user_account_id foreign key (account_id) references oto_account (id) on delete restrict on update restrict; - -create index ix_c_user_group_id on c_user (group_id); -alter table c_user add constraint fk_c_user_group_id foreign key (group_id) references c_group (id) on delete restrict on update restrict; - -create index ix_em_user_role_user_id on em_user_role (user_id); -alter table em_user_role add constraint fk_em_user_role_user_id foreign key (user_id) references em_user (id) on delete restrict on update restrict; - -create index ix_em_user_role_role_id on em_user_role (role_id); -alter table em_user_role add constraint fk_em_user_role_role_id foreign key (role_id) references em_role (id) on delete restrict on update restrict; - -create index ix_vehicle_lease_id on vehicle (lease_id); -alter table vehicle add constraint fk_vehicle_lease_id foreign key (lease_id) references vehicle_lease (id) on delete restrict on update restrict; - -create index ix_vehicle_car_ref_id on vehicle (car_ref_id); -alter table vehicle add constraint fk_vehicle_car_ref_id foreign key (car_ref_id) references truck_ref (id) on delete restrict on update restrict; - -create index ix_vehicle_truck_ref_id on vehicle (truck_ref_id); -alter table vehicle add constraint fk_vehicle_truck_ref_id foreign key (truck_ref_id) references truck_ref (id) on delete restrict on update restrict; - -create index ix_vehicle_driver_vehicle_id on vehicle_driver (vehicle_id); -alter table vehicle_driver add constraint fk_vehicle_driver_vehicle_id foreign key (vehicle_id) references vehicle (id) on delete restrict on update restrict; - -create index ix_vehicle_driver_address_id on vehicle_driver (address_id); -alter table vehicle_driver add constraint fk_vehicle_driver_address_id foreign key (address_id) references o_address (id) on delete restrict on update restrict; - -create index ix_warehouses_officezoneid on warehouses (officezoneid); -alter table warehouses add constraint fk_warehouses_officezoneid foreign key (officezoneid) references zones (id) on delete restrict on update restrict; - -create index ix_warehousesshippingzones_warehouses on warehousesshippingzones (warehouseid); -alter table warehousesshippingzones add constraint fk_warehousesshippingzones_warehouses foreign key (warehouseid) references warehouses (id) on delete restrict on update restrict; - -create index ix_warehousesshippingzones_zones on warehousesshippingzones (shippingzoneid); -alter table warehousesshippingzones add constraint fk_warehousesshippingzones_zones foreign key (shippingzoneid) references zones (id) on delete restrict on update restrict; - -create index ix_sa_wheel_tire on sa_wheel (tire); -alter table sa_wheel add constraint fk_sa_wheel_tire foreign key (tire) references sa_tire (id) on delete restrict on update restrict; - -create index ix_sa_wheel_car on sa_wheel (car); -alter table sa_wheel add constraint fk_sa_wheel_car foreign key (car) references sa_car (id) on delete restrict on update restrict; - -create index ix_g_who_props_otm_who_created_id on g_who_props_otm (who_created_id); -alter table g_who_props_otm add constraint fk_g_who_props_otm_who_created_id foreign key (who_created_id) references g_user (id) on delete restrict on update restrict; - -create index ix_g_who_props_otm_who_modified_id on g_who_props_otm (who_modified_id); -alter table g_who_props_otm add constraint fk_g_who_props_otm_who_modified_id foreign key (who_modified_id) references g_user (id) on delete restrict on update restrict; - -create index ix_with_zero_parent_id on with_zero (parent_id); -alter table with_zero add constraint fk_with_zero_parent_id foreign key (parent_id) references parent (id) on delete restrict on update restrict; - -alter table hx_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hx_link set sys_period = tstzrange(when_created, null); -create table hx_link_history(like hx_link); -create view hx_link_with_history as select * from hx_link union all select * from hx_link_history; - -alter table hi_link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hi_link set sys_period = tstzrange(when_created, null); -create table hi_link_history(like hi_link); -create view hi_link_with_history as select * from hi_link union all select * from hi_link_history; - -alter table hi_link_doc add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -create table hi_link_doc_history(like hi_link_doc); -create view hi_link_doc_with_history as select * from hi_link_doc union all select * from hi_link_doc_history; - -alter table hi_tone add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hi_tone set sys_period = tstzrange(when_created, null); -create table hi_tone_history(like hi_tone); -create view hi_tone_with_history as select * from hi_tone union all select * from hi_tone_history; - -alter table hi_tthree add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hi_tthree set sys_period = tstzrange(when_created, null); -create table hi_tthree_history(like hi_tthree); -create view hi_tthree_with_history as select * from hi_tthree union all select * from hi_tthree_history; - -alter table hi_ttwo add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hi_ttwo set sys_period = tstzrange(when_created, null); -create table hi_ttwo_history(like hi_ttwo); -create view hi_ttwo_with_history as select * from hi_ttwo union all select * from hi_ttwo_history; - -alter table hsd_setting add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hsd_setting set sys_period = tstzrange(when_created, null); -create table hsd_setting_history(like hsd_setting); -create view hsd_setting_with_history as select * from hsd_setting union all select * from hsd_setting_history; - -alter table hsd_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update hsd_user set sys_period = tstzrange(when_created, null); -create table hsd_user_history(like hsd_user); -create view hsd_user_with_history as select * from hsd_user union all select * from hsd_user_history; - -alter table link add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update link set sys_period = tstzrange(when_created, null); -create table link_history(like link); -create view link_with_history as select * from link union all select * from link_history; - -alter table c_user add column sys_period tstzrange not null default tstzrange(current_timestamp, null); -update c_user set sys_period = tstzrange(when_created, null); -create table c_user_history(like c_user); -create view c_user_with_history as select * from c_user union all select * from c_user_history; - -create or replace function hx_link_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hx_link_history (sys_period,id, name, location, comments, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hx_link_history_upd - before update or delete on hx_link - for each row execute procedure hx_link_history_version(); - -create or replace function hi_link_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hi_link_history (sys_period,id, name, location, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hi_link_history_upd - before update or delete on hi_link - for each row execute procedure hi_link_history_version(); - -create or replace function hi_link_doc_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hi_link_doc_history (sys_period,hi_link_id, hi_doc_id) values (tstzrange(lowerTs,upperTs), OLD.hi_link_id, OLD.hi_doc_id); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hi_link_doc_history_upd - before update or delete on hi_link_doc - for each row execute procedure hi_link_doc_history_version(); - -create or replace function hi_tone_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hi_tone_history (sys_period,id, name, comments, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.comments, OLD.version, OLD.when_created, OLD.when_modified); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hi_tone_history_upd - before update or delete on hi_tone - for each row execute procedure hi_tone_history_version(); - -create or replace function hi_tthree_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hi_tthree_history (sys_period,id, hi_ttwo_id, three, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_ttwo_id, OLD.three, OLD.version, OLD.when_created, OLD.when_modified); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hi_tthree_history_upd - before update or delete on hi_tthree - for each row execute procedure hi_tthree_history_version(); - -create or replace function hi_ttwo_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hi_ttwo_history (sys_period,id, hi_tone_id, two, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.hi_tone_id, OLD.two, OLD.version, OLD.when_created, OLD.when_modified); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hi_ttwo_history_upd - before update or delete on hi_ttwo - for each row execute procedure hi_ttwo_history_version(); - -create or replace function hsd_setting_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hsd_setting_history (sys_period,id, code, content, user_id, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.code, OLD.content, OLD.user_id, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hsd_setting_history_upd - before update or delete on hsd_setting - for each row execute procedure hsd_setting_history_version(); - -create or replace function hsd_user_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into hsd_user_history (sys_period,id, name, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger hsd_user_history_upd - before update or delete on hsd_user - for each row execute procedure hsd_user_history_version(); - -create or replace function link_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into link_history (sys_period,id, name, location, when_publish, link_comment, version, when_created, when_modified, deleted) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.name, OLD.location, OLD.when_publish, OLD.link_comment, OLD.version, OLD.when_created, OLD.when_modified, OLD.deleted); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger link_history_upd - before update or delete on link - for each row execute procedure link_history_version(); - -create or replace function c_user_history_version() returns trigger as $$ -declare - lowerTs timestamptz; - upperTs timestamptz; -begin - lowerTs = lower(OLD.sys_period); - upperTs = greatest(lowerTs + '1 microsecond',current_timestamp); - if (TG_OP = 'UPDATE') then - insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); - NEW.sys_period = tstzrange(upperTs,null); - return new; - elsif (TG_OP = 'DELETE') then - insert into c_user_history (sys_period,id, inactive, name, email, group_id, version, when_created, when_modified) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.inactive, OLD.name, OLD.email, OLD.group_id, OLD.version, OLD.when_created, OLD.when_modified); - return old; - end if; -end; -$$ LANGUAGE plpgsql; - -create trigger c_user_history_upd - before update or delete on c_user - for each row execute procedure c_user_history_version(); - diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql deleted file mode 100644 index 2afd91a..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently0/2.1__m5.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m5 (id integer, acol varchar(20), bcol timestamp); - -create index concurrently ix_m5_acol on m5 (acol); \ No newline at end of file diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql deleted file mode 100644 index 3f9a84d..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_concurrently1/2.2__m6.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m6 (id integer, acol varchar(20), bcol timestamp); - -drop index concurrently ix_m5_acol; -create index concurrently ix_m5_acol2 on m5 (acol,id); -create index concurrently ix_m6_acol2 on m6 (bcol); -- junk \ No newline at end of file diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql deleted file mode 100644 index 63ffe8f..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.0__m0.sql +++ /dev/null @@ -1,3 +0,0 @@ - - -create table ${my_table_name} (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql deleted file mode 100644 index 7d68a2e..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_early/1.1__m1.sql +++ /dev/null @@ -1 +0,0 @@ -create table m1 (id integer, acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql deleted file mode 100644 index 63ffe8f..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.0__m0.sql +++ /dev/null @@ -1,3 +0,0 @@ - - -create table ${my_table_name} (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql deleted file mode 100644 index 7d68a2e..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/1.1__m1.sql +++ /dev/null @@ -1 +0,0 @@ -create table m1 (id integer, acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql deleted file mode 100644 index a56969c..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.0__m2.sql +++ /dev/null @@ -1,3 +0,0 @@ - - -create table ${other_table_name} (acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql b/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql deleted file mode 100644 index b2ccc21..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_postgres_early1/2.1__m3.sql +++ /dev/null @@ -1,3 +0,0 @@ - - -create table m4 (acol varchar(20)); diff --git a/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql deleted file mode 100644 index c4aaa00..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.1__initial.sql +++ /dev/null @@ -1,12 +0,0 @@ -create table m1 -( - id integer, - acol varchar(20) -); - -create table m2 -( - id integer, - acol varchar(20), - bcol timestamp -); diff --git a/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql deleted file mode 100644 index 0b975c7..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_sqlserver/1.2__add_m3.sql +++ /dev/null @@ -1,9 +0,0 @@ -create table m3 -( - id integer, - acol varchar(20), - bcol timestamp -); - -insert into m3 (id, acol) -VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql b/ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql deleted file mode 100644 index 0c07143..0000000 --- a/ebean-migration-it/src/test/resources/dbmig_sqlserver/I__create_procs.sql +++ /dev/null @@ -1,114 +0,0 @@ -if not exists (select name from sys.types where name = 'ebean_bigint_tvp') -create type ebean_bigint_tvp as table (c1 bigint) -GO -if not exists (select name from sys.types where name = 'ebean_float_tvp') -create type ebean_float_tvp as table (c1 float) -GO -if not exists (select name from sys.types where name = 'ebean_bit_tvp') -create type ebean_bit_tvp as table (c1 bit) -GO -if not exists (select name from sys.types where name = 'ebean_date_tvp') -create type ebean_date_tvp as table (c1 date) -GO -if not exists (select name from sys.types where name = 'ebean_time_tvp') -create type ebean_time_tvp as table (c1 time) -GO -if not exists (select name from sys.types where name = 'ebean_uniqueidentifier_tvp') -create type ebean_uniqueidentifier_tvp as table (c1 uniqueidentifier) -GO -if not exists (select name from sys.types where name = 'ebean_nvarchar_tvp') -create type ebean_nvarchar_tvp as table (c1 nvarchar(max)) -GO - --- --- PROCEDURE: usp_ebean_drop_indices TABLE, COLUMN --- deletes all indices referring to TABLE.COLUMN --- -CREATE OR ALTER PROCEDURE usp_ebean_drop_indices @tableName nvarchar(255), @columnName nvarchar(255) -AS SET NOCOUNT ON -declare @sql nvarchar(1000) -declare @indexName nvarchar(255) -BEGIN - DECLARE index_cursor CURSOR FOR SELECT i.name from sys.indexes i - join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id - join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id - where i.object_id = OBJECT_ID(@tableName) AND c.name = @columnName; - OPEN index_cursor - FETCH NEXT FROM index_cursor INTO @indexName - WHILE @@FETCH_STATUS = 0 - BEGIN - set @sql = 'drop index ' + @indexName + ' on ' + @tableName; - EXECUTE(@sql); - - FETCH NEXT FROM index_cursor INTO @indexName - END; - CLOSE index_cursor; - DEALLOCATE index_cursor; -END -GO - --- --- PROCEDURE: usp_ebean_drop_default_constraint TABLE, COLUMN --- deletes the default constraint, which has a random name --- -CREATE OR ALTER PROCEDURE usp_ebean_drop_default_constraint @tableName nvarchar(255), @columnName nvarchar(255) -AS SET NOCOUNT ON -declare @tmp nvarchar(1000) -BEGIN - select @tmp = t1.name from sys.default_constraints t1 - join sys.columns t2 on t1.object_id = t2.default_object_id - where t1.parent_object_id = OBJECT_ID(@tableName) and t2.name = @columnName; - - if @tmp is not null EXEC('alter table ' + @tableName +' drop constraint ' + @tmp); -END -GO - --- --- PROCEDURE: usp_ebean_drop_constraints TABLE, COLUMN --- deletes constraints and foreign keys refering to TABLE.COLUMN --- -CREATE OR ALTER PROCEDURE usp_ebean_drop_constraints @tableName nvarchar(255), @columnName nvarchar(255) -AS SET NOCOUNT ON -declare @sql nvarchar(1000) -declare @constraintName nvarchar(255) -BEGIN - DECLARE name_cursor CURSOR FOR - SELECT cc.name from sys.check_constraints cc - join sys.columns c on c.object_id = cc.parent_object_id and c.column_id = cc.parent_column_id - where parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName - UNION SELECT fk.name from sys.foreign_keys fk - join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id - and fkc.parent_object_id = fk.parent_object_id - join sys.columns c on c.object_id = fkc.parent_object_id and c.column_id = fkc.parent_column_id - where fkc.parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName; - - OPEN name_cursor - FETCH NEXT FROM name_cursor INTO @constraintName - WHILE @@FETCH_STATUS = 0 - BEGIN - set @sql = 'alter table ' + @tableName + ' drop constraint ' + @constraintName; - EXECUTE(@sql); - - FETCH NEXT FROM name_cursor INTO @constraintName - END; - CLOSE name_cursor; - DEALLOCATE name_cursor; -END -GO - --- --- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN --- deletes the column annd ensures that all indices and constraints are dropped first --- -CREATE OR ALTER PROCEDURE usp_ebean_drop_column @tableName nvarchar(255), @columnName nvarchar(255) -AS SET NOCOUNT ON -declare @sql nvarchar(1000) -BEGIN - EXEC usp_ebean_drop_indices @tableName, @columnName; - EXEC usp_ebean_drop_default_constraint @tableName, @columnName; - EXEC usp_ebean_drop_constraints @tableName, @columnName; - - set @sql = 'alter table ' + @tableName + ' drop column ' + @columnName; - EXECUTE(@sql); -END -GO diff --git a/ebean-migration-it/src/test/resources/ebean.properties b/ebean-migration-it/src/test/resources/ebean.properties new file mode 100644 index 0000000..05828c0 --- /dev/null +++ b/ebean-migration-it/src/test/resources/ebean.properties @@ -0,0 +1,12 @@ +ebean.ddl.generate=false +ebean.ddl.run=false + +ebean.packages=io.ebean.migration.model + +datasource.default=h2 +datasource.h2.username=sa +datasource.h2.password= +datasource.h2.url=jdbc:h2:mem:testsMem;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE + +ebean.h2.migration.migrationPath=dbmig +ebean.h2.migration.jdbcMigrations=io.ebean.migration.it.V1_2_1__test diff --git a/ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql b/ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/fastcheck/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations b/ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations deleted file mode 100644 index 63d7678..0000000 --- a/ebean-migration-it/src/test/resources/fastcheck/idx_h2.migrations +++ /dev/null @@ -1 +0,0 @@ -567, 1.1__initial.sql diff --git a/ebean-migration-it/src/test/resources/index0/1.0__initial.sql b/ebean-migration-it/src/test/resources/index0/1.0__initial.sql deleted file mode 100644 index 1e2a409..0000000 --- a/ebean-migration-it/src/test/resources/index0/1.0__initial.sql +++ /dev/null @@ -1,232 +0,0 @@ --- Migrationscripts for ebean unittest --- apply changes -create table migtest_ckey_assoc ( - id integer generated by default as identity not null, - assoc_one varchar(255), - constraint pk_migtest_ckey_assoc primary key (id) -); - -create table migtest_ckey_detail ( - id integer generated by default as identity not null, - something varchar(255), - constraint pk_migtest_ckey_detail primary key (id) -); - -create table migtest_ckey_parent ( - one_key integer not null, - two_key varchar(127) not null, - name varchar(255), - version integer not null, - constraint pk_migtest_ckey_parent primary key (one_key,two_key) -); - -create table migtest_fk_cascade ( - id bigint generated by default as identity not null, - one_id bigint, - constraint pk_migtest_fk_cascade primary key (id) -); - -create table migtest_fk_cascade_one ( - id bigint generated by default as identity not null, - constraint pk_migtest_fk_cascade_one primary key (id) -); - -create table migtest_fk_none ( - id bigint generated by default as identity not null, - one_id bigint, - constraint pk_migtest_fk_none primary key (id) -); - -create table migtest_fk_none_via_join ( - id bigint generated by default as identity not null, - one_id bigint, - constraint pk_migtest_fk_none_via_join primary key (id) -); - -create table migtest_fk_one ( - id bigint generated by default as identity not null, - constraint pk_migtest_fk_one primary key (id) -); - -create table migtest_fk_set_null ( - id bigint generated by default as identity not null, - one_id bigint, - constraint pk_migtest_fk_set_null primary key (id) -); - -create table migtest_e_basic ( - id integer generated by default as identity not null, - status varchar(1), - status2 varchar(1) default 'N' not null, - name varchar(127), - description varchar(127), - some_date timestamp, - old_boolean boolean default false not null, - old_boolean2 boolean, - eref_id integer, - indextest1 varchar(127), - indextest2 varchar(127), - indextest3 varchar(127), - indextest4 varchar(127), - indextest5 varchar(127), - indextest6 varchar(127), - user_id integer not null, - constraint ck_migtest_e_basic_status check ( status in ('N','A','I')), - constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')), - constraint uq_migtest_e_basic_indextest2 unique (indextest2), - constraint uq_migtest_e_basic_indextest6 unique (indextest6), - constraint pk_migtest_e_basic primary key (id) -); - -create table migtest_e_enum ( - id integer generated by default as identity not null, - test_status varchar(1), - constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')), - constraint pk_migtest_e_enum primary key (id) -); - -create table migtest_e_history ( - id integer generated by default as identity not null, - test_string varchar(255), - constraint pk_migtest_e_history primary key (id) -); - -create table migtest_e_history2 ( - id integer generated by default as identity not null, - test_string varchar(255), - obsolete_string1 varchar(255), - obsolete_string2 varchar(255), - constraint pk_migtest_e_history2 primary key (id) -); - -create table migtest_e_history3 ( - id integer generated by default as identity not null, - test_string varchar(255), - constraint pk_migtest_e_history3 primary key (id) -); - -create table migtest_e_history4 ( - id integer generated by default as identity not null, - test_number integer, - constraint pk_migtest_e_history4 primary key (id) -); - -create table migtest_e_history5 ( - id integer generated by default as identity not null, - test_number integer, - constraint pk_migtest_e_history5 primary key (id) -); - -create table migtest_e_history6 ( - id integer generated by default as identity not null, - test_number1 integer, - test_number2 integer not null, - constraint pk_migtest_e_history6 primary key (id) -); - -create table migtest_e_ref ( - id integer generated by default as identity not null, - name varchar(127) not null, - constraint uq_migtest_e_ref_name unique (name), - constraint pk_migtest_e_ref primary key (id) -); - -create table migtest_e_softdelete ( - id integer generated by default as identity not null, - test_string varchar(255), - constraint pk_migtest_e_softdelete primary key (id) -); - -create table migtest_mtm_c ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_migtest_mtm_c primary key (id) -); - -create table migtest_mtm_m ( - id bigint generated by default as identity not null, - name varchar(255), - constraint pk_migtest_mtm_m primary key (id) -); - -create table migtest_oto_child ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_migtest_oto_child primary key (id) -); - -create table migtest_oto_master ( - id bigint generated by default as identity not null, - name varchar(255), - constraint pk_migtest_oto_master primary key (id) -); - -create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); -create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); -create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; - -create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; - -create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); -alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; - -alter table migtest_e_history2 add column sys_period_start timestamp default now(); -alter table migtest_e_history2 add column sys_period_end timestamp; -create table migtest_e_history2_history( - id integer, - test_string varchar(255), - obsolete_string1 varchar(255), - obsolete_string2 varchar(255), - sys_period_start timestamp, - sys_period_end timestamp -); -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -alter table migtest_e_history3 add column sys_period_start timestamp default now(); -alter table migtest_e_history3 add column sys_period_end timestamp; -create table migtest_e_history3_history( - id integer, - test_string varchar(255), - sys_period_start timestamp, - sys_period_end timestamp -); -create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; - -alter table migtest_e_history4 add column sys_period_start timestamp default now(); -alter table migtest_e_history4 add column sys_period_end timestamp; -create table migtest_e_history4_history( - id integer, - test_number integer, - sys_period_start timestamp, - sys_period_end timestamp -); -create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; - -alter table migtest_e_history5 add column sys_period_start timestamp default now(); -alter table migtest_e_history5 add column sys_period_end timestamp; -create table migtest_e_history5_history( - id integer, - test_number integer, - sys_period_start timestamp, - sys_period_end timestamp -); -create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; - -alter table migtest_e_history6 add column sys_period_start timestamp default now(); -alter table migtest_e_history6 add column sys_period_end timestamp; -create table migtest_e_history6_history( - id integer, - test_number1 integer, - test_number2 integer, - sys_period_start timestamp, - sys_period_end timestamp -); -create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history; - -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.1.sql b/ebean-migration-it/src/test/resources/index0/1.1.sql deleted file mode 100644 index b51d15d..0000000 --- a/ebean-migration-it/src/test/resources/index0/1.1.sql +++ /dev/null @@ -1,152 +0,0 @@ --- Migrationscripts for ebean unittest --- drop dependencies -drop view if exists migtest_e_history2_with_history; -drop view if exists migtest_e_history3_with_history; -drop view if exists migtest_e_history4_with_history; -drop view if exists migtest_e_history5_with_history; - --- apply changes -create table migtest_e_user ( - id integer 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_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict; -alter table migtest_ckey_parent add column assoc_id integer; - -alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict; -alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict; -alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict; -alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict; - -update migtest_e_basic set status = 'A' where status is null; -alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; -alter table migtest_e_basic alter column status set default 'A'; -alter table migtest_e_basic alter column status set not null; -alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')); -alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2; -alter table migtest_e_basic alter column status2 varchar(127); -alter table migtest_e_basic alter column status2 drop default; -alter table migtest_e_basic alter column status2 set null; - --- rename all collisions; -alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description); - -insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict; -alter table migtest_e_basic alter column user_id set null; -alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null; -alter table migtest_e_basic add column new_boolean_field boolean default true not null; -update migtest_e_basic set new_boolean_field = old_boolean; - -alter table migtest_e_basic add column new_boolean_field2 boolean default true not null; -alter table migtest_e_basic add column progress integer default 0 not null; -alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)); -alter table migtest_e_basic add column new_integer integer default 42 not null; - -alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; -alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; -alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1); -alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name); -alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4); -alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5); -alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; -comment on column migtest_e_history.test_string is 'Column altered to long now'; -alter table migtest_e_history alter column test_string bigint; -comment on table migtest_e_history is 'We have history now'; - --- NOTE: table has @History - special migration may be necessary -update migtest_e_history2 set test_string = 'unknown' where test_string is null; -alter table migtest_e_history2 alter column test_string set default 'unknown'; -alter table migtest_e_history2 alter column test_string set not null; -alter table migtest_e_history2 add column test_string2 varchar(255); -alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null; -alter table migtest_e_history2 add column new_column varchar(20); -alter table migtest_e_history2_history add column test_string2 varchar(255); -alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown'; -alter table migtest_e_history2_history add column new_column varchar(20); - -alter table migtest_e_history4 alter column test_number bigint; -alter table migtest_e_history4_history alter column test_number bigint; -alter table migtest_e_history5 add column test_boolean boolean default false not null; -alter table migtest_e_history5_history add column test_boolean boolean default false; - - --- 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 set null; -alter table migtest_e_softdelete add column deleted boolean default false not null; - -alter table migtest_oto_child add column master_id bigint; - -create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3); -create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); -drop index if exists ix_migtest_e_basic_indextest1; -drop index if exists ix_migtest_e_basic_indextest5; -create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); -alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; - -create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id); -alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; - -create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id); -alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; - -create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); -alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; - -create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); -alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; - -alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict; - -alter table migtest_e_history add column sys_period_start timestamp default now(); -alter table migtest_e_history add column sys_period_end timestamp; -create table migtest_e_history_history( - id integer, - test_string bigint, - sys_period_start timestamp, - sys_period_end timestamp -); -create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history; - -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; - -create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; - -create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; - -create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [add test_string2, add test_string3, add new_column] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [exclude test_string] -drop trigger migtest_e_history3_history_upd; -create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [alter test_number] -drop trigger migtest_e_history4_history_upd; -create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [add test_boolean] -drop trigger migtest_e_history5_history_upd; -create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql b/ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql deleted file mode 100644 index dea5dde..0000000 --- a/ebean-migration-it/src/test/resources/index0/1.2__dropsFor_1.1.sql +++ /dev/null @@ -1,24 +0,0 @@ --- Migrationscripts for ebean unittest --- drop dependencies -drop view if exists migtest_e_history2_with_history; - --- apply changes -alter table migtest_e_basic drop column old_boolean; - -alter table migtest_e_basic drop column old_boolean2; - -alter table migtest_e_basic drop column eref_id; - -alter table migtest_e_history2 drop column obsolete_string1; -alter table migtest_e_history2_history drop column obsolete_string1; - -alter table migtest_e_history2 drop column obsolete_string2; -alter table migtest_e_history2_history drop column obsolete_string2; - -drop table if exists migtest_e_ref; -drop sequence if exists migtest_e_ref_seq; -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - --- changes: [drop obsolete_string1, drop obsolete_string2] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.3.sql b/ebean-migration-it/src/test/resources/index0/1.3.sql deleted file mode 100644 index a1d6cca..0000000 --- a/ebean-migration-it/src/test/resources/index0/1.3.sql +++ /dev/null @@ -1,90 +0,0 @@ --- Migrationscripts for ebean unittest --- drop dependencies -drop view if exists migtest_e_history2_with_history; -drop view if exists migtest_e_history3_with_history; -drop view if exists migtest_e_history4_with_history; - --- apply changes -create table migtest_e_ref ( - id integer generated by default as identity not null, - name varchar(127) not null, - constraint uq_migtest_e_ref_name unique (name), - constraint pk_migtest_e_ref primary key (id) -); - -alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent; -alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id; -alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; -alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id; -alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id; -alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id; -alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; -alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status; -alter table migtest_e_basic alter column status drop default; -alter table migtest_e_basic alter column status set null; -alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I')); - -update migtest_e_basic set status2 = 'N' where status2 is null; -alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2; -alter table migtest_e_basic alter column status2 varchar(1); -alter table migtest_e_basic alter column status2 set default 'N'; -alter table migtest_e_basic alter column status2 set not null; -alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')); -alter table migtest_e_basic drop constraint uq_migtest_e_basic_description; - -update migtest_e_basic set user_id = 23 where user_id is null; -alter table migtest_e_basic drop constraint if exists fk_migtest_e_basic_user_id; -alter table migtest_e_basic alter column user_id set default 23; -alter table migtest_e_basic alter column user_id set not null; -alter table migtest_e_basic add column old_boolean boolean default false not null; -alter table migtest_e_basic add column old_boolean2 boolean; -alter table migtest_e_basic add column eref_id integer; - -alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1; -alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; -alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; -alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; -alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2); -alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6); -alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; -alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')); -comment on column migtest_e_history.test_string is ''; -comment on table migtest_e_history is ''; -alter table migtest_e_history2 alter column test_string drop default; -alter table migtest_e_history2 alter column test_string set null; -alter table migtest_e_history2 add column obsolete_string1 varchar(255); -alter table migtest_e_history2 add column obsolete_string2 varchar(255); -alter table migtest_e_history2_history add column obsolete_string1 varchar(255); -alter table migtest_e_history2_history add column obsolete_string2 varchar(255); - -alter table migtest_e_history4 alter column test_number integer; -alter table migtest_e_history4_history alter column test_number integer; -alter table migtest_e_history6 alter column test_number1 drop default; -alter table migtest_e_history6 alter column test_number1 set null; - --- NOTE: table has @History - special migration may be necessary -update migtest_e_history6 set test_number2 = 7 where test_number2 is null; -alter table migtest_e_history6 alter column test_number2 set default 7; -alter table migtest_e_history6 alter column test_number2 set not null; -create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); -create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); -drop index if exists ix_migtest_e_basic_indextest3; -drop index if exists ix_migtest_e_basic_indextest6; -create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); -alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; - -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; - -create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; - --- changes: [add obsolete_string1, add obsolete_string2] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [include test_string] -drop trigger migtest_e_history3_history_upd; -create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [alter test_number] -drop trigger migtest_e_history4_history_upd; -create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql b/ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql deleted file mode 100644 index 1776f53..0000000 --- a/ebean-migration-it/src/test/resources/index0/1.4__dropsFor_1.3.sql +++ /dev/null @@ -1,58 +0,0 @@ --- Migrationscripts for ebean unittest --- drop dependencies -drop trigger migtest_e_history_history_upd; -drop view migtest_e_history_with_history; -alter table migtest_e_history drop column sys_period_start; -alter table migtest_e_history drop column sys_period_end; -drop table migtest_e_history_history; - -drop view if exists migtest_e_history2_with_history; -drop view if exists migtest_e_history5_with_history; - --- apply changes -alter table migtest_ckey_detail drop column one_key; - -alter table migtest_ckey_detail drop column two_key; - -alter table migtest_ckey_parent drop column assoc_id; - -alter table migtest_e_basic drop column new_string_field; - -alter table migtest_e_basic drop column new_boolean_field; - -alter table migtest_e_basic drop column new_boolean_field2; - -alter table migtest_e_basic drop column progress; - -alter table migtest_e_basic drop column new_integer; - -alter table migtest_e_history2 drop column test_string2; -alter table migtest_e_history2_history drop column test_string2; - -alter table migtest_e_history2 drop column test_string3; -alter table migtest_e_history2_history drop column test_string3; - -alter table migtest_e_history2 drop column new_column; -alter table migtest_e_history2_history drop column new_column; - -alter table migtest_e_history5 drop column test_boolean; -alter table migtest_e_history5_history drop column test_boolean; - -alter table migtest_e_softdelete drop column deleted; - -alter table migtest_oto_child drop column master_id; - -drop table if exists migtest_e_user; -drop sequence if exists migtest_e_user_seq; -drop table if exists migtest_mtm_c_migtest_mtm_m; -drop table if exists migtest_mtm_m_migtest_mtm_c; -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; - --- changes: [drop test_string2, drop test_string3, drop new_column] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [drop test_boolean] -drop trigger migtest_e_history5_history_upd; -create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-migration-it/src/test/resources/index0/idx_h2.migrations b/ebean-migration-it/src/test/resources/index0/idx_h2.migrations deleted file mode 100644 index fb21ce8..0000000 --- a/ebean-migration-it/src/test/resources/index0/idx_h2.migrations +++ /dev/null @@ -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 - diff --git a/ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql deleted file mode 100644 index fd5f737..0000000 --- a/ebean-migration-it/src/test/resources/indexB_0/1.0__initial.sql +++ /dev/null @@ -1,6 +0,0 @@ --- apply changes -create table ${my_table_name} ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_${my_table_name} primary key (id) -); diff --git a/ebean-migration-it/src/test/resources/indexB_0/1.1.sql b/ebean-migration-it/src/test/resources/indexB_0/1.1.sql deleted file mode 100644 index 38e24be..0000000 --- a/ebean-migration-it/src/test/resources/indexB_0/1.1.sql +++ /dev/null @@ -1 +0,0 @@ -insert into ${my_table_name} (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexB_0/1.2.sql b/ebean-migration-it/src/test/resources/indexB_0/1.2.sql deleted file mode 100644 index b3fa4db..0000000 --- a/ebean-migration-it/src/test/resources/indexB_0/1.2.sql +++ /dev/null @@ -1 +0,0 @@ -create table foo (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql deleted file mode 100644 index fd5f737..0000000 --- a/ebean-migration-it/src/test/resources/indexB_1/1.0__initial.sql +++ /dev/null @@ -1,6 +0,0 @@ --- apply changes -create table ${my_table_name} ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_${my_table_name} primary key (id) -); diff --git a/ebean-migration-it/src/test/resources/indexB_1/1.1.sql b/ebean-migration-it/src/test/resources/indexB_1/1.1.sql deleted file mode 100644 index 38e24be..0000000 --- a/ebean-migration-it/src/test/resources/indexB_1/1.1.sql +++ /dev/null @@ -1 +0,0 @@ -insert into ${my_table_name} (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexB_1/1.2.sql b/ebean-migration-it/src/test/resources/indexB_1/1.2.sql deleted file mode 100644 index b3fa4db..0000000 --- a/ebean-migration-it/src/test/resources/indexB_1/1.2.sql +++ /dev/null @@ -1 +0,0 @@ -create table foo (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations b/ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations deleted file mode 100644 index a639c29..0000000 --- a/ebean-migration-it/src/test/resources/indexB_1/idx_h2.migrations +++ /dev/null @@ -1,4 +0,0 @@ -845768926, 1.0__initial.sql -19858255, 1.1.sql -513154593, 1.2.sql - diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql deleted file mode 100644 index fd5f737..0000000 --- a/ebean-migration-it/src/test/resources/indexB_2/1.0__initial.sql +++ /dev/null @@ -1,6 +0,0 @@ --- apply changes -create table ${my_table_name} ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_${my_table_name} primary key (id) -); diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.1.sql b/ebean-migration-it/src/test/resources/indexB_2/1.1.sql deleted file mode 100644 index 38e24be..0000000 --- a/ebean-migration-it/src/test/resources/indexB_2/1.1.sql +++ /dev/null @@ -1 +0,0 @@ -insert into ${my_table_name} (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.2.sql b/ebean-migration-it/src/test/resources/indexB_2/1.2.sql deleted file mode 100644 index b3fa4db..0000000 --- a/ebean-migration-it/src/test/resources/indexB_2/1.2.sql +++ /dev/null @@ -1 +0,0 @@ -create table foo (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_2/1.3.sql b/ebean-migration-it/src/test/resources/indexB_2/1.3.sql deleted file mode 100644 index 1095ac9..0000000 --- a/ebean-migration-it/src/test/resources/indexB_2/1.3.sql +++ /dev/null @@ -1 +0,0 @@ -create table bazz (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations b/ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations deleted file mode 100644 index aa0a5d5..0000000 --- a/ebean-migration-it/src/test/resources/indexB_2/idx_h2.migrations +++ /dev/null @@ -1,5 +0,0 @@ -845768926, 1.0__initial.sql -19858255, 1.1.sql -513154593, 1.2.sql -113154590, 1.3.sql - diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql deleted file mode 100644 index 8f18f2a..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.0__initial.sql +++ /dev/null @@ -1,6 +0,0 @@ --- apply changes -create table m1 ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_m1 primary key (id) -); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql deleted file mode 100644 index 8583711..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.1.sql +++ /dev/null @@ -1 +0,0 @@ -insert into m1 (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql b/ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql deleted file mode 100644 index eb186f5..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_0/1.2.sql +++ /dev/null @@ -1 +0,0 @@ -create table m2 (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations b/ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations deleted file mode 100644 index 6920195..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_0/idx_h2.migrations +++ /dev/null @@ -1,4 +0,0 @@ -1, 1.0__initial.sql -2, 1.1.sql -3, 1.2.sql - diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql deleted file mode 100644 index 8f18f2a..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.0__initial.sql +++ /dev/null @@ -1,6 +0,0 @@ --- apply changes -create table m1 ( - id integer generated by default as identity not null, - name varchar(255), - constraint pk_m1 primary key (id) -); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql deleted file mode 100644 index 8583711..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.1.sql +++ /dev/null @@ -1 +0,0 @@ -insert into m1 (name) values ('hi'); diff --git a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql b/ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql deleted file mode 100644 index eb186f5..0000000 --- a/ebean-migration-it/src/test/resources/indexPatchReset_1/1.2.sql +++ /dev/null @@ -1 +0,0 @@ -create table m2 (acol varchar(10)); diff --git a/ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql b/ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql deleted file mode 100644 index 5f67d2b..0000000 --- a/ebean-migration-it/src/test/resources/multiplatform/h2/1.0__multi-initial.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Migrationscripts for ebean unittest --- apply changes -create table junk ( - id integer generated by default as identity not null, - assoc_one varchar(255) -); diff --git a/ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql b/ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql deleted file mode 100644 index 46c181e..0000000 --- a/ebean-migration-it/src/test/resources/multiplatform/mybase/1.0__one.sql +++ /dev/null @@ -1,4 +0,0 @@ -create table junk ( - id integer generated by default as identity not null, - assoc_one varchar(255) -); diff --git a/ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql b/ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql deleted file mode 100644 index 77ac746..0000000 --- a/ebean-migration-it/src/test/resources/multiplatform/mybase/2.0__two.sql +++ /dev/null @@ -1,4 +0,0 @@ -create table junk2 ( - id integer generated by default as identity not null, - assoc_one varchar(255) -); diff --git a/ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql b/ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql deleted file mode 100644 index e551f49..0000000 --- a/ebean-migration-it/src/test/resources/multiplatform/noth2/2.0__notValidForH2.sql +++ /dev/null @@ -1 +0,0 @@ -This is just junk - would not execute diff --git a/ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql b/ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/tabletest1/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql b/ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/tabletest2-err/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql deleted file mode 100644 index 3518305..0000000 --- a/ebean-migration-it/src/test/resources/tabletest2-err/1.2__add_m3.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m3 (id integer, acol varchar(20), bcol timestamp); - -alter table m1 add column addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql b/ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql deleted file mode 100644 index bf05736..0000000 --- a/ebean-migration-it/src/test/resources/tabletest2-err/R__m2_view.sql +++ /dev/null @@ -1 +0,0 @@ -i am corrupt; \ No newline at end of file diff --git a/ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql b/ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql deleted file mode 100644 index 41f07d7..0000000 --- a/ebean-migration-it/src/test/resources/tabletest2/1.1__initial.sql +++ /dev/null @@ -1,3 +0,0 @@ -create table m1 (id integer, acol varchar(20)); - -create table m2 (id integer, acol varchar(20), bcol timestamp); diff --git a/ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql deleted file mode 100644 index 3518305..0000000 --- a/ebean-migration-it/src/test/resources/tabletest2/1.2__add_m3.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m3 (id integer, acol varchar(20), bcol timestamp); - -alter table m1 add column addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql b/ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql deleted file mode 100644 index 6a7c4df..0000000 --- a/ebean-migration-it/src/test/resources/tabletest2/R__m2_view.sql +++ /dev/null @@ -1 +0,0 @@ -create or replace view m2_vw as select id, acol from m2; diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java index 4f228b9..d44991b 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java @@ -112,7 +112,7 @@ private Connection connection(DataSource dataSource) { * Run the migrations if there are any that need running. Uses optionl DB as context */ private List run(Connection connection, Database db, boolean checkStateOnly) { - return new MigrationEngine(migrationConfig, checkStateOnly).run(connection); + return new MigrationEngine(migrationConfig, checkStateOnly).run(connection, db); } /** From 16aee17d4c77998f8f720c64414efa50db88da83 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 3 Jan 2024 11:04:16 +0100 Subject: [PATCH 12/18] Reverting some code --- .../migration/it/EbeanMigrationTest.java | 2 +- .../io/ebean/migration/it/V1_2_1__test.java | 16 ++++---- ebean-migration/pom.xml | 2 + .../java/io/ebean/migration/AutoRunner.java | 1 - .../io/ebean/migration/JdbcMigration.java | 7 ++++ .../io/ebean/migration/MigrationContext.java | 6 --- .../io/ebean/migration/MigrationRunner.java | 25 +++-------- .../io/ebean/migration/MigrationRunnerDb.java | 41 +++++++++++++++++++ .../runner/DefaultMigrationContext.java | 11 +---- .../runner/LocalJdbcMigrationResource.java | 4 +- .../runner/LocalMigrationResources.java | 3 +- .../migration/runner/MigrationEngine.java | 29 +------------ .../migration/runner/MigrationEngineDb.java | 36 ++++++++++++++++ .../src/main/java/module-info.java | 2 +- .../migration/runner/MigrationTable1Test.java | 2 +- .../migration/runner/MigrationTable2Test.java | 2 +- .../runner/MigrationTableAsyncTest.java | 2 +- .../MigrationTableCreateTableRaceTest.java | 2 +- .../runner/MigrationTableTestDb2.java | 2 +- 19 files changed, 112 insertions(+), 83 deletions(-) create mode 100644 ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java create mode 100644 ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngineDb.java diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java index 0cb690b..d9658ae 100644 --- a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java +++ b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java @@ -24,7 +24,7 @@ public void testEbeanServerJdbcMig() { Database db = DB.getDefault(); config.setName(db.name()); config.load(db.pluginApi().config().getProperties()); - new MigrationRunner(config).run(db); + //new MigrationRunner(config).run(db); M3 m3 = DB.find(M3.class).findOne(); diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java index 1da7c14..8eaa75c 100644 --- a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java +++ b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java @@ -26,14 +26,14 @@ public class V1_2_1__test implements JdbcMigration { @Override public void migrate(MigrationContext context) { - Database db = context.database(); - try (Transaction txn = beginExternalTransaction(context.database(), context.connection())) { - - - M3 m3 = db.find(M3.class).findOne(); - m3.setAcol("Hello Migration"); - db.save(m3); - } +// Database db = context.database(); +// try (Transaction txn = beginExternalTransaction(context.database(), context.connection())) { +// +// +// M3 m3 = db.find(M3.class).findOne(); +// m3.setAcol("Hello Migration"); +// db.save(m3); +// } } private Transaction beginExternalTransaction(Database database, Connection connection) { diff --git a/ebean-migration/pom.xml b/ebean-migration/pom.xml index 266aa0e..3135fb8 100644 --- a/ebean-migration/pom.xml +++ b/ebean-migration/pom.xml @@ -34,6 +34,7 @@ ebean-ddl-runner 2.3 + io.ebean diff --git a/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java b/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java index c6258a6..9383e2f 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java +++ b/ebean-migration/src/main/java/io/ebean/migration/AutoRunner.java @@ -44,5 +44,4 @@ public void setBasePlatform(String basePlatform) { public void run(DataSource dataSource) { new MigrationRunner(config).run(dataSource); } - } diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java index 4f44281..6219412 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java @@ -49,6 +49,13 @@ default String getName() { return getClass().getSimpleName(); } + /** + * Returns the version of the JdbcMigration. By default, it is parsed from {@link #getName()} + */ + default MigrationVersion getVersion() { + return MigrationVersion.parse(getName()); + } + /** * Determines, if this migration can be used for that migrationContext. * Here, platform checks or other things can be implemented. diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java index 43183bd..a2417ad 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java @@ -1,7 +1,5 @@ package io.ebean.migration; -import io.ebean.Database; - import java.sql.Connection; /** @@ -40,8 +38,4 @@ public interface MigrationContext { */ String basePlatform(); - /** - * The Ebean database. - */ - Database database(); } diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java index d44991b..b3270f7 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java @@ -1,7 +1,6 @@ package io.ebean.migration; import io.avaje.applog.AppLog; -import io.ebean.Database; import io.ebean.migration.runner.MigrationEngine; import javax.sql.DataSource; @@ -42,7 +41,7 @@ public List checkState(DataSource dataSource) { * Return the migrations that would be applied if the migration is run. */ public List checkState(Connection connection) { - return run(connection, null, true); + return run(connection, true); } /** @@ -52,13 +51,6 @@ public List checkState(MigrationContext context) { return run(context, true); } - /** - * Return the migrations that would be applied if the migration is run. - */ - public List checkState(Database server) { - return run(connection(server.dataSource()), null, true); - } - /** * Run by creating a DB connection from driver, url, username defined in MigrationConfig. */ @@ -77,7 +69,7 @@ public void run(DataSource dataSource) { * Run the migrations if there are any that need running. */ public void run(Connection connection) { - run(connection, null, false); + run(connection, false); } /** @@ -87,13 +79,6 @@ public void run(MigrationContext context) { run(context, false); } - /** - * Run the migrations if there are any that need running. - */ - public void run(Database db) { - run(connection(db.dataSource()), db,false); - } - private Connection connection(DataSource dataSource) { String username = migrationConfig.getDbUsername(); try { @@ -109,10 +94,10 @@ private Connection connection(DataSource dataSource) { } /** - * Run the migrations if there are any that need running. Uses optionl DB as context + * Run the migrations if there are any that need running. */ - private List run(Connection connection, Database db, boolean checkStateOnly) { - return new MigrationEngine(migrationConfig, checkStateOnly).run(connection, db); + private List run(Connection connection, boolean checkStateOnly) { + return new MigrationEngine(migrationConfig, checkStateOnly).run(connection); } /** diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java new file mode 100644 index 0000000..f690f1f --- /dev/null +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java @@ -0,0 +1,41 @@ +package io.ebean.migration; + +import io.ebean.migration.runner.MigrationEngine; + +import java.sql.Connection; +import java.util.List; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class MigrationRunnerDb extends MigrationRunner { + public MigrationRunnerDb(MigrationConfig migrationConfig) { + super(migrationConfig); + } + + /** + * Return the migrations that would be applied if the migration is run. + */ + /* public List checkState(Database server) { + return run(connection(server.dataSource()), null, true); + }*/ + /** + * Run the migrations if there are any that need running. + */ + /* + public void run(Database db) { + try (Transaction txn = db.beginTransaction()){ + run(connection(db.dataSource()), db, false); + } + }*/ + + + /** + * Run the migrations if there are any that need running. Uses optionl DB as context + */ + /* + private List run(Connection connection, Database db, boolean checkStateOnly) { + return new MigrationEngine(migrationConfig, checkStateOnly).run(connection, db); + } + */ +} diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java index 4b559f1..76d254a 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java @@ -1,6 +1,5 @@ package io.ebean.migration.runner; -import io.ebean.Database; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationContext; @@ -17,14 +16,11 @@ class DefaultMigrationContext implements MigrationContext { private final String platform; private final String basePlatform; - private final Database database; - - DefaultMigrationContext(MigrationConfig config, Connection connection, Database database) { + DefaultMigrationContext(MigrationConfig config, Connection connection) { this.connection = connection; this.migrationPath = config.getMigrationPath(); this.platform = config.getPlatform(); this.basePlatform = config.getBasePlatform(); - this.database = database; } @Override @@ -46,9 +42,4 @@ public String platform() { public String basePlatform() { return basePlatform; } - - @Override - public Database database() { - return database; - } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java index 36cadde..4acd928 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java @@ -15,8 +15,8 @@ final class LocalJdbcMigrationResource extends LocalMigrationResource { /** * Construct with version and resource. */ - LocalJdbcMigrationResource(MigrationVersion version, JdbcMigration migration) { - super(version, migration.getClass().getName()); + LocalJdbcMigrationResource(MigrationVersion version, String location, JdbcMigration migration) { + super(version, location); this.migration = migration; } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index 2d37174..f082fe4 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -94,8 +94,7 @@ private void readJdbcMigrations(MigrationContext context) { if (jdbcMigrations != null) { for (JdbcMigration jdbcMigration : jdbcMigrations) { if (jdbcMigration.matches(context)) { - final var version = MigrationVersion.parse(jdbcMigration.getName()); - versions.add(new LocalJdbcMigrationResource(version, jdbcMigration)); + versions.add(new LocalJdbcMigrationResource(jdbcMigration.getVersion(), jdbcMigration.getName(), jdbcMigration)); } } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java index 04cc543..60e57df 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java @@ -1,14 +1,11 @@ package io.ebean.migration.runner; import io.avaje.applog.AppLog; -import io.ebean.TxScope; import io.ebean.migration.MigrationConfig; import io.ebean.migration.MigrationContext; import io.ebean.migration.MigrationException; import io.ebean.migration.MigrationResource; -import io.ebean.Database; -import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; import java.util.List; @@ -37,18 +34,14 @@ public MigrationEngine(MigrationConfig migrationConfig, boolean checkStateOnly) this.fastMode = !checkStateOnly && migrationConfig.isFastMode(); } - public List run(Connection connection) { - return run(connection, null); - } - /** * Run the migrations if there are any that need running. * * @param connection the connection to run on. Note the connection will be closed. */ - public List run(Connection connection, Database db) { + public List run(Connection connection) { try { - return run(new DefaultMigrationContext(migrationConfig, connection, db)); + return run(new DefaultMigrationContext(migrationConfig, connection)); } finally { close(connection); } @@ -79,24 +72,6 @@ public List run(MigrationContext context) { setAutoCommitFalse(connection); final MigrationTable table = initialiseMigrationTable(firstCheck, connection); - - - /*SpiEbeanServer defaultServer = (SpiEbeanServer)DB.get(); - - assert defaultServer != null; - - TransactionManager transactionManager = (TransactionManager)defaultServer.transactionManager(); - SpiTransaction txn = transactionManager.wrapExternalConnection(connection); - transactionManager.externalBeginTransaction(txn, TxScope.notSupported()); - - try { - this.migrate(defaultServer); - txn.flush(); - } finally { - transactionManager.externalRemoveTransaction(); - }*/ - - try { List result = runMigrations(table, resources.versions()); connection.commit(); diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngineDb.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngineDb.java new file mode 100644 index 0000000..27546c9 --- /dev/null +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngineDb.java @@ -0,0 +1,36 @@ +package io.ebean.migration.runner; + +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationResource; + +import java.sql.Connection; +import java.util.List; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class MigrationEngineDb extends MigrationEngine { + /** + * Create with the MigrationConfig. + * + * @param migrationConfig + * @param checkStateOnly + */ + public MigrationEngineDb(MigrationConfig migrationConfig, boolean checkStateOnly) { + super(migrationConfig, checkStateOnly); + } + + /** + * Run the migrations if there are any that need running. + * + * @param connection the connection to run on. Note the connection will be closed. + */ + /* + public List run(Connection connection, Database db) { + try { + return run(new DefaultMigrationContext(migrationConfig, connection, db)); + } finally { + close(connection); + } + }*/ +} diff --git a/ebean-migration/src/main/java/module-info.java b/ebean-migration/src/main/java/module-info.java index d28c43d..053e07b 100644 --- a/ebean-migration/src/main/java/module-info.java +++ b/ebean-migration/src/main/java/module-info.java @@ -6,7 +6,7 @@ requires transitive io.avaje.applog; requires transitive io.avaje.classpath.scanner; requires transitive io.ebean.ddl.runner; - requires transitive io.ebean.api; + //requires transitive io.ebean.api; requires io.ebean.migration.auto; uses io.ebean.migration.JdbcMigration; diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java index 5cd89bb..d7880c0 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable1Test.java @@ -45,7 +45,7 @@ public void shutdown() { private MigrationTable migrationTable(Connection conn) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java index f8130ce..4b1e6bb 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTable2Test.java @@ -12,7 +12,7 @@ public class MigrationTable2Test { private static MigrationTable migrationTable(MigrationConfig config) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, null, null), new MigrationPlatform()); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, null), new MigrationPlatform()); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java index e7e1235..a6795d8 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableAsyncTest.java @@ -204,7 +204,7 @@ private void runTest(boolean withExisting) throws SQLException, InterruptedExcep } private static MigrationTable migrationTable(MigrationPlatform platform, Connection connection) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection, null), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, connection), platform); return new MigrationTable(fc, false); } diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java index 0539732..f3ad2b7 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableCreateTableRaceTest.java @@ -51,7 +51,7 @@ void testRaceCondition_expect_loserOfCreateTableCanPerformTableExistsCheck() thr try (Connection conn = dataSource.getConnection()) { dropTable(conn); - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); MigrationTable table = new MigrationTable(fc, false); table.createTable(); try { diff --git a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java index 4cd3907..5a35392 100644 --- a/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java +++ b/ebean-migration/src/test/java/io/ebean/migration/runner/MigrationTableTestDb2.java @@ -44,7 +44,7 @@ public void testMigrationTableBase() throws Exception { config.setMigrationPath("dbmig"); try (Connection conn = dataSource.getConnection()) { - var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn, null), platform); + var fc = new FirstCheck(config, new DefaultMigrationContext(config, conn), platform); MigrationTable table = new MigrationTable(fc, false); table.createIfNeededAndLock(); table.unlockMigrationTable(); From e60e4759f9e27fb1b5b10069ad908061159af83c Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 3 Jan 2024 16:51:48 +0100 Subject: [PATCH 13/18] begin with db dependency --- ebean-migration/pom.xml | 2 - .../io/ebean/migration/MigrationContext.java | 7 ++++ .../io/ebean/migration/MigrationRunnerDb.java | 41 ------------------- .../runner/DefaultMigrationContext.java | 6 +++ .../runner/LocalMigrationResources.java | 10 +++-- .../migration/runner/MigrationEngine.java | 6 +-- .../src/main/java/module-info.java | 1 + 7 files changed, 23 insertions(+), 50 deletions(-) delete mode 100644 ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java diff --git a/ebean-migration/pom.xml b/ebean-migration/pom.xml index 3135fb8..266aa0e 100644 --- a/ebean-migration/pom.xml +++ b/ebean-migration/pom.xml @@ -34,7 +34,6 @@ ebean-ddl-runner 2.3 - io.ebean diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java index a2417ad..8422f34 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationContext.java @@ -1,6 +1,7 @@ package io.ebean.migration; import java.sql.Connection; +import java.sql.SQLException; /** * The current context while a migration runs. @@ -38,4 +39,10 @@ public interface MigrationContext { */ String basePlatform(); + /** + * Indicates that all migrations are done and the underlying connection or transaction should perform a commit. + *

    + * NOTE: + */ + void commit() throws SQLException; } diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java deleted file mode 100644 index f690f1f..0000000 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunnerDb.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.ebean.migration; - -import io.ebean.migration.runner.MigrationEngine; - -import java.sql.Connection; -import java.util.List; - -/** - * @author Roland Praml, FOCONIS AG - */ -public class MigrationRunnerDb extends MigrationRunner { - public MigrationRunnerDb(MigrationConfig migrationConfig) { - super(migrationConfig); - } - - /** - * Return the migrations that would be applied if the migration is run. - */ - /* public List checkState(Database server) { - return run(connection(server.dataSource()), null, true); - }*/ - /** - * Run the migrations if there are any that need running. - */ - /* - public void run(Database db) { - try (Transaction txn = db.beginTransaction()){ - run(connection(db.dataSource()), db, false); - } - }*/ - - - /** - * Run the migrations if there are any that need running. Uses optionl DB as context - */ - /* - private List run(Connection connection, Database db, boolean checkStateOnly) { - return new MigrationEngine(migrationConfig, checkStateOnly).run(connection, db); - } - */ -} diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java index 76d254a..4df93c2 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/DefaultMigrationContext.java @@ -4,6 +4,7 @@ import io.ebean.migration.MigrationContext; import java.sql.Connection; +import java.sql.SQLException; /** * A default implementation of the MigrationContext. @@ -42,4 +43,9 @@ public String platform() { public String basePlatform() { return basePlatform; } + + @Override + public void commit() throws SQLException { + connection.commit(); + } } diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index f082fe4..a640021 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -27,14 +27,16 @@ final class LocalMigrationResources { private final MigrationConfig migrationConfig; private final ClassLoader classLoader; private final Iterable jdbcMigrations; + private final MigrationContext context; /** * Construct with configuration options. */ - LocalMigrationResources(MigrationConfig migrationConfig) { + LocalMigrationResources(MigrationConfig migrationConfig, MigrationContext context) { this.migrationConfig = migrationConfig; this.classLoader = migrationConfig.getClassLoader(); this.jdbcMigrations = migrationConfig.getJdbcMigrations(); + this.context = context; } /** @@ -49,7 +51,7 @@ boolean readInitResources() { /** * Read all the migration resources (SQL scripts and JDBC migrations) returning true if there are versions. */ - boolean readResources(MigrationContext context) { + boolean readResources() { if (readFromIndex()) { // automatically enable earlyChecksumMode when using index file with pre-computed checksums migrationConfig.setEarlyChecksumMode(true); @@ -58,7 +60,7 @@ boolean readResources(MigrationContext context) { } // after we read the SQL migrations from index or classpath scan, we // read jdbcMigrations and sort them. - readJdbcMigrations(context); + readJdbcMigrations(); Collections.sort(versions); return !versions.isEmpty(); } @@ -90,7 +92,7 @@ private boolean readFromIndex() { return false; } - private void readJdbcMigrations(MigrationContext context) { + private void readJdbcMigrations() { if (jdbcMigrations != null) { for (JdbcMigration jdbcMigration : jdbcMigrations) { if (jdbcMigration.matches(context)) { diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java index 60e57df..8ea04a5 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java @@ -53,8 +53,8 @@ public List run(Connection connection) { public List run(MigrationContext context) { long startMs = System.currentTimeMillis(); - LocalMigrationResources resources = new LocalMigrationResources(migrationConfig); - if (!resources.readResources(context) && !resources.readInitResources()) { + LocalMigrationResources resources = new LocalMigrationResources(migrationConfig, context); + if (!resources.readResources() && !resources.readInitResources()) { log.log(DEBUG, "no migrations to check"); return emptyList(); } @@ -74,7 +74,7 @@ public List run(MigrationContext context) { final MigrationTable table = initialiseMigrationTable(firstCheck, connection); try { List result = runMigrations(table, resources.versions()); - connection.commit(); + context.commit(); if (!checkStateOnly) { long commitMs = System.currentTimeMillis(); log.log(INFO, "DB migrations completed in {0}ms - executed:{1} totalMigrations:{2} mode:{3}", (commitMs - startMs), table.count(), table.size(), table.mode()); diff --git a/ebean-migration/src/main/java/module-info.java b/ebean-migration/src/main/java/module-info.java index 053e07b..2856c9d 100644 --- a/ebean-migration/src/main/java/module-info.java +++ b/ebean-migration/src/main/java/module-info.java @@ -1,6 +1,7 @@ open module io.ebean.migration { exports io.ebean.migration; + exports io.ebean.migration.db; requires transitive java.sql; requires transitive io.avaje.applog; From 4da3958b2baf5abcdda42d1a842c1bb534423192 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 3 Jan 2024 18:12:32 +0100 Subject: [PATCH 14/18] added plugin --- ebean-migration-db/pom.xml | 169 ++++++++++++++++++ .../migration/db/MigrationContextDb.java | 14 ++ .../ebean/migration/db/MigrationPlugin.java | 37 ++++ .../ebean/migration/db/MigrationRunnerDb.java | 38 ++++ .../db/TransactionBasedMigrationContext.java | 66 +++++++ .../src/main/java/module-info.java | 13 ++ .../META-INF/services/io.ebean.plugin.Plugin | 1 + .../migration/it/EbeanMigrationTest.java | 85 +++++++++ .../io/ebean/migration/it/V1_2_1__test.java | 57 ++++++ .../test}/java/org/migration/model/M3.java | 10 +- .../src/test/resources/dbmig/1.1__initial.sql | 5 + .../src/test/resources/dbmig/1.2__add_m3.sql | 5 + .../src/test/resources/dbmig/I__hello.sql | 1 + .../src/test/resources/dbmig/R__m2_view.sql | 1 + .../src/test/resources/ebean.properties | 12 ++ .../src/test/resources/logback-test.xml | 17 ++ .../java/org/migration/model/DemoModel.java | 15 -- .../migration/it/EbeanMigrationTest.java | 1 - .../io/ebean/migration/it/V1_2_1__test.java | 3 - ebean-migration/pom.xml | 3 +- .../io/ebean/migration/JdbcMigration.java | 3 +- .../io/ebean/migration/MigrationConfig.java | 20 +++ .../runner/LocalMigrationResources.java | 10 +- .../migration/runner/MigrationEngine.java | 4 +- .../src/main/java/module-info.java | 2 - pom.xml | 3 +- 26 files changed, 561 insertions(+), 34 deletions(-) create mode 100644 ebean-migration-db/pom.xml create mode 100644 ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationContextDb.java create mode 100644 ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java create mode 100644 ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationRunnerDb.java create mode 100644 ebean-migration-db/src/main/java/io/ebean/migration/db/TransactionBasedMigrationContext.java create mode 100644 ebean-migration-db/src/main/java/module-info.java create mode 100644 ebean-migration-db/src/main/resources/META-INF/services/io.ebean.plugin.Plugin create mode 100644 ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java create mode 100644 ebean-migration-db/src/test/java/io/ebean/migration/it/V1_2_1__test.java rename {ebean-migration-it/src/main => ebean-migration-db/src/test}/java/org/migration/model/M3.java (67%) create mode 100644 ebean-migration-db/src/test/resources/dbmig/1.1__initial.sql create mode 100644 ebean-migration-db/src/test/resources/dbmig/1.2__add_m3.sql create mode 100644 ebean-migration-db/src/test/resources/dbmig/I__hello.sql create mode 100644 ebean-migration-db/src/test/resources/dbmig/R__m2_view.sql create mode 100644 ebean-migration-db/src/test/resources/ebean.properties create mode 100644 ebean-migration-db/src/test/resources/logback-test.xml delete mode 100644 ebean-migration-it/src/main/java/org/migration/model/DemoModel.java diff --git a/ebean-migration-db/pom.xml b/ebean-migration-db/pom.xml new file mode 100644 index 0000000..2e57eb1 --- /dev/null +++ b/ebean-migration-db/pom.xml @@ -0,0 +1,169 @@ + + + 4.0.0 + + org.avaje + java11-oss + 3.12 + + + + io.ebean + ebean-migration-db + 13.11.2-SNAPSHOT + + + scm:git:git@github.com:ebean-orm/ebean-migration.git + HEAD + + + + true + false + + + + + + io.ebean + ebean-migration + 13.11.2-SNAPSHOT + + + + io.ebean + ebean-api + 13.25.0 + provided + + + + + io.avaje + classpath-scanner + 7.1 + + + + + io.ebean + ebean + 13.25.0 + test + + + + com.h2database + h2 + 2.2.220 + test + + + + com.microsoft.sqlserver + mssql-jdbc + 9.4.1.jre8 + test + + + + mysql + mysql-connector-java + 8.0.28 + test + + + + org.postgresql + postgresql + 42.4.3 + test + + + + com.nuodb.jdbc + nuodb-jdbc + 22.0.0 + test + + + + com.ibm.db2 + jcc + 11.5.6.0 + test + + + + org.mariadb.jdbc + mariadb-java-client + 3.0.6 + test + + + + com.oracle.database.jdbc + + ojdbc8 + 19.12.0.0 + test + + + + + + + + + + + + org.avaje.composite + logback + 1.1 + test + + + + io.ebean + ebean-test-containers + 7.1 + test + + + + io.avaje + junit + 1.3 + test + + + + io.ebean + ebean-datasource + 8.0 + test + + + + + + + io.repaint.maven + tiles-maven-plugin + 2.33 + true + + + io.ebean.tile:enhancement:13.25.0 + + + + + + diff --git a/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationContextDb.java b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationContextDb.java new file mode 100644 index 0000000..214becb --- /dev/null +++ b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationContextDb.java @@ -0,0 +1,14 @@ +package io.ebean.migration.db; + +import io.ebean.Database; +import io.ebean.Transaction; +import io.ebean.migration.MigrationContext; + +/** + * @author Roland Praml, FOCONIS AG + */ +public interface MigrationContextDb extends MigrationContext { + public Transaction transaction(); + + public Database database(); +} diff --git a/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java new file mode 100644 index 0000000..2e28e56 --- /dev/null +++ b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java @@ -0,0 +1,37 @@ +package io.ebean.migration.db; + +import io.ebean.DB; +import io.ebean.Database; +import io.ebean.migration.MigrationConfig; +import io.ebean.plugin.Plugin; +import io.ebean.plugin.SpiServer; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class MigrationPlugin implements Plugin { + private MigrationConfig config = new MigrationConfig(); + private SpiServer server; + + @Override + public void configure(SpiServer server) { + config.setName(server.name()); + config.load(server.config().getProperties()); + this.server = server; + if (server.config().isRunMigration() && config.isAutoRun()) { + throw new UnsupportedOperationException("You cannot enable both"); // TODO + } + } + + @Override + public void online(boolean online) { + if (online && config.isAutoRun()) { + new MigrationRunnerDb(config).run(server); + } + } + + @Override + public void shutdown() { + + } +} diff --git a/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationRunnerDb.java b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationRunnerDb.java new file mode 100644 index 0000000..362a680 --- /dev/null +++ b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationRunnerDb.java @@ -0,0 +1,38 @@ +package io.ebean.migration.db; + +import io.ebean.Database; +import io.ebean.Transaction; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationResource; +import io.ebean.migration.MigrationRunner; + +import java.util.List; + + +/** + * @author Roland Praml, FOCONIS AG + */ +public class MigrationRunnerDb extends MigrationRunner { + public MigrationRunnerDb(MigrationConfig migrationConfig) { + super(migrationConfig); + } + + /** + * Return the migrations that would be applied if the migration is run. + */ + public List checkState(Database db) { + try (Transaction txn = db.beginTransaction()) { + return checkState(new TransactionBasedMigrationContext(migrationConfig, txn, db)); + } + } + + /** + * Run the migrations if there are any that need running. + */ + public void run(Database db) { + try (Transaction txn = db.beginTransaction()) { + run(new TransactionBasedMigrationContext(migrationConfig, txn, db)); + txn.end(); + } + } +} diff --git a/ebean-migration-db/src/main/java/io/ebean/migration/db/TransactionBasedMigrationContext.java b/ebean-migration-db/src/main/java/io/ebean/migration/db/TransactionBasedMigrationContext.java new file mode 100644 index 0000000..4c5dda9 --- /dev/null +++ b/ebean-migration-db/src/main/java/io/ebean/migration/db/TransactionBasedMigrationContext.java @@ -0,0 +1,66 @@ +package io.ebean.migration.db; + +import io.ebean.Database; +import io.ebean.Transaction; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationContext; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * A default implementation of the MigrationContext. + * + * @author Roland Praml, FOCONIS AG + */ +class TransactionBasedMigrationContext implements MigrationContextDb { + private final Transaction transaction; + private final String migrationPath; + private final String platform; + private final String basePlatform; + private final Database database; + + TransactionBasedMigrationContext(MigrationConfig config, Transaction transaction, Database database) { + this.transaction = transaction; + this.migrationPath = config.getMigrationPath(); + this.platform = config.getPlatform(); + this.basePlatform = config.getBasePlatform(); + this.database = database; + } + + @Override + public Connection connection() { + return transaction.connection(); + } + + @Override + public String migrationPath() { + return migrationPath; + } + + @Override + public String platform() { + return platform; + } + + @Override + public String basePlatform() { + return basePlatform; + } + + @Override + public void commit() throws SQLException { + // we must not use txn.commit here, as this closes the underlying connection, which is needed for logicalLock etc. + transaction.commitAndContinue(); + } + + @Override + public Transaction transaction() { + return transaction; + } + + @Override + public Database database() { + return database; + } +} diff --git a/ebean-migration-db/src/main/java/module-info.java b/ebean-migration-db/src/main/java/module-info.java new file mode 100644 index 0000000..15e0a6b --- /dev/null +++ b/ebean-migration-db/src/main/java/module-info.java @@ -0,0 +1,13 @@ +module io.ebean.migration.db { + + exports io.ebean.migration.db; + + requires transitive java.sql; + requires transitive io.avaje.applog; + requires transitive io.avaje.classpath.scanner; + requires transitive io.ebean.ddl.runner; + requires static io.ebean.api; + requires io.ebean.migration; + uses io.ebean.plugin.Plugin; + provides io.ebean.plugin.Plugin with io.ebean.migration.db.MigrationPlugin; +} diff --git a/ebean-migration-db/src/main/resources/META-INF/services/io.ebean.plugin.Plugin b/ebean-migration-db/src/main/resources/META-INF/services/io.ebean.plugin.Plugin new file mode 100644 index 0000000..df259f8 --- /dev/null +++ b/ebean-migration-db/src/main/resources/META-INF/services/io.ebean.plugin.Plugin @@ -0,0 +1 @@ +io.ebean.migration.db.MigrationPlugin diff --git a/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java b/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java new file mode 100644 index 0000000..14287da --- /dev/null +++ b/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java @@ -0,0 +1,85 @@ +package io.ebean.migration.it; + +import io.ebean.DB; +import io.ebean.Database; +import io.ebean.DatabaseFactory; +import io.ebean.config.DatabaseConfig; +import io.ebean.migration.MigrationConfig; +import io.ebean.migration.MigrationRunner; +import io.ebean.migration.db.MigrationRunnerDb; +import org.migration.model.M3; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Roland Praml, FOCONIS AG + */ +public class EbeanMigrationTest { + + @Test + public void testEbeanServerJdbcMig() { + + // NOTE: This can be done by AutoMigration (or MigrationPlugin) later + MigrationConfig config = new MigrationConfig(); + Database db = DB.getDefault(); + try { + config.setName(db.name()); + config.load(db.pluginApi().config().getProperties()); + new MigrationRunnerDb(config).run(db); + + + M3 m3 = DB.find(M3.class).where().idEq(1).findOne(); + assertThat(m3.getAcol()).isEqualTo("Migrate db PreCommit"); + } finally { + db.shutdown(true, false); + } + } + + @Test + public void testWithRunner() { + + // NOTE: This can be done by AutoMigration (or MigrationPlugin) later + DatabaseConfig dbCfg = new DatabaseConfig(); + dbCfg.setName("h2"); + dbCfg.loadFromProperties(); + dbCfg.setRunMigration(true); + Database db = DatabaseFactory.create(dbCfg); + try { + + M3 m3 = DB.find(M3.class).where().idEq(1).findOne(); + assertThat(m3.getAcol()).isEqualTo("Migrate raw"); + } finally { + db.shutdown(true, false); + } + + } + + @Test + public void testNoMigration() { + Database db = DB.getDefault(); + try { + + M3 m3 = DB.find(M3.class).where().idEq(1).findOne(); + assertThat(m3.getAcol()).isEqualTo("Migrate db PreCommit"); + } finally { + db.shutdown(true, false); + } + } + @Test + public void testWithPlugin() { + DatabaseConfig dbCfg = new DatabaseConfig(); + dbCfg.setName("h2"); + dbCfg.loadFromProperties(); + dbCfg.getProperties().setProperty("ebean.h2.migration.autoRun", "true"); + dbCfg.setDefaultServer(true); + Database db = DatabaseFactory.create(dbCfg); + try { + + M3 m3 = DB.find(M3.class).where().idEq(1).findOne(); + assertThat(m3.getAcol()).isEqualTo("Migrate db PreCommit"); + } finally { + db.shutdown(true, false); + } + } +} diff --git a/ebean-migration-db/src/test/java/io/ebean/migration/it/V1_2_1__test.java b/ebean-migration-db/src/test/java/io/ebean/migration/it/V1_2_1__test.java new file mode 100644 index 0000000..520316e --- /dev/null +++ b/ebean-migration-db/src/test/java/io/ebean/migration/it/V1_2_1__test.java @@ -0,0 +1,57 @@ +package io.ebean.migration.it; + +import io.ebean.DB; +import io.ebean.Database; +import io.ebean.Transaction; +import io.ebean.TxScope; +import io.ebean.migration.JdbcMigration; +import io.ebean.migration.MigrationContext; +import io.ebean.migration.db.MigrationContextDb; +import io.ebeaninternal.server.core.DefaultServer; +import io.ebeaninternal.server.transaction.ExternalJdbcTransaction; +import io.ebeaninternal.server.transaction.TransactionManager; +import org.migration.model.M3; + +import javax.persistence.PersistenceException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; +import static org.assertj.core.api.Assertions.assertThat; +/** + * Sample migration. + * + * @author Roland Praml, FOCONIS AG + */ +public class V1_2_1__test implements JdbcMigration { + + + @Override + public void migrate(MigrationContext context) throws SQLException { + if (context instanceof MigrationContextDb) { + // some asserts + Database db = ((MigrationContextDb) context).database(); // do not use DB.getDefault, as it is not yet registered! + + assertThat(((MigrationContextDb) context).transaction()) + .isNotNull() + .isSameAs(db.currentTransaction()); + + M3 m3 = db.find(M3.class).where().idEq(1).findOne(); + m3.setAcol("Migrate db"); + db.save(m3); + + } else { + try (PreparedStatement ps = context.connection().prepareStatement("update m3 set acol = ? where id = ?")) { + ps.setString(1, "Migrate raw"); + ps.setInt(2, 1); + ps.executeUpdate(); + } + } + } + + + @Override + public String toString() { + return "Dummy jdbc migration"; + } +} diff --git a/ebean-migration-it/src/main/java/org/migration/model/M3.java b/ebean-migration-db/src/test/java/org/migration/model/M3.java similarity index 67% rename from ebean-migration-it/src/main/java/org/migration/model/M3.java rename to ebean-migration-db/src/test/java/org/migration/model/M3.java index 9c4eca6..500e2ff 100644 --- a/ebean-migration-it/src/main/java/org/migration/model/M3.java +++ b/ebean-migration-db/src/test/java/org/migration/model/M3.java @@ -1,7 +1,8 @@ package org.migration.model; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.PreUpdate; /** * @author Roland Praml, FOCONIS AG @@ -27,4 +28,9 @@ public String getAcol() { public void setAcol(String acol) { this.acol = acol; } + + @PreUpdate + public void addCommitMsg() { + acol += " PreCommit"; + } } diff --git a/ebean-migration-db/src/test/resources/dbmig/1.1__initial.sql b/ebean-migration-db/src/test/resources/dbmig/1.1__initial.sql new file mode 100644 index 0000000..c627009 --- /dev/null +++ b/ebean-migration-db/src/test/resources/dbmig/1.1__initial.sql @@ -0,0 +1,5 @@ +create table m1 (id integer, acol varchar(20)); +-- Check with DB2: +-- call sysproc.admin_cmd('reorg table m1'); +create table m2 (id integer, acol varchar(20), bcol timestamp); + diff --git a/ebean-migration-db/src/test/resources/dbmig/1.2__add_m3.sql b/ebean-migration-db/src/test/resources/dbmig/1.2__add_m3.sql new file mode 100644 index 0000000..3518305 --- /dev/null +++ b/ebean-migration-db/src/test/resources/dbmig/1.2__add_m3.sql @@ -0,0 +1,5 @@ +create table m3 (id integer, acol varchar(20), bcol timestamp); + +alter table m1 add column addcol varchar(10); + +insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-db/src/test/resources/dbmig/I__hello.sql b/ebean-migration-db/src/test/resources/dbmig/I__hello.sql new file mode 100644 index 0000000..63a4934 --- /dev/null +++ b/ebean-migration-db/src/test/resources/dbmig/I__hello.sql @@ -0,0 +1 @@ +-- do nothing diff --git a/ebean-migration-db/src/test/resources/dbmig/R__m2_view.sql b/ebean-migration-db/src/test/resources/dbmig/R__m2_view.sql new file mode 100644 index 0000000..6a7c4df --- /dev/null +++ b/ebean-migration-db/src/test/resources/dbmig/R__m2_view.sql @@ -0,0 +1 @@ +create or replace view m2_vw as select id, acol from m2; diff --git a/ebean-migration-db/src/test/resources/ebean.properties b/ebean-migration-db/src/test/resources/ebean.properties new file mode 100644 index 0000000..1047822 --- /dev/null +++ b/ebean-migration-db/src/test/resources/ebean.properties @@ -0,0 +1,12 @@ +ebean.ddl.generate=false +ebean.ddl.run=false + +ebean.packages=org.migration.model + +datasource.default=h2 +datasource.h2.username=sa +datasource.h2.password= +datasource.h2.url=jdbc:h2:mem:testsMem;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE + +ebean.h2.migration.migrationPath=dbmig +ebean.h2.migration.jdbcMigrations=io.ebean.migration.it.V1_2_1__test diff --git a/ebean-migration-db/src/test/resources/logback-test.xml b/ebean-migration-db/src/test/resources/logback-test.xml new file mode 100644 index 0000000..a227835 --- /dev/null +++ b/ebean-migration-db/src/test/resources/logback-test.xml @@ -0,0 +1,17 @@ + + + + TRACE + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/ebean-migration-it/src/main/java/org/migration/model/DemoModel.java b/ebean-migration-it/src/main/java/org/migration/model/DemoModel.java deleted file mode 100644 index a0274d1..0000000 --- a/ebean-migration-it/src/main/java/org/migration/model/DemoModel.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.migration.model; - -import jakarta.persistence.Entity; -import jakarta.persistence.Id; - -/** - * @author Roland Praml, FOCONIS AG - */ -@Entity -public class DemoModel { - @Id - private int id; - - private String foo; -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java index d9658ae..0cf7781 100644 --- a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java +++ b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java @@ -5,7 +5,6 @@ import io.ebean.DatabaseFactory; import io.ebean.config.DatabaseConfig; import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationRunner; import org.migration.model.M3; import org.junit.jupiter.api.Test; diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java index 8eaa75c..943b1aa 100644 --- a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java +++ b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java @@ -5,9 +5,6 @@ import io.ebean.TxScope; import io.ebean.migration.JdbcMigration; import io.ebean.migration.MigrationContext; -import io.ebeaninternal.api.ScopeTrans; -import io.ebeaninternal.api.ScopedTransaction; -import io.ebeaninternal.api.SpiTransaction; import io.ebeaninternal.server.core.DefaultServer; import io.ebeaninternal.server.transaction.ExternalJdbcTransaction; import io.ebeaninternal.server.transaction.TransactionManager; diff --git a/ebean-migration/pom.xml b/ebean-migration/pom.xml index 266aa0e..98636d5 100644 --- a/ebean-migration/pom.xml +++ b/ebean-migration/pom.xml @@ -39,7 +39,7 @@ io.ebean ebean-api 13.25.0 - provided + true @@ -164,4 +164,5 @@ mvn install:install-file -Dfile=/some/path/to/ojdbc7.jar -DgroupId=oracle \ + diff --git a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java index 6219412..99bf021 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java +++ b/ebean-migration/src/main/java/io/ebean/migration/JdbcMigration.java @@ -1,6 +1,7 @@ package io.ebean.migration; import java.sql.Connection; +import java.sql.SQLException; /** * Interface to be implemented by Jdbc Java Migrations. By default the migration @@ -31,7 +32,7 @@ public interface JdbcMigration extends MigrationChecksumProvider { * Note: This API has changed with ebean-migration 13.12, as the initialization has changed. * See https://github.com/ebean-orm/ebean-migration/issues/90 for migration advice. */ - void migrate(MigrationContext context); + void migrate(MigrationContext context) throws SQLException; @Override default int getChecksum() { diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java index bb7dd8f..b73a06e 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java @@ -37,6 +37,11 @@ public class MigrationConfig { private boolean setCurrentSchema = true; private boolean allowErrorInRepeatable; + /** + * Run migration automatically when ebean starts (Requires MigrationPlugin) + */ + private boolean autoRun; + /** * Holds a Collection/Iterable of JdbcMigrations. All migrations (JDBC and SQL) are * extecuted in the order defined by their version numbers. @@ -495,6 +500,20 @@ public void setMinVersionFailMessage(String minVersionFailMessage) { this.minVersionFailMessage = minVersionFailMessage; } + /** + * Sets, if migration should automatically run when ebean starts. + */ + public void setAutoRun(boolean autoRun) { + this.autoRun = autoRun; + } + + /** + * run migration on ebean start + */ + public boolean isAutoRun() { + return autoRun; + } + /** * Load configuration from standard properties. */ @@ -521,6 +540,7 @@ public void load(Properties props) { runPlaceholders = property("placeholders", runPlaceholders); minVersion = property("minVersion", minVersion); minVersionFailMessage = property("minVersionFailMessage", minVersionFailMessage); + autoRun = property("autoRun", autoRun); String jdbcMigrations = property("jdbcMigrations"); if (jdbcMigrations != null) { diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java index a640021..f082fe4 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java @@ -27,16 +27,14 @@ final class LocalMigrationResources { private final MigrationConfig migrationConfig; private final ClassLoader classLoader; private final Iterable jdbcMigrations; - private final MigrationContext context; /** * Construct with configuration options. */ - LocalMigrationResources(MigrationConfig migrationConfig, MigrationContext context) { + LocalMigrationResources(MigrationConfig migrationConfig) { this.migrationConfig = migrationConfig; this.classLoader = migrationConfig.getClassLoader(); this.jdbcMigrations = migrationConfig.getJdbcMigrations(); - this.context = context; } /** @@ -51,7 +49,7 @@ boolean readInitResources() { /** * Read all the migration resources (SQL scripts and JDBC migrations) returning true if there are versions. */ - boolean readResources() { + boolean readResources(MigrationContext context) { if (readFromIndex()) { // automatically enable earlyChecksumMode when using index file with pre-computed checksums migrationConfig.setEarlyChecksumMode(true); @@ -60,7 +58,7 @@ boolean readResources() { } // after we read the SQL migrations from index or classpath scan, we // read jdbcMigrations and sort them. - readJdbcMigrations(); + readJdbcMigrations(context); Collections.sort(versions); return !versions.isEmpty(); } @@ -92,7 +90,7 @@ private boolean readFromIndex() { return false; } - private void readJdbcMigrations() { + private void readJdbcMigrations(MigrationContext context) { if (jdbcMigrations != null) { for (JdbcMigration jdbcMigration : jdbcMigrations) { if (jdbcMigration.matches(context)) { diff --git a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java index 8ea04a5..323e7de 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java +++ b/ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java @@ -53,8 +53,8 @@ public List run(Connection connection) { public List run(MigrationContext context) { long startMs = System.currentTimeMillis(); - LocalMigrationResources resources = new LocalMigrationResources(migrationConfig, context); - if (!resources.readResources() && !resources.readInitResources()) { + LocalMigrationResources resources = new LocalMigrationResources(migrationConfig); + if (!resources.readResources(context) && !resources.readInitResources()) { log.log(DEBUG, "no migrations to check"); return emptyList(); } diff --git a/ebean-migration/src/main/java/module-info.java b/ebean-migration/src/main/java/module-info.java index 2856c9d..e0f8e22 100644 --- a/ebean-migration/src/main/java/module-info.java +++ b/ebean-migration/src/main/java/module-info.java @@ -1,13 +1,11 @@ open module io.ebean.migration { exports io.ebean.migration; - exports io.ebean.migration.db; requires transitive java.sql; requires transitive io.avaje.applog; requires transitive io.avaje.classpath.scanner; requires transitive io.ebean.ddl.runner; - //requires transitive io.ebean.api; requires io.ebean.migration.auto; uses io.ebean.migration.JdbcMigration; diff --git a/pom.xml b/pom.xml index 2526367..22ef846 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,8 @@ ebean-migration-auto ebean-migration - ebean-migration-it + ebean-migration-db + From 40d6a734b719f1070c78cf4318f71dc97f7dd158 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Wed, 10 Apr 2024 17:30:35 +0200 Subject: [PATCH 15/18] FIX: Snapshot versions --- ebean-migration-db/pom.xml | 4 ++-- ebean-migration-it/pom.xml | 4 ++-- ebean-migration/pom.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ebean-migration-db/pom.xml b/ebean-migration-db/pom.xml index 2e57eb1..ebc061b 100644 --- a/ebean-migration-db/pom.xml +++ b/ebean-migration-db/pom.xml @@ -10,7 +10,7 @@ io.ebean ebean-migration-db - 13.11.2-SNAPSHOT + 14.0.1-SNAPSHOT scm:git:git@github.com:ebean-orm/ebean-migration.git @@ -27,7 +27,7 @@ io.ebean ebean-migration - 13.11.2-SNAPSHOT + 14.0.1-SNAPSHOT diff --git a/ebean-migration-it/pom.xml b/ebean-migration-it/pom.xml index 59a8592..55c3f25 100644 --- a/ebean-migration-it/pom.xml +++ b/ebean-migration-it/pom.xml @@ -11,7 +11,7 @@ io.ebean ebean-migration-it - 13.11.2-SNAPSHOT + 14.0.1-SNAPSHOT scm:git:git@github.com:ebean-orm/ebean-migration.git @@ -35,7 +35,7 @@ io.ebean ebean-migration - 13.11.2-SNAPSHOT + 14.0.1-SNAPSHOT - - - org.avaje.composite - logback - 1.1 - test - - - - - com.h2database - h2 - 2.2.220 - test - - - - io.avaje - junit - 1.3 - test - - - - - - - - io.repaint.maven - tiles-maven-plugin - 2.33 - true - - - io.ebean.tile:enhancement:13.25.0 - - - - - - diff --git a/ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF b/ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 8ad70ad..0000000 --- a/ebean-migration-it/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 -Automatic-Module-Name: io.ebean.migration diff --git a/ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner b/ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner deleted file mode 100644 index 449863e..0000000 --- a/ebean-migration-it/src/main/resources/META-INF/services/io.ebean.migration.auto.AutoMigrationRunner +++ /dev/null @@ -1 +0,0 @@ -io.ebean.migration.AutoRunner \ No newline at end of file diff --git a/ebean-migration-it/src/main/resources/ebean.mf b/ebean-migration-it/src/main/resources/ebean.mf deleted file mode 100644 index ff58400..0000000 --- a/ebean-migration-it/src/main/resources/ebean.mf +++ /dev/null @@ -1,3 +0,0 @@ -entity-packages: org.migration.model -entity-field-access: true -synthetic: false diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java deleted file mode 100644 index 0cf7781..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.ebean.migration.it; - -import io.ebean.DB; -import io.ebean.Database; -import io.ebean.DatabaseFactory; -import io.ebean.config.DatabaseConfig; -import io.ebean.migration.MigrationConfig; -import org.migration.model.M3; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Roland Praml, FOCONIS AG - */ -public class EbeanMigrationTest { - - @Test - public void testEbeanServerJdbcMig() { - - // NOTE: This can be done by AutoMigration (or MigrationPlugin) later - MigrationConfig config = new MigrationConfig(); - Database db = DB.getDefault(); - config.setName(db.name()); - config.load(db.pluginApi().config().getProperties()); - //new MigrationRunner(config).run(db); - - - M3 m3 = DB.find(M3.class).findOne(); - assertThat(m3.getId()).isEqualTo(1); - assertThat(m3.getAcol()).isEqualTo("Hello Migration"); - - } - - @Test - public void testWithRunner() { - - // NOTE: This can be done by AutoMigration (or MigrationPlugin) later - DatabaseConfig dbCfg = new DatabaseConfig(); - dbCfg.setName("h2"); - dbCfg.loadFromProperties(); - dbCfg.setRunMigration(true); - DatabaseFactory.create(dbCfg); - - M3 m3 = DB.find(M3.class).findOne(); - assertThat(m3.getId()).isEqualTo(1); - assertThat(m3.getAcol()).isEqualTo("text with ; sign"); - - } -} diff --git a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java b/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java deleted file mode 100644 index 943b1aa..0000000 --- a/ebean-migration-it/src/test/java/io/ebean/migration/it/V1_2_1__test.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.ebean.migration.it; - -import io.ebean.Database; -import io.ebean.Transaction; -import io.ebean.TxScope; -import io.ebean.migration.JdbcMigration; -import io.ebean.migration.MigrationContext; -import io.ebeaninternal.server.core.DefaultServer; -import io.ebeaninternal.server.transaction.ExternalJdbcTransaction; -import io.ebeaninternal.server.transaction.TransactionManager; -import jakarta.persistence.PersistenceException; -import org.migration.model.M3; - -import java.sql.Connection; - -/** - * Sample migration. - * - * @author Roland Praml, FOCONIS AG - */ -public class V1_2_1__test implements JdbcMigration { - - - @Override - public void migrate(MigrationContext context) { -// Database db = context.database(); -// try (Transaction txn = beginExternalTransaction(context.database(), context.connection())) { -// -// -// M3 m3 = db.find(M3.class).findOne(); -// m3.setAcol("Hello Migration"); -// db.save(m3); -// } - } - - private Transaction beginExternalTransaction(Database database, Connection connection) { - DefaultServer defaultServer = (DefaultServer) database; - TransactionManager transactionManager = (io.ebeaninternal.server.transaction.TransactionManager) defaultServer.transactionManager(); - ExternalJdbcTransaction txn = new ExternalJdbcTransaction(true, connection, transactionManager) { - @Override - public void end() throws PersistenceException { - transactionManager.externalRemoveTransaction(); - } - }; - return transactionManager.externalBeginTransaction(txn, TxScope.required()); - } - - @Override - public String toString() { - return "Dummy jdbc migration"; - } -} diff --git a/ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql b/ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql deleted file mode 100644 index c627009..0000000 --- a/ebean-migration-it/src/test/resources/dbmig/1.1__initial.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m1 (id integer, acol varchar(20)); --- Check with DB2: --- call sysproc.admin_cmd('reorg table m1'); -create table m2 (id integer, acol varchar(20), bcol timestamp); - diff --git a/ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql b/ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql deleted file mode 100644 index 3518305..0000000 --- a/ebean-migration-it/src/test/resources/dbmig/1.2__add_m3.sql +++ /dev/null @@ -1,5 +0,0 @@ -create table m3 (id integer, acol varchar(20), bcol timestamp); - -alter table m1 add column addcol varchar(10); - -insert into m3 (id, acol) VALUES (1, 'text with ; sign'); -- plus some comment diff --git a/ebean-migration-it/src/test/resources/dbmig/I__hello.sql b/ebean-migration-it/src/test/resources/dbmig/I__hello.sql deleted file mode 100644 index 63a4934..0000000 --- a/ebean-migration-it/src/test/resources/dbmig/I__hello.sql +++ /dev/null @@ -1 +0,0 @@ --- do nothing diff --git a/ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql b/ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql deleted file mode 100644 index 6a7c4df..0000000 --- a/ebean-migration-it/src/test/resources/dbmig/R__m2_view.sql +++ /dev/null @@ -1 +0,0 @@ -create or replace view m2_vw as select id, acol from m2; diff --git a/ebean-migration-it/src/test/resources/ebean.properties b/ebean-migration-it/src/test/resources/ebean.properties deleted file mode 100644 index 05828c0..0000000 --- a/ebean-migration-it/src/test/resources/ebean.properties +++ /dev/null @@ -1,12 +0,0 @@ -ebean.ddl.generate=false -ebean.ddl.run=false - -ebean.packages=io.ebean.migration.model - -datasource.default=h2 -datasource.h2.username=sa -datasource.h2.password= -datasource.h2.url=jdbc:h2:mem:testsMem;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE - -ebean.h2.migration.migrationPath=dbmig -ebean.h2.migration.jdbcMigrations=io.ebean.migration.it.V1_2_1__test diff --git a/ebean-migration-it/src/test/resources/logback-test.xml b/ebean-migration-it/src/test/resources/logback-test.xml deleted file mode 100644 index a227835..0000000 --- a/ebean-migration-it/src/test/resources/logback-test.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - TRACE - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 22ef846..400119b 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,6 @@ ebean-migration-auto ebean-migration ebean-migration-db - From 4391093f2853782b7a353aeda57743e3389405fd Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 11 Apr 2024 16:06:25 +0200 Subject: [PATCH 18/18] Some comments and documentation --- README.md | 26 ++++ .../ebean/migration/db/MigrationPlugin.java | 8 +- .../migration/it/EbeanMigrationTest.java | 2 +- ebean-migration/pom.xml | 8 -- .../migration/AbstractMigrationRunner.java | 112 ------------------ .../io/ebean/migration/MigrationConfig.java | 15 ++- 6 files changed, 37 insertions(+), 134 deletions(-) delete mode 100644 ebean-migration/src/main/java/io/ebean/migration/AbstractMigrationRunner.java diff --git a/README.md b/README.md index c8cb636..7b8387a 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,32 @@ Then create a run a MigrationRunner. When running the database connection can ei runner.run(); ``` + +### Run from ebean with JDBC migrations + +Migration supports two modes how to run automatically on ebean server start: + +- Run as AutoRunner (controlled by `ebean.migration.run = true`) +- Run as Ebean plugin (controlled by `ebean.migration.plugin.run = true`) + +To run as plugin, you need the additional dependency to `ebean-migration-db`. + +In the AutoRunner mode, you only have a `MigrationContext` that provides access to the current connection. +When the plugin is used, you have a `MigrationContextDb` in your JDBC migrations and you can access the current transaction +and the ebean server. This is useful to make queries with the ebean server: +```java + public void migrate(MigrationContext context) throws SQLException { + Database db = ((MigrationContextDb) context).database(); + db.findDto(...) + } +``` + + +**Important**: +- do not use `DB.getDefault()` at this stage +- do not create new transactions (or committing existing one) +- be aware that the DB layout may not match to your entities (use `db.findDto` instead of `db.find`) + ## Notes: MigrationConfig migrationPath is the root path (classpath or filesystem) where the migration scripts are searched for. diff --git a/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java index a1979b6..63f817e 100644 --- a/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java +++ b/ebean-migration-db/src/main/java/io/ebean/migration/db/MigrationPlugin.java @@ -1,7 +1,5 @@ package io.ebean.migration.db; -import io.ebean.DB; -import io.ebean.Database; import io.ebean.migration.MigrationConfig; import io.ebean.plugin.Plugin; import io.ebean.plugin.SpiServer; @@ -18,14 +16,14 @@ public void configure(SpiServer server) { config.setName(server.name()); config.load(server.config().getProperties()); this.server = server; - if (server.config().isRunMigration() && config.isAutoRun()) { - throw new UnsupportedOperationException("You cannot enable both"); // TODO + if (server.config().isRunMigration() && config.isPluginRun()) { + throw new UnsupportedOperationException("You cannot enable both 'migration.run' and 'migration.plugin.run'"); } } @Override public void online(boolean online) { - if (online && config.isAutoRun()) { + if (online && config.isPluginRun()) { new MigrationRunnerDb(config, server).run(); } } diff --git a/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java b/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java index 7ec0fea..2bd719f 100644 --- a/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java +++ b/ebean-migration-db/src/test/java/io/ebean/migration/it/EbeanMigrationTest.java @@ -62,7 +62,7 @@ public void testWithPlugin() { DatabaseConfig dbCfg = new DatabaseConfig(); dbCfg.setName("h2"); dbCfg.loadFromProperties(); - dbCfg.getProperties().setProperty("ebean.h2.migration.autoRun", "true"); + dbCfg.getProperties().setProperty("ebean.h2.migration.plugin.run", "true"); dbCfg.setDefaultServer(true); Database db = DatabaseFactory.create(dbCfg); try { diff --git a/ebean-migration/pom.xml b/ebean-migration/pom.xml index 60937a7..9ca2ec5 100644 --- a/ebean-migration/pom.xml +++ b/ebean-migration/pom.xml @@ -35,13 +35,6 @@ 2.3 - - io.ebean - ebean-api - 14.1.0 - true - - io.ebean ebean-migration-auto @@ -164,5 +157,4 @@ mvn install:install-file -Dfile=/some/path/to/ojdbc7.jar -DgroupId=oracle \ - diff --git a/ebean-migration/src/main/java/io/ebean/migration/AbstractMigrationRunner.java b/ebean-migration/src/main/java/io/ebean/migration/AbstractMigrationRunner.java deleted file mode 100644 index 70dc51c..0000000 --- a/ebean-migration/src/main/java/io/ebean/migration/AbstractMigrationRunner.java +++ /dev/null @@ -1,112 +0,0 @@ -package io.ebean.migration; - -import io.avaje.applog.AppLog; -import io.ebean.migration.MigrationConfig; -import io.ebean.migration.MigrationContext; -import io.ebean.migration.MigrationResource; -import io.ebean.migration.runner.MigrationEngine; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.List; - -import static java.lang.System.Logger.Level.DEBUG; - -/** - * Runs the DB migration typically on application start. - */ -public class AbstractMigrationRunner { - - static final System.Logger log = AppLog.getLogger("io.ebean.migration"); - - protected final MigrationConfig migrationConfig; - - public AbstractMigrationRunner(MigrationConfig migrationConfig) { - this.migrationConfig = migrationConfig; - } - - /** - * Return the migrations that would be applied if the migration is run. - */ - public List checkState() { - return checkState(migrationConfig.createConnection()); - } - - /** - * Return the migrations that would be applied if the migration is run. - */ - public List checkState(DataSource dataSource) { - return checkState(connection(dataSource)); - } - - /** - * Return the migrations that would be applied if the migration is run. - */ - public List checkState(Connection connection) { - return run(connection, true); - } - - /** - * Return the migrations that would be applied if the migration is run. - */ - public List checkState(MigrationContext context) { - return run(context, true); - } - - /** - * Run by creating a DB connection from driver, url, username defined in MigrationConfig. - */ - public void run() { - run(migrationConfig.createConnection()); - } - - /** - * Run using the connection from the DataSource. - */ - public void run(DataSource dataSource) { - run(connection(dataSource)); - } - - /** - * Run the migrations if there are any that need running. - */ - public void run(Connection connection) { - run(connection, false); - } - - /** - * Run the migrations if there are any that need running. - */ - public void run(MigrationContext context) { - run(context, false); - } - - private Connection connection(DataSource dataSource) { - String username = migrationConfig.getDbUsername(); - try { - if (username == null) { - return dataSource.getConnection(); - } - log.log(DEBUG, "using db user [{0}] to run migrations ...", username); - return dataSource.getConnection(username, migrationConfig.getDbPassword()); - } catch (SQLException e) { - String msgSuffix = (username == null) ? "" : " using user [" + username + "]"; - throw new IllegalArgumentException("Error trying to connect to database for DB Migration" + msgSuffix, e); - } - } - - /** - * Run the migrations if there are any that need running. - */ - private List run(Connection connection, boolean checkStateOnly) { - return new MigrationEngine(migrationConfig, checkStateOnly).run(connection); - } - - /** - * Run the migrations if there are any that need running. - */ - private List run(MigrationContext context, boolean checkStateOnly) { - return new MigrationEngine(migrationConfig, checkStateOnly).run(context); - } -} diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java index b73a06e..a091448 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java @@ -1,6 +1,5 @@ package io.ebean.migration; -import java.lang.reflect.Constructor; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -38,9 +37,9 @@ public class MigrationConfig { private boolean allowErrorInRepeatable; /** - * Run migration automatically when ebean starts (Requires MigrationPlugin) + * Run migration automatically when ebean starts (Requires MigrationPlugin from ebean-migration-db) */ - private boolean autoRun; + private boolean pluginRun; /** * Holds a Collection/Iterable of JdbcMigrations. All migrations (JDBC and SQL) are @@ -503,15 +502,15 @@ public void setMinVersionFailMessage(String minVersionFailMessage) { /** * Sets, if migration should automatically run when ebean starts. */ - public void setAutoRun(boolean autoRun) { - this.autoRun = autoRun; + public void setPluginRun(boolean pluginRun) { + this.pluginRun = pluginRun; } /** * run migration on ebean start */ - public boolean isAutoRun() { - return autoRun; + public boolean isPluginRun() { + return pluginRun; } /** @@ -540,7 +539,7 @@ public void load(Properties props) { runPlaceholders = property("placeholders", runPlaceholders); minVersion = property("minVersion", minVersion); minVersionFailMessage = property("minVersionFailMessage", minVersionFailMessage); - autoRun = property("autoRun", autoRun); + pluginRun = property("plugin.run", pluginRun); String jdbcMigrations = property("jdbcMigrations"); if (jdbcMigrations != null) {