Fix dbmigration (#1277)

ENH: Support adding a '-- Generated by' comment to DDL including version and timestamp
This commit is contained in:
Roland Praml authored and Rob Bygrave committed 2018-02-26 12:37:54 +13:00
1 parent 0e219a9bc6
commit 91cb5a23fd
55 files changed
+184 -13

No files matched your search

@@ -63,7 +63,7 @@ public class ModelBuild_compoundKeyTest extends BaseTestCase {
String apply = Helper.asText(this, "/assert/ModelBuild_compoundKeyTest/apply.sql");
String createDdl = currentModel.getCreateDdl();
assertThat(createDdl).isEqualTo(apply);
assertThat(createDdl).startsWith("-- Generated by ebean").endsWith(apply);
}
@@ -81,6 +81,6 @@ public class ModelBuild_compoundKeyTest extends BaseTestCase {
String createDdl = currentModel.getCreateDdl();
String apply = Helper.asText(this, "/assert/ModelBuild_compoundKeyTest/apply.sql");
assertThat(createDdl).isEqualTo(apply);
assertThat(createDdl).startsWith("-- Generated by ebean").endsWith(apply);
}
}
@@ -45,7 +45,9 @@ public class ModelBuild_explicitSequencesTest extends BaseTestCase {
CurrentModel currentModel = new CurrentModel(ebeanServer);
String apply = currentModel.getCreateDdl();
assertThat(apply).isEqualTo(Helper.asText(this, "/assert/ModelBuild_explicitSequencesTest/apply.sql"));
assertThat(apply)
.startsWith("-- Generated by ebean")
.endsWith(Helper.asText(this, "/assert/ModelBuild_explicitSequencesTest/apply.sql"));
}
@@ -56,7 +58,9 @@ public class ModelBuild_explicitSequencesTest extends BaseTestCase {
CurrentModel currentModel = new CurrentModel(ebeanServer);
String apply = currentModel.getCreateDdl();
assertThat(apply).isEqualTo(Helper.asText(this, "/assert/ModelBuild_explicitSequencesTest/pg-apply.sql"));
assertThat(apply)
.startsWith("-- Generated by ebean")
.endsWith(Helper.asText(this, "/assert/ModelBuild_explicitSequencesTest/pg-apply.sql"));
}
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id integer generated by default as identity not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column new_string_field;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id integer auto_increment not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer auto_increment not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer auto_increment not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
drop trigger migtest_e_history_history_upd;
drop view migtest_e_history_with_history;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id integer generated by default as identity (start with 1) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer generated by default as identity (start with 1) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity (start with 1) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column new_string_field;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id integer auto_increment not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer auto_increment not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer auto_increment not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
drop trigger migtest_e_history_history_upd;
drop trigger migtest_e_history_history_del;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id number(10) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id number(10) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id number(10) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column new_string_field;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id serial not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
drop view if exists migtest_e_history2_with_history;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id serial not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
drop trigger if exists migtest_e_history_history_upd on migtest_e_history cascade;
drop function if exists migtest_e_history_history_version();
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id integer not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column new_string_field;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_basic (
id integer identity(1,1) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer identity(1,1) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
-- drop column migtest_e_basic.old_boolean;
IF (OBJECT_ID('uq_migtest_e_basic_old_boolean', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_old_boolean;
@@ -39,3 +40,4 @@ IF OBJECT_ID('fk_migtest_e_basic_eref_id', 'F') IS NOT NULL alter table migtest_
alter table migtest_e_basic drop column eref_id;
IF OBJECT_ID('migtest_e_ref', 'U') IS NOT NULL drop table migtest_e_ref;
IF OBJECT_ID('migtest_e_ref_seq', 'SO') IS NOT NULL drop sequence migtest_e_ref_seq;
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer identity(1,1) not null,
@@ -1,3 +1,4 @@
-- Migrationscripts for ebean unittest
-- apply changes
-- drop column migtest_e_basic.new_string_field;
IF (OBJECT_ID('uq_migtest_e_basic_new_string_field', 'UQ') IS NOT NULL) alter table migtest_e_basic drop constraint uq_migtest_e_basic_new_string_field;
@@ -104,6 +105,7 @@ IF OBJECT_ID('fk_migtest_e_softdelete_deleted', 'F') IS NOT NULL alter table mig
alter table migtest_e_softdelete drop column deleted;
IF OBJECT_ID('migtest_e_user', 'U') IS NOT NULL drop table migtest_e_user;
IF OBJECT_ID('migtest_e_user_seq', 'SO') IS NOT NULL drop sequence migtest_e_user_seq;
-- dropping history support for migtest_e_history;
delimiter $$
DECLARE @Tmp nvarchar(200);select @Tmp = t1.name from sys.default_constraints t1
+2
View File
@@ -18,6 +18,7 @@ ebean.encryptKeyManager=org.tests.basic.encrypt.BasicEncyptKeyManager
ebean.sqlserver.ddl.createOnly=true
ebean.ddl.generate=true
ebean.ddl.run=true
ebean.ddl.header=-- Generated by ebean ${version} at ${timestamp}
ebean.packages=org.tests
datasource.default=h2
@@ -152,6 +153,7 @@ datasource.migrationtest.databaseDriver=org.h2.Driver
ebean.migrationtest.applyPrefix=V
ebean.migrationtest.ddl.generate=false
ebean.migrationtest.ddl.run=false
ebean.migrationtest.ddl.header=-- Migrationscripts for ebean unittest
ebean.migrationtest.migration.appName=migrationtest
ebean.migrationtest.migration.migrationPath=dbmigration/migrationtest
ebean.migrationtest.migration.strict=true