mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0fa3f0cb1 | ||
|
|
41a31c1aa0 | ||
|
|
ab301f970c | ||
|
|
d1b7b082a2 | ||
|
|
5fb3a1e019 | ||
|
|
cb0dee998b | ||
|
|
53b606289d | ||
|
|
574d5e215b | ||
|
|
508f2129f5 | ||
|
|
cdfcbeec43 | ||
|
|
0e9782e6b3 | ||
|
|
927fa5f7d3 | ||
|
|
53a80c7dd1 | ||
|
|
89789f3347 | ||
|
|
9dc5ca602c | ||
|
|
95737cd3c5 | ||
|
|
0a49fc9b62 | ||
|
|
f8c80c7fd2 | ||
|
|
fc837b6472 | ||
|
|
cfaedcdbc5 | ||
|
|
111bac7514 | ||
|
|
1a2ca63d65 | ||
|
|
33031d1c69 | ||
|
|
49d9d88fbe | ||
|
|
756f867ed2 | ||
|
|
12108ada38 | ||
|
|
fb2fdc9b53 | ||
|
|
d570971fd1 | ||
|
|
a8434f22ff | ||
|
|
b0d3921264 | ||
|
|
4167dfc4af | ||
|
|
e49a0c9ffb | ||
|
|
dd6f223ae1 | ||
|
|
05aff53241 | ||
|
|
9a3362e842 |
@@ -11,7 +11,7 @@ Goto [https://ebean-orm.github.io/](http://ebean-orm.github.io/ "Ebean ORM's Web
|
||||
[Maven central - all related projects](http://search.maven.org/#search%7Cga%7C1%7Cebean "maven central all related projects")
|
||||
|
||||
## Current versions
|
||||
* [](https://maven-badges.herokuapp.com/maven-central/org.avaje.ebean/ebean) - ebean
|
||||
* [](https://maven-badges.herokuapp.com/maven-central/org.avaje.ebean/ebean-agent) - ebean-agent
|
||||
* [](https://maven-badges.herokuapp.com/maven-central/org.avaje.ebean/ebean-maven-plugin) - ebean-maven-plugin
|
||||
* [](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean) - ebean
|
||||
* [](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean-agent) - ebean-agent
|
||||
* [](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean-maven-plugin) - ebean-maven-plugin
|
||||
|
||||
|
||||
@@ -9,15 +9,20 @@
|
||||
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>11.15.3</version>
|
||||
<version>11.15.10</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ebean</name>
|
||||
<url>http://ebean-orm.github.io/</url>
|
||||
|
||||
<properties>
|
||||
<jackson-core.version>2.9.5</jackson-core.version>
|
||||
<snakeyaml.version>1.21</snakeyaml.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
|
||||
<tag>ebean-11.15.3</tag>
|
||||
<tag>ebean-11.15.10</tag>
|
||||
</scm>
|
||||
|
||||
<profiles>
|
||||
@@ -89,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.19</version>
|
||||
<version>${snakeyaml.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
@@ -130,7 +135,7 @@
|
||||
<dependency>
|
||||
<groupId>io.ebean</groupId>
|
||||
<artifactId>ebean-migration</artifactId>
|
||||
<version>11.5.1</version>
|
||||
<version>11.5.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -143,14 +148,14 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>${jackson-core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- provided scope for JsonNode support -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>${jackson-core.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -169,13 +174,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface Transaction extends AutoCloseable {
|
||||
* This returns the current transaction for the 'default server'. If you are using
|
||||
* multiple EbeanServer's then use {@link EbeanServer#currentTransaction()}.
|
||||
* </p>
|
||||
*
|
||||
* @see Ebean#currentTransaction()
|
||||
* @see EbeanServer#currentTransaction()
|
||||
*/
|
||||
@@ -136,6 +137,18 @@ public interface Transaction extends AutoCloseable {
|
||||
*/
|
||||
void rollback(Throwable e) throws PersistenceException;
|
||||
|
||||
/**
|
||||
* Set when we want nested transactions to use Savepoint's.
|
||||
* <p>
|
||||
* This means that for a nested transaction:
|
||||
* <ul>
|
||||
* <li>begin transaction maps to creating a savepoint</li>
|
||||
* <li>commit transaction maps to releasing a savepoint</li>
|
||||
* <li>rollback transaction maps to rollback a savepoint</li>
|
||||
* </ul>
|
||||
*/
|
||||
void setNestedUseSavepoint();
|
||||
|
||||
/**
|
||||
* Mark the transaction for rollback only.
|
||||
*/
|
||||
@@ -151,7 +164,6 @@ public interface Transaction extends AutoCloseable {
|
||||
*/
|
||||
void end();
|
||||
|
||||
|
||||
/**
|
||||
* Synonym for end() to support AutoClosable.
|
||||
*/
|
||||
@@ -227,7 +239,7 @@ public interface Transaction extends AutoCloseable {
|
||||
* Refer to {@link ServerConfig#setSkipCacheAfterWrite(boolean)} for configuring the default behavior
|
||||
* for using the L2 bean cache in transactions spanning multiple query/persist requests.
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* <pre>{@code
|
||||
*
|
||||
* // assume Customer has L2 bean caching enabled ...
|
||||
@@ -309,7 +321,7 @@ public interface Transaction extends AutoCloseable {
|
||||
* <p>
|
||||
* Example: batch processing executing every 3 rows
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* <pre>{@code
|
||||
*
|
||||
* String data = "This is a simple test of the batch processing"
|
||||
|
||||
@@ -2871,7 +2871,7 @@ public class ServerConfig {
|
||||
}
|
||||
|
||||
private NamingConvention createNamingConvention(PropertiesWrapper properties, NamingConvention namingConvention) {
|
||||
NamingConvention nc = properties.createInstance(NamingConvention.class, "namingconvention", null);
|
||||
NamingConvention nc = properties.createInstance(NamingConvention.class, "namingConvention", null);
|
||||
return (nc != null) ? nc : namingConvention;
|
||||
}
|
||||
|
||||
|
||||
@@ -319,4 +319,9 @@ public interface SpiTransaction extends Transaction {
|
||||
* Return the profile location for this transaction.
|
||||
*/
|
||||
ProfileLocation getProfileLocation();
|
||||
|
||||
/**
|
||||
* Return true when nested transactions should create Savepoints.
|
||||
*/
|
||||
boolean isNestedUseSavepoint();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.sql.SQLException;
|
||||
/**
|
||||
* Proxy for an underlying SpiTransaction (most of the API).
|
||||
*/
|
||||
abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
public abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
|
||||
protected SpiTransaction transaction;
|
||||
|
||||
@@ -50,6 +50,16 @@ abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
return transaction.isRollbackOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedUseSavepoint() {
|
||||
transaction.setNestedUseSavepoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNestedUseSavepoint() {
|
||||
return transaction.isNestedUseSavepoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long profileOffset() {
|
||||
return transaction.profileOffset();
|
||||
|
||||
@@ -18,7 +18,9 @@ public class DdlWrite {
|
||||
|
||||
private final DdlBuffer applyForeignKeys;
|
||||
|
||||
private final DdlBuffer applyHistory;
|
||||
private final DdlBuffer applyHistoryView;
|
||||
|
||||
private final DdlBuffer applyHistoryTrigger;
|
||||
|
||||
private final DdlBuffer dropAllForeignKeys;
|
||||
|
||||
@@ -39,7 +41,8 @@ public class DdlWrite {
|
||||
this.applyDropDependencies = new BaseDdlBuffer(configuration);
|
||||
this.apply = new BaseDdlBuffer(configuration);
|
||||
this.applyForeignKeys = new BaseDdlBuffer(configuration);
|
||||
this.applyHistory = new BaseDdlBuffer(configuration);
|
||||
this.applyHistoryView = new BaseDdlBuffer(configuration);
|
||||
this.applyHistoryTrigger = new BaseDdlBuffer(configuration);
|
||||
this.dropAllForeignKeys = new BaseDdlBuffer(configuration);
|
||||
this.dropAll = new BaseDdlBuffer(configuration);
|
||||
}
|
||||
@@ -61,7 +64,8 @@ public class DdlWrite {
|
||||
public boolean isApplyEmpty() {
|
||||
return apply.getBuffer().isEmpty()
|
||||
&& applyForeignKeys.getBuffer().isEmpty()
|
||||
&& applyHistory.getBuffer().isEmpty()
|
||||
&& applyHistoryView.getBuffer().isEmpty()
|
||||
&& applyHistoryTrigger.getBuffer().isEmpty()
|
||||
&& applyDropDependencies.getBuffer().isEmpty();
|
||||
}
|
||||
|
||||
@@ -90,10 +94,17 @@ public class DdlWrite {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the buffer that apply history DDL is written to.
|
||||
* Return the buffer that apply history-view DDL is written to.
|
||||
*/
|
||||
public DdlBuffer applyHistory() {
|
||||
return applyHistory;
|
||||
public DdlBuffer applyHistoryView() {
|
||||
return applyHistoryView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the buffer that apply history-trigger DDL is written to.
|
||||
*/
|
||||
public DdlBuffer applyHistoryTrigger() {
|
||||
return applyHistoryTrigger;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+47
-18
@@ -42,6 +42,12 @@ import java.util.Map;
|
||||
*/
|
||||
public class BaseTableDdl implements TableDdl {
|
||||
|
||||
enum HistorySupport {
|
||||
NONE,
|
||||
SQL2011,
|
||||
TRIGGER_BASED
|
||||
}
|
||||
|
||||
protected final DbConstraintNaming naming;
|
||||
|
||||
protected final NamingConvention namingConvention;
|
||||
@@ -78,22 +84,23 @@ public class BaseTableDdl implements TableDdl {
|
||||
|
||||
private boolean strictMode;
|
||||
|
||||
private final boolean sql2011History;
|
||||
private final HistorySupport historySupport;
|
||||
|
||||
/**
|
||||
* Helper class that is used to execute the migration ddl before and after the migration action.
|
||||
*/
|
||||
private class DdlMigrationHelp {
|
||||
private List<String> before;
|
||||
private List<String> after;
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
private String defaultValue;
|
||||
private final List<String> before;
|
||||
private final List<String> after;
|
||||
private final String tableName;
|
||||
private final String columnName;
|
||||
private final String defaultValue;
|
||||
private final boolean withHistory;
|
||||
|
||||
/**
|
||||
* Constructor for DdlMigrationHelp when adding a NEW column.
|
||||
*/
|
||||
DdlMigrationHelp(String tableName, Column column) {
|
||||
DdlMigrationHelp(String tableName, Column column, boolean withHistory) {
|
||||
this.tableName = tableName;
|
||||
this.columnName = column.getName();
|
||||
this.defaultValue = platformDdl.convertDefaultValue(column.getDefaultValue());
|
||||
@@ -105,6 +112,7 @@ public class BaseTableDdl implements TableDdl {
|
||||
|
||||
before = getScriptsForPlatform(column.getBefore(), platformDdl.getPlatform().getName());
|
||||
after = getScriptsForPlatform(column.getAfter(), platformDdl.getPlatform().getName());
|
||||
this.withHistory = withHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,6 +127,7 @@ public class BaseTableDdl implements TableDdl {
|
||||
|
||||
boolean alterNotNull = Boolean.TRUE.equals(alter.isNotnull());
|
||||
// here we add the platform's default update script
|
||||
withHistory = isTrue(alter.isWithHistory());
|
||||
if (alter.getBefore().isEmpty() && alterNotNull) {
|
||||
if (defaultValue == null) {
|
||||
handleStrictError(tableName, columnName);
|
||||
@@ -134,6 +143,10 @@ public class BaseTableDdl implements TableDdl {
|
||||
if (!before.isEmpty()) {
|
||||
buffer.end();
|
||||
}
|
||||
|
||||
if (!before.isEmpty() && withHistory) {
|
||||
buffer.append("-- NOTE: table has @History - special migration may be necessary").newLine();
|
||||
}
|
||||
for (String ddlScript : before) {
|
||||
buffer.append(translate(ddlScript, tableName, columnName, this.defaultValue));
|
||||
buffer.endOfStatement();
|
||||
@@ -141,6 +154,9 @@ public class BaseTableDdl implements TableDdl {
|
||||
}
|
||||
|
||||
void writeAfter(DdlBuffer buffer) throws IOException {
|
||||
if (!after.isEmpty() && withHistory) {
|
||||
buffer.append("-- NOTE: table has @History - special migration may be necessary").newLine();
|
||||
}
|
||||
// here we run post migration scripts
|
||||
for (String ddlScript : after) {
|
||||
buffer.append(translate(ddlScript, tableName, columnName, defaultValue));
|
||||
@@ -198,7 +214,11 @@ public class BaseTableDdl implements TableDdl {
|
||||
this.platformDdl.configure(serverConfig);
|
||||
this.strictMode = serverConfig.getMigrationConfig().isStrictMode();
|
||||
DbHistorySupport hist = platformDdl.getPlatform().getHistorySupport();
|
||||
this.sql2011History = hist != null && hist.isStandardsBased();
|
||||
if (hist == null) {
|
||||
this.historySupport = HistorySupport.NONE;
|
||||
} else {
|
||||
this.historySupport = hist.isStandardsBased() ? HistorySupport.SQL2011 : HistorySupport.TRIGGER_BASED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -700,8 +720,14 @@ public class BaseTableDdl implements TableDdl {
|
||||
*/
|
||||
@Override
|
||||
public void generateEpilog(DdlWrite write) throws IOException {
|
||||
for (HistoryTableUpdate update : this.regenerateHistoryTriggers.values()) {
|
||||
platformDdl.regenerateHistoryTriggers(write, update);
|
||||
if (!regenerateHistoryTriggers.isEmpty()) {
|
||||
platformDdl.lockTables(write.applyHistoryTrigger(), regenerateHistoryTriggers.keySet());
|
||||
|
||||
for (HistoryTableUpdate update : this.regenerateHistoryTriggers.values()) {
|
||||
platformDdl.regenerateHistoryTriggers(write, update);
|
||||
}
|
||||
|
||||
platformDdl.unlockTables(write.applyHistoryTrigger(), regenerateHistoryTriggers.keySet());
|
||||
}
|
||||
platformDdl.generateEpilog(write);
|
||||
}
|
||||
@@ -722,15 +748,15 @@ public class BaseTableDdl implements TableDdl {
|
||||
String tableName = addColumn.getTableName();
|
||||
List<Column> columns = addColumn.getColumn();
|
||||
for (Column column : columns) {
|
||||
alterTableAddColumn(writer.apply(), tableName, column, false);
|
||||
alterTableAddColumn(writer.apply(), tableName, column, false, isTrue(addColumn.isWithHistory()));
|
||||
}
|
||||
|
||||
if (isTrue(addColumn.isWithHistory()) && !sql2011History) {
|
||||
if (isTrue(addColumn.isWithHistory()) && historySupport == HistorySupport.TRIGGER_BASED) {
|
||||
// make same changes to the history table
|
||||
String historyTable = historyTable(tableName);
|
||||
for (Column column : columns) {
|
||||
regenerateHistoryTriggers(tableName, HistoryTableUpdate.Change.ADD, column.getName());
|
||||
alterTableAddColumn(writer.apply(), historyTable, column, true);
|
||||
alterTableAddColumn(writer.apply(), historyTable, column, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,7 +797,8 @@ public class BaseTableDdl implements TableDdl {
|
||||
String tableName = dropColumn.getTableName();
|
||||
|
||||
alterTableDropColumn(writer.apply(), tableName, dropColumn.getColumnName());
|
||||
if (isTrue(dropColumn.isWithHistory()) && !sql2011History) {
|
||||
|
||||
if (isTrue(dropColumn.isWithHistory()) && historySupport == HistorySupport.TRIGGER_BASED) {
|
||||
// also drop from the history table
|
||||
regenerateHistoryTriggers(tableName, HistoryTableUpdate.Change.DROP, dropColumn.getColumnName());
|
||||
alterTableDropColumn(writer.apply(), historyTable(tableName), dropColumn.getColumnName());
|
||||
@@ -872,8 +899,9 @@ public class BaseTableDdl implements TableDdl {
|
||||
if (hasValue(ddl)) {
|
||||
writer.apply().append(ddl).endOfStatement();
|
||||
|
||||
if (isTrue(alter.isWithHistory()) && alter.getType() != null && !sql2011History) {
|
||||
if (isTrue(alter.isWithHistory()) && alter.getType() != null && historySupport == historySupport.TRIGGER_BASED) {
|
||||
// mysql and sql server column type change allowing nulls in the history table column
|
||||
regenerateHistoryTriggers(alter.getTableName(), HistoryTableUpdate.Change.ALTER, alter.getColumnName());
|
||||
AlterColumn alterHistoryColumn = new AlterColumn();
|
||||
alterHistoryColumn.setTableName(historyTable(alter.getTableName()));
|
||||
alterHistoryColumn.setColumnName(alter.getColumnName());
|
||||
@@ -923,7 +951,8 @@ public class BaseTableDdl implements TableDdl {
|
||||
String ddl = platformDdl.alterColumnType(alter.getTableName(), alter.getColumnName(), alter.getType());
|
||||
if (hasValue(ddl)) {
|
||||
writer.apply().append(ddl).endOfStatement();
|
||||
if (isTrue(alter.isWithHistory()) && !sql2011History) {
|
||||
if (isTrue(alter.isWithHistory()) && historySupport == HistorySupport.TRIGGER_BASED) {
|
||||
regenerateHistoryTriggers(alter.getTableName(), HistoryTableUpdate.Change.ALTER, alter.getColumnName());
|
||||
// apply same type change to matching column in the history table
|
||||
ddl = platformDdl.alterColumnType(historyTable(alter.getTableName()), alter.getColumnName(), alter.getType());
|
||||
writer.apply().append(ddl).endOfStatement();
|
||||
@@ -979,8 +1008,8 @@ public class BaseTableDdl implements TableDdl {
|
||||
platformDdl.alterTableDropColumn(buffer, tableName, columnName);
|
||||
}
|
||||
|
||||
protected void alterTableAddColumn(DdlBuffer buffer, String tableName, Column column, boolean onHistoryTable) throws IOException {
|
||||
DdlMigrationHelp help = new DdlMigrationHelp(tableName, column);
|
||||
protected void alterTableAddColumn(DdlBuffer buffer, String tableName, Column column, boolean onHistoryTable, boolean withHistory) throws IOException {
|
||||
DdlMigrationHelp help = new DdlMigrationHelp(tableName, column, withHistory);
|
||||
if (!onHistoryTable) {
|
||||
help.writeBefore(buffer);
|
||||
}
|
||||
|
||||
+14
-14
@@ -69,7 +69,7 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl {
|
||||
*/
|
||||
protected void updateTriggers(DdlWrite writer, MTable table, HistoryTableUpdate update) throws IOException {
|
||||
|
||||
writer.applyHistory().append("-- changes: ").append(update.description()).newLine();
|
||||
writer.applyHistoryTrigger().append("-- changes: ").append(update.description()).newLine();
|
||||
|
||||
updateHistoryTriggers(createDbTriggerUpdate(writer, table));
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl {
|
||||
|
||||
String baseTableName = table.getName();
|
||||
|
||||
DdlBuffer apply = writer.applyHistory();
|
||||
DdlBuffer apply = writer.applyHistoryView();
|
||||
|
||||
addSysPeriodColumns(apply, baseTableName, whenCreatedColumn);
|
||||
createHistoryTable(apply, table);
|
||||
@@ -210,19 +210,19 @@ public abstract class DbTriggerBasedHistoryDdl implements PlatformHistoryDdl {
|
||||
.endOfStatement().end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or replace the with_history view with explicit columns.
|
||||
*/
|
||||
protected void createWithHistoryView(DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer apply = update.historyBuffer();
|
||||
apply.append("create or replace view ").append(update.getBaseTable()).append(viewSuffix).append(" as select ");
|
||||
appendColumnNames(apply, update.getColumns(), "");
|
||||
appendSysPeriodColumns(apply, ", ");
|
||||
apply.append(" from ").append(update.getBaseTable()).append(" union all select ");
|
||||
appendColumnNames(apply, update.getColumns(), "");
|
||||
appendSysPeriodColumns(apply, ", ");
|
||||
apply.append(" from ").append(update.getHistoryTable()).endOfStatement().end();
|
||||
/**
|
||||
* For postgres/h2/mysql we need to drop and recreate the view. Well, we could add columns to the end of the view
|
||||
* but otherwise we need to drop and create it.
|
||||
*/
|
||||
protected void recreateHistoryView(DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer buffer = update.dropDependencyBuffer();
|
||||
// we need to drop the view early/first before any changes to the tables etc
|
||||
buffer.append("drop view if exists ").append(update.getBaseTable()).append(viewSuffix).endOfStatement();
|
||||
|
||||
// recreate the view after all ddl modifications - the view requires ALL columns, also the historyExclude ones.
|
||||
createWithHistoryView(update.historyViewBuffer(), update.getBaseTable());
|
||||
}
|
||||
|
||||
protected void appendSysPeriodColumns(DdlBuffer apply, String prefix) throws IOException {
|
||||
|
||||
+10
-2
@@ -28,10 +28,18 @@ public class DbTriggerUpdate {
|
||||
/**
|
||||
* Return the appropriate buffer for the current mode.
|
||||
*/
|
||||
public DdlBuffer historyBuffer() {
|
||||
return writer.applyHistory();
|
||||
public DdlBuffer historyViewBuffer() {
|
||||
return writer.applyHistoryView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the appropriate buffer for the current mode.
|
||||
*/
|
||||
public DdlBuffer historyTriggerBuffer() {
|
||||
return writer.applyHistoryTrigger();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the appropriate drop dependency buffer for the current mode.
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ public class H2HistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
protected void createTriggers(DdlWrite writer, MTable table) throws IOException {
|
||||
|
||||
String baseTableName = table.getName();
|
||||
DdlBuffer apply = writer.applyHistory();
|
||||
DdlBuffer apply = writer.applyHistoryTrigger();
|
||||
|
||||
addCreateTrigger(apply, updateTriggerName(baseTableName), baseTableName);
|
||||
}
|
||||
@@ -35,7 +35,9 @@ public class H2HistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
@Override
|
||||
protected void updateHistoryTriggers(DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer buffer = update.historyBuffer();
|
||||
recreateHistoryView(update);
|
||||
|
||||
DdlBuffer buffer = update.historyTriggerBuffer();
|
||||
dropTriggers(buffer, update.getBaseTable());
|
||||
addCreateTrigger(buffer, updateTriggerName(update.getBaseTable()), update.getBaseTable());
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ public class HistoryTableUpdate {
|
||||
ADD,
|
||||
DROP,
|
||||
INCLUDE,
|
||||
EXCLUDE
|
||||
EXCLUDE,
|
||||
ALTER
|
||||
}
|
||||
|
||||
private static class Column {
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||
import io.ebeaninternal.dbmigration.migration.Column;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* MySql specific DDL.
|
||||
@@ -113,10 +114,39 @@ public class MySqlDdl extends PlatformDdl {
|
||||
}
|
||||
apply.append(String.format("alter table %s comment = '%s'", tableName, tableComment)).endOfStatement();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addColumnComment(DdlBuffer apply, String table, String column, String comment) throws IOException {
|
||||
// alter comment currently not supported as it requires to repeat whole column definition
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Locks all tables for triggers that have to be updated.
|
||||
*/
|
||||
@Override
|
||||
public void lockTables(DdlBuffer buffer, Collection<String> tables) throws IOException {
|
||||
if (!tables.isEmpty()) {
|
||||
buffer.append("lock tables ");
|
||||
int i = 0;
|
||||
for (String table : tables) {
|
||||
if (i > 0) {
|
||||
buffer.append(", ");
|
||||
}
|
||||
buffer.append(table).append(" write");
|
||||
i++;
|
||||
}
|
||||
buffer.endOfStatement();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks all tables for triggers that have to be updated.
|
||||
*/
|
||||
@Override
|
||||
public void unlockTables(DdlBuffer buffer, Collection<String> tables) throws IOException {
|
||||
buffer.append("unlock tables").endOfStatement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -34,19 +34,19 @@ public class MySqlHistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
@Override
|
||||
protected void updateHistoryTriggers(DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer buffer = update.historyBuffer();
|
||||
recreateHistoryView(update);
|
||||
|
||||
DdlBuffer buffer = update.historyTriggerBuffer();
|
||||
String baseTable = update.getBaseTable();
|
||||
|
||||
buffer.append("lock tables ").append(baseTable).append(" write").endOfStatement();
|
||||
dropTriggers(buffer, baseTable);
|
||||
addBeforeUpdate(updateTriggerName(baseTable), update);
|
||||
addBeforeDelete(deleteTriggerName(baseTable), update);
|
||||
buffer.append("unlock tables").endOfStatement();
|
||||
}
|
||||
|
||||
private void addBeforeUpdate(String triggerName, DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer apply = update.historyBuffer();
|
||||
DdlBuffer apply = update.historyTriggerBuffer();
|
||||
apply
|
||||
.append("delimiter $$").newLine()
|
||||
.append("create trigger ").append(triggerName).append(" before update on ").append(update.getBaseTable())
|
||||
@@ -59,7 +59,7 @@ public class MySqlHistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
|
||||
private void addBeforeDelete(String triggerName, DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer apply = update.historyBuffer();
|
||||
DdlBuffer apply = update.historyTriggerBuffer();
|
||||
apply
|
||||
.append("delimiter $$").newLine()
|
||||
.append("create trigger ").append(triggerName).append(" before delete on ").append(update.getBaseTable())
|
||||
|
||||
@@ -20,10 +20,12 @@ import io.ebeaninternal.dbmigration.migration.Column;
|
||||
import io.ebeaninternal.dbmigration.migration.DropHistoryTable;
|
||||
import io.ebeaninternal.dbmigration.migration.IdentityType;
|
||||
import io.ebeaninternal.dbmigration.model.MTable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -442,13 +444,16 @@ public class PlatformDdl {
|
||||
.append(" ").append(addColumn).append(" ").append(column.getName())
|
||||
.append(" ").append(convertedType);
|
||||
|
||||
if (!onHistoryTable) {
|
||||
|
||||
if (defaultValue != null) {
|
||||
// Add default value also to history table if it is not excluded
|
||||
if (defaultValue != null) {
|
||||
if (!onHistoryTable || !isTrue(column.isHistoryExclude())) {
|
||||
buffer.append(" default ");
|
||||
buffer.append(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (!onHistoryTable) {
|
||||
if (isTrue(column.isNotnull())) {
|
||||
buffer.append(" not null");
|
||||
}
|
||||
@@ -456,7 +461,8 @@ public class PlatformDdl {
|
||||
|
||||
// check constraints cannot be added in one statement for h2
|
||||
if (!StringHelper.isNull(column.getCheckConstraint())) {
|
||||
String ddl = alterTableAddCheckConstraint(tableName, column.getCheckConstraintName(), column.getCheckConstraint());
|
||||
String ddl = alterTableAddCheckConstraint(tableName, column.getCheckConstraintName(),
|
||||
column.getCheckConstraint());
|
||||
buffer.append(ddl).endOfStatement();
|
||||
}
|
||||
} else {
|
||||
@@ -641,4 +647,18 @@ public class PlatformDdl {
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mysql-specific: Locks all tables for triggers that have to be updated.
|
||||
*/
|
||||
public void lockTables(DdlBuffer buffer, Collection<String> tables) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mysql-specific: Unlocks all tables for triggers that have to be updated.
|
||||
*/
|
||||
public void unlockTables(DdlBuffer buffer, Collection<String> tables) throws IOException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-17
@@ -62,7 +62,7 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
String procedureName = procedureName(baseTableName);
|
||||
String triggerName = triggerName(baseTableName);
|
||||
|
||||
DdlBuffer apply = writer.applyHistory();
|
||||
DdlBuffer apply = writer.applyHistoryTrigger();
|
||||
apply
|
||||
.append("create trigger ").append(triggerName).newLine()
|
||||
.append(" before update or delete on ").append(baseTableName).newLine()
|
||||
@@ -107,7 +107,7 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
String historyTable = historyTableName(table.getName());
|
||||
|
||||
List<String> columnNames = columnNamesForApply(table);
|
||||
createOrReplaceFunction(writer.applyHistory(), procedureName, historyTable, columnNames);
|
||||
createOrReplaceFunction(writer.applyHistoryTrigger(), procedureName, historyTable, columnNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,21 +116,7 @@ public class PostgresHistoryDdl extends DbTriggerBasedHistoryDdl {
|
||||
String procedureName = procedureName(update.getBaseTable());
|
||||
|
||||
recreateHistoryView(update);
|
||||
createOrReplaceFunction(update.historyBuffer(), procedureName, update.getHistoryTable(), update.getColumns());
|
||||
}
|
||||
|
||||
/**
|
||||
* For postgres we need to drop and recreate the view. Well, we could add columns to the end of the view
|
||||
* but otherwise we need to drop and create it.
|
||||
*/
|
||||
private void recreateHistoryView(DbTriggerUpdate update) throws IOException {
|
||||
|
||||
DdlBuffer buffer = update.dropDependencyBuffer();
|
||||
// we need to drop the view early/first before any changes to the tables etc
|
||||
buffer.append("drop view if exists ").append(update.getBaseTable()).append(viewSuffix).endOfStatement();
|
||||
|
||||
// recreate the view with specific columns specified (the columns generally are not dropped until later)
|
||||
createWithHistoryView(update);
|
||||
createOrReplaceFunction(update.historyTriggerBuffer(), procedureName, update.getHistoryTable(), update.getColumns());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+23
-10
@@ -31,19 +31,24 @@ public class SqlServerHistoryDdl implements PlatformHistoryDdl {
|
||||
enableSystemVersioning(writer, baseTable);
|
||||
}
|
||||
|
||||
private void enableSystemVersioning(DdlWrite writer, String baseTable) throws IOException {
|
||||
DdlBuffer apply = writer.applyHistory();
|
||||
apply.append("alter table ").append(baseTable).newLine()
|
||||
.append(" add ").append(systemPeriodStart).append(" datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),").newLine()
|
||||
.append(" ").append(systemPeriodEnd).append(" datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',").newLine()
|
||||
.append("period for system_time (").append(systemPeriodStart).append(", ").append(systemPeriodEnd).append(")").endOfStatement();
|
||||
|
||||
private String getHistoryTable(String baseTable) {
|
||||
String historyTable = baseTable + "_history"; // history must contain schema, otherwise you'll get
|
||||
// Setting SYSTEM_VERSIONING to ON failed because history table 'xxx_history' is not specified in two-part name format.
|
||||
if (historyTable.indexOf('.') == -1) {
|
||||
historyTable = "dbo." +historyTable; // so add the default schema, if none was specified.
|
||||
}
|
||||
apply.append("alter table ").append(baseTable).append(" set (system_versioning = on (history_table=").append(historyTable).append("))").endOfStatement();
|
||||
return historyTable;
|
||||
}
|
||||
|
||||
private void enableSystemVersioning(DdlWrite writer, String baseTable) throws IOException {
|
||||
DdlBuffer apply = writer.applyHistoryView();
|
||||
apply.append("alter table ").append(baseTable).newLine()
|
||||
.append(" add ").append(systemPeriodStart).append(" datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),").newLine()
|
||||
.append(" ").append(systemPeriodEnd).append(" datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',").newLine()
|
||||
.append("period for system_time (").append(systemPeriodStart).append(", ").append(systemPeriodEnd).append(")").endOfStatement();
|
||||
|
||||
apply.append("alter table ").append(baseTable).append(" set (system_versioning = on (history_table=")
|
||||
.append(getHistoryTable(baseTable)).append("))").endOfStatement();
|
||||
|
||||
DdlBuffer drop = writer.dropAll();
|
||||
drop.append("IF OBJECT_ID('").append(baseTable).append("', 'U') IS NOT NULL alter table ").append(baseTable).append(" set (system_versioning = off)").endOfStatement();
|
||||
@@ -53,7 +58,7 @@ public class SqlServerHistoryDdl implements PlatformHistoryDdl {
|
||||
@Override
|
||||
public void dropHistoryTable(DdlWrite writer, DropHistoryTable dropHistoryTable) throws IOException {
|
||||
String baseTable = dropHistoryTable.getBaseTable();
|
||||
DdlBuffer apply = writer.applyHistory();
|
||||
DdlBuffer apply = writer.applyHistoryView();
|
||||
apply.append("-- dropping history support for ").append(baseTable).endOfStatement();
|
||||
// drop default constraints
|
||||
|
||||
@@ -76,7 +81,15 @@ public class SqlServerHistoryDdl implements PlatformHistoryDdl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTriggers(DdlWrite write, HistoryTableUpdate baseTable) throws IOException {
|
||||
public void updateTriggers(DdlWrite writer, HistoryTableUpdate baseTable) throws IOException {
|
||||
// SQL Server 2016 does not need triggers
|
||||
DdlBuffer apply = writer.applyHistoryView();
|
||||
String baseTableName = baseTable.getBaseTable();
|
||||
apply.append("-- alter table ").append(baseTableName).append(" set (system_versioning = off (history_table=")
|
||||
.append(getHistoryTable(baseTableName)).append("))").endOfStatement();
|
||||
apply.append("-- history migration goes here").newLine();
|
||||
apply.append("-- alter table ").append(baseTableName).append(" set (system_versioning = on (history_table=")
|
||||
.append(getHistoryTable(baseTableName)).append("))").endOfStatement();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,8 @@ public class CurrentModel {
|
||||
}
|
||||
ddl.append(write.apply().getBuffer());
|
||||
ddl.append(write.applyForeignKeys().getBuffer());
|
||||
ddl.append(write.applyHistory().getBuffer());
|
||||
ddl.append(write.applyHistoryView().getBuffer());
|
||||
ddl.append(write.applyHistoryTrigger().getBuffer());
|
||||
|
||||
return ddl.toString();
|
||||
}
|
||||
|
||||
@@ -527,5 +527,8 @@ public class MColumn {
|
||||
if (hasValue(alterColumn.getForeignKeyOnUpdate())) {
|
||||
fkeyOnUpdate = fkeyMode(alterColumn.getForeignKeyOnUpdate());
|
||||
}
|
||||
if (hasValue(alterColumn.isHistoryExclude())) {
|
||||
historyExclude = alterColumn.isHistoryExclude();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ public class MTable {
|
||||
DropColumn dropColumn = new DropColumn();
|
||||
dropColumn.setTableName(name);
|
||||
dropColumn.setColumnName(existingColumn.getName());
|
||||
if (withHistory && !existingColumn.isHistoryExclude()) {
|
||||
if (withHistory) {
|
||||
// These dropColumns should occur on the history
|
||||
// table as well as the base table
|
||||
dropColumn.setWithHistory(Boolean.TRUE);
|
||||
|
||||
@@ -97,7 +97,8 @@ public class PlatformDdlWriter {
|
||||
writer.append("-- apply changes\n");
|
||||
writer.append(write.apply().getBuffer());
|
||||
writer.append(write.applyForeignKeys().getBuffer());
|
||||
writer.append(write.applyHistory().getBuffer());
|
||||
writer.append(write.applyHistoryView().getBuffer());
|
||||
writer.append(write.applyHistoryTrigger().getBuffer());
|
||||
}
|
||||
|
||||
private void prependDropDependencies(Writer writer, DdlBuffer buffer) throws IOException {
|
||||
|
||||
@@ -15,6 +15,10 @@ public class CachedBeanDataToBean {
|
||||
EntityBeanIntercept ebi = bean._ebean_getIntercept();
|
||||
|
||||
BeanProperty idProperty = desc.getIdProperty();
|
||||
if (desc.getInheritInfo() != null) {
|
||||
desc = desc.getInheritInfo().readType(bean.getClass()).desc();
|
||||
}
|
||||
|
||||
if (idProperty != null) {
|
||||
// load the id property
|
||||
loadProperty(bean, cacheBeanData, ebi, idProperty, context);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package io.ebeaninternal.server.core;
|
||||
|
||||
import io.ebeaninternal.server.lib.ShutdownManager;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
/**
|
||||
* Listens for webserver server starting and stopping events.
|
||||
* <p>
|
||||
* Register this listener in the web.xml configuration file. This will listen
|
||||
* for startup and shutdown events.
|
||||
* </p>
|
||||
*/
|
||||
public class ServletContextListener implements javax.servlet.ServletContextListener {
|
||||
|
||||
/**
|
||||
* The servlet container is stopping.
|
||||
*/
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent event) {
|
||||
ShutdownManager.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing on startup.
|
||||
*/
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,6 +71,7 @@ import io.ebeaninternal.server.query.STreePropertyAssocMany;
|
||||
import io.ebeaninternal.server.query.STreePropertyAssocOne;
|
||||
import io.ebeaninternal.server.query.STreeType;
|
||||
import io.ebeaninternal.server.query.SqlBeanLoad;
|
||||
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
||||
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
import io.ebeaninternal.server.type.DataBind;
|
||||
@@ -1723,7 +1724,15 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* associated L2 bean caching.
|
||||
*/
|
||||
public boolean isDeleteByStatement() {
|
||||
return deleteRecurseSkippable && !isBeanCaching();
|
||||
return persistListener == null
|
||||
&& persistController == null
|
||||
&& deleteRecurseSkippable && !isBeanCaching();
|
||||
}
|
||||
|
||||
public boolean isDeleteByBulk() {
|
||||
return persistListener == null
|
||||
&& persistController == null
|
||||
&& propertiesManyToMany.length == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1870,6 +1879,9 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
* on first access (lazy load) or immediately (eager load)
|
||||
*/
|
||||
public EntityBean createEntityBean(boolean isNew) {
|
||||
if (prototypeEntityBean == null) {
|
||||
throw new UnsupportedOperationException("cannot create entity bean for abstract entity " + getName());
|
||||
}
|
||||
try {
|
||||
EntityBean bean = (EntityBean) prototypeEntityBean._ebean_newInstance();
|
||||
|
||||
@@ -1961,6 +1973,13 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
|
||||
public T createReference(Object id, PersistenceContext pc) {
|
||||
|
||||
try {
|
||||
if (inheritInfo != null && !inheritInfo.isConcrete()) {
|
||||
// we actually need to do a query because we don't know the type without the discriminator
|
||||
// value, just select the id property and discriminator column (auto added)
|
||||
DefaultOrmQuery<T> query = new DefaultOrmQuery<>(this, ebeanServer, ebeanServer.getExpressionFactory());
|
||||
return query.select(getIdProperty().getName()).setId(id).findOne();
|
||||
}
|
||||
|
||||
EntityBean eb = createEntityBean();
|
||||
id = convertSetId(id, eb);
|
||||
EntityBeanIntercept ebi = eb._ebean_getIntercept();
|
||||
|
||||
@@ -447,7 +447,21 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
void beanPutAll(Collection<EntityBean> beans) {
|
||||
if (desc.inheritInfo != null) {
|
||||
Class<?> aClass = theClassOf(beans);
|
||||
desc.descOf(aClass).cacheBeanPutAllDirect(beans);
|
||||
// check if all beans have the same class
|
||||
for (EntityBean bean : beans) {
|
||||
if (!bean.getClass().equals(aClass)) {
|
||||
aClass = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (aClass == null) {
|
||||
// there are different bean types in the collection, so we add one by one to the cache
|
||||
for (EntityBean bean : beans) {
|
||||
desc.descOf(bean.getClass()).cacheBeanPutDirect(bean);
|
||||
}
|
||||
} else {
|
||||
desc.descOf(aClass).cacheBeanPutAllDirect(beans);
|
||||
}
|
||||
} else {
|
||||
beanCachePutAllDirect(beans);
|
||||
}
|
||||
|
||||
@@ -310,6 +310,10 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
|
||||
String discProperty = prefix + "." + discriminatorColumn;
|
||||
selectChain.add(discProperty);
|
||||
}
|
||||
if (targetIdBinder == null) {
|
||||
throw new IllegalStateException("No Id binding property for " + getFullBeanName()
|
||||
+ ". Probably a missing @OneToOne mapping annotation on this relationship?");
|
||||
}
|
||||
targetIdBinder.buildRawSqlSelectChain(prefix, selectChain);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.ebeaninternal.server.deploy.id.IdBinder;
|
||||
import io.ebeaninternal.server.deploy.parse.DeployInheritInfo;
|
||||
import io.ebeaninternal.server.query.SqlTreeProperties;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -291,7 +292,7 @@ public class InheritInfo {
|
||||
* Return true if this is considered a concrete type in the inheritance hierarchy.
|
||||
*/
|
||||
public boolean isConcrete() {
|
||||
return discriminatorValue != null;
|
||||
return !Modifier.isAbstract(type.getModifiers());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,11 +123,14 @@ public class DeployInherit {
|
||||
info.setColumnDefn(da.columnDefinition());
|
||||
}
|
||||
|
||||
DiscriminatorValue dv = AnnotationUtil.findAnnotation(cls, DiscriminatorValue.class); // do not search recursive
|
||||
if (dv != null) {
|
||||
info.setDiscriminatorValue(dv.value());
|
||||
if (!info.isAbstract()) {
|
||||
DiscriminatorValue dv = AnnotationUtil.findAnnotation(cls, DiscriminatorValue.class); // do not search recursive
|
||||
if (dv != null) {
|
||||
info.setDiscriminatorValue(dv.value());
|
||||
} else {
|
||||
info.setDiscriminatorValue(cls.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.deploy.parse;
|
||||
|
||||
import io.ebeaninternal.server.deploy.InheritInfo;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
@@ -64,7 +65,7 @@ public class DeployInheritInfo {
|
||||
* Return true if this is abstract node.
|
||||
*/
|
||||
public boolean isAbstract() {
|
||||
return (discriminatorObjectValue == null);
|
||||
return Modifier.isAbstract(type.getModifiers());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +206,7 @@ public class DeployInheritInfo {
|
||||
}
|
||||
|
||||
private void appendDiscriminator(List<Object> list) {
|
||||
if (discriminatorObjectValue != null) {
|
||||
if (!isAbstract()) {
|
||||
list.add(discriminatorObjectValue);
|
||||
}
|
||||
for (DeployInheritInfo child : children) {
|
||||
|
||||
@@ -588,10 +588,18 @@ public final class DefaultPersister implements Persister {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteList(List<?> beanList, Transaction t, boolean softDelete) {
|
||||
private void deleteList(List<?> beanList, SpiTransaction t, boolean softDelete, boolean children) {
|
||||
if (children) {
|
||||
t.depth(-1);
|
||||
t.checkBatchEscalationOnCollection();
|
||||
}
|
||||
for (Object aBeanList : beanList) {
|
||||
deleteRecurse((EntityBean) aBeanList, t, softDelete);
|
||||
}
|
||||
if (children) {
|
||||
t.flushBatchOnCollection();
|
||||
t.depth(+1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,7 +683,7 @@ public final class DefaultPersister implements Persister {
|
||||
t.logSummary("-- DeleteById of " + descriptor.getName() + " ids[" + idList + "] requires fetch of foreign key values");
|
||||
}
|
||||
List<?> beanList = server.findList(q, t);
|
||||
deleteList(beanList, t, softDelete);
|
||||
deleteList(beanList, t, softDelete, false);
|
||||
return beanList.size();
|
||||
|
||||
} else {
|
||||
@@ -1012,7 +1020,7 @@ public final class DefaultPersister implements Persister {
|
||||
// cascade delete the beans in the collection
|
||||
BeanDescriptor<?> targetDesc = many.getTargetDescriptor();
|
||||
if (!softDelete || targetDesc.isSoftDelete()) {
|
||||
if (targetDesc.isDeleteRecurseSkippable() && !targetDesc.isBeanCaching()) {
|
||||
if (targetDesc.isDeleteByStatement()) {
|
||||
// Just delete all the children with one statement
|
||||
IntersectionRow intRow = many.buildManyDeleteChildren(parentBean, excludeDetailIds);
|
||||
SqlUpdate sqlDelete = intRow.createDelete(server, softDelete);
|
||||
@@ -1037,13 +1045,13 @@ public final class DefaultPersister implements Persister {
|
||||
*/
|
||||
private void deleteChildrenById(SpiTransaction t, BeanDescriptor<?> targetDesc, List<Object> childIds, boolean softDelete) {
|
||||
|
||||
if (targetDesc.propertiesManyToMany().length > 0) {
|
||||
if (!targetDesc.isDeleteByBulk()) {
|
||||
// convert into a list of reference objects and perform delete by object
|
||||
List<Object> refList = new ArrayList<>(childIds.size());
|
||||
for (Object id : childIds) {
|
||||
refList.add(targetDesc.createReference(id, null));
|
||||
}
|
||||
deleteList(refList, t, softDelete);
|
||||
deleteList(refList, t, softDelete, true);
|
||||
|
||||
} else {
|
||||
// perform delete by statement if possible
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.rawsql;
|
||||
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql.Sql;
|
||||
import io.ebeaninternal.server.querydefn.SimpleTextParser;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql.Sql;
|
||||
|
||||
/**
|
||||
* Parses sql-select queries to try and determine the location where WHERE and
|
||||
@@ -55,11 +55,7 @@ class DRawSqlParser {
|
||||
|
||||
private Sql parse() {
|
||||
|
||||
if (!hasPlaceHolders()) {
|
||||
// parse the sql for the keywords...
|
||||
// select, from, where, having, group by, order by
|
||||
parseSqlFindKeywords(true);
|
||||
}
|
||||
parseSqlFindKeywords(true);
|
||||
|
||||
whereExprPos = findWhereExprPosition();
|
||||
havingExprPos = findHavingExprPosition();
|
||||
|
||||
@@ -231,6 +231,16 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
public void markNotQueryOnly() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNestedUseSavepoint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedUseSavepoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
if (!isActive()) {
|
||||
|
||||
@@ -77,6 +77,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
|
||||
protected boolean rollbackOnly;
|
||||
|
||||
protected boolean nestedUseSavepoint;
|
||||
|
||||
/**
|
||||
* The underlying Connection.
|
||||
*/
|
||||
@@ -1117,6 +1119,16 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
this.rollbackOnly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNestedUseSavepoint() {
|
||||
return nestedUseSavepoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedUseSavepoint() {
|
||||
this.nestedUseSavepoint = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback the transaction.
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,16 @@ class NoTransaction implements SpiTransaction {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNestedUseSavepoint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedUseSavepoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
// always false
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.api.SpiTransactionProxy;
|
||||
import io.ebeaninternal.server.lib.util.Str;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Savepoint;
|
||||
|
||||
/**
|
||||
* A nested transaction that represents a Savepoint.
|
||||
*/
|
||||
class SavepointTransaction extends SpiTransactionProxy {
|
||||
|
||||
private static final int STATE_COMMITTED = 1;
|
||||
private static final int STATE_ROLLED_BACK = 2;
|
||||
|
||||
private final TransactionManager manager;
|
||||
private final Savepoint savepoint;
|
||||
private final Connection connection;
|
||||
private final String logPrefix;
|
||||
|
||||
private boolean rollbackOnly;
|
||||
private int state;
|
||||
|
||||
SavepointTransaction(SpiTransaction transaction, TransactionManager manager) throws SQLException {
|
||||
this.manager = manager;
|
||||
this.transaction = transaction;
|
||||
this.connection = transaction.getInternalConnection();
|
||||
this.savepoint = connection.setSavepoint();
|
||||
int savepointId = savepoint.getSavepointId();
|
||||
this.logPrefix = "txn[" + transaction.getId() + "-sp" + savepointId + "] ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogPrefix() {
|
||||
return logPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSql(String msg) {
|
||||
TransactionManager.SQL_LOGGER.debug(Str.add(logPrefix, msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSummary(String msg) {
|
||||
TransactionManager.SUM_LOGGER.debug(Str.add(logPrefix, msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRollbackOnly() {
|
||||
this.rollbackOnly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
if (rollbackOnly) {
|
||||
rollbackSavepoint(null);
|
||||
} else {
|
||||
commitSavepoint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback() throws PersistenceException {
|
||||
rollbackSavepoint(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(Throwable e) throws PersistenceException {
|
||||
rollbackSavepoint(e);
|
||||
}
|
||||
|
||||
private void commitSavepoint() {
|
||||
try {
|
||||
connection.releaseSavepoint(savepoint);
|
||||
state = STATE_COMMITTED;
|
||||
manager.notifyOfCommit(this);
|
||||
} catch (SQLException e) {
|
||||
throw new PersistenceException("Error trying to commit/release Savepoint", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void rollbackSavepoint(Throwable cause) throws PersistenceException {
|
||||
try {
|
||||
connection.rollback(savepoint);
|
||||
state = STATE_ROLLED_BACK;
|
||||
manager.notifyOfRollback(this, cause);
|
||||
} catch (SQLException e) {
|
||||
throw new PersistenceException("Error trying to rollback Savepoint", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
if (state == 0) {
|
||||
rollback();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
end();
|
||||
}
|
||||
}
|
||||
@@ -582,27 +582,42 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
|
||||
txScope = initTxScope(txScope);
|
||||
|
||||
boolean setToScope = false;
|
||||
ScopedTransaction txnContainer = getActiveScoped();
|
||||
|
||||
boolean setToScope;
|
||||
boolean nestedSavepoint;
|
||||
SpiTransaction transaction;
|
||||
if (txnContainer == null) {
|
||||
setToScope = true;
|
||||
txnContainer = createScopedTransaction();
|
||||
setToScope = true;
|
||||
transaction = null;
|
||||
nestedSavepoint = false;
|
||||
} else {
|
||||
setToScope = false;
|
||||
transaction = txnContainer.current();
|
||||
nestedSavepoint = transaction.isNestedUseSavepoint();
|
||||
}
|
||||
|
||||
SpiTransaction transaction = txnContainer.current();
|
||||
|
||||
TxType type = txScope.getType();
|
||||
boolean createTransaction = isCreateNewTransaction(transaction, type);
|
||||
if (createTransaction) {
|
||||
switch (type) {
|
||||
case SUPPORTS:
|
||||
case NOT_SUPPORTED:
|
||||
case NEVER:
|
||||
transaction = NoTransaction.INSTANCE;
|
||||
break;
|
||||
default:
|
||||
transaction = createTransaction(true, txScope.getIsolationLevel());
|
||||
initNewTransaction(transaction, txScope);
|
||||
|
||||
boolean createTransaction;
|
||||
if (nestedSavepoint && (type == TxType.REQUIRED || type == TxType.REQUIRES_NEW)) {
|
||||
createTransaction = true;
|
||||
transaction = createSavepoint(transaction, this);
|
||||
|
||||
} else {
|
||||
createTransaction = isCreateNewTransaction(transaction, type);
|
||||
if (createTransaction) {
|
||||
switch (type) {
|
||||
case SUPPORTS:
|
||||
case NOT_SUPPORTED:
|
||||
case NEVER:
|
||||
transaction = NoTransaction.INSTANCE;
|
||||
break;
|
||||
default:
|
||||
transaction = createTransaction(true, txScope.getIsolationLevel());
|
||||
initNewTransaction(transaction, txScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,6 +628,14 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
return txnContainer;
|
||||
}
|
||||
|
||||
private SpiTransaction createSavepoint(SpiTransaction transaction, TransactionManager manager) {
|
||||
try {
|
||||
return new SavepointTransaction(transaction, manager);
|
||||
} catch (SQLException e) {
|
||||
throw new PersistenceException("Error creating nested Savepoint Transaction", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initNewTransaction(SpiTransaction transaction, TxScope txScope) {
|
||||
|
||||
if (txScope.isSkipCache()) {
|
||||
|
||||
@@ -58,9 +58,9 @@ import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Currency;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -564,7 +564,7 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
|
||||
boolean integerType = true;
|
||||
|
||||
Map<String, String> nameValueMap = new HashMap<>();
|
||||
Map<String, String> nameValueMap = new LinkedHashMap<>();
|
||||
|
||||
Field[] fields = enumType.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
@@ -657,7 +657,7 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
*/
|
||||
private ScalarTypeEnum<?> createEnumScalarTypeDbValue(Class<? extends Enum<?>> enumType, Method method, boolean integerType) {
|
||||
|
||||
Map<String, String> nameValueMap = new HashMap<>();
|
||||
Map<String, String> nameValueMap = new LinkedHashMap<>();
|
||||
|
||||
Enum<?>[] enumConstants = enumType.getEnumConstants();
|
||||
for (Enum<?> enumConstant : enumConstants) {
|
||||
|
||||
@@ -65,6 +65,8 @@ public class ServerConfigTest {
|
||||
props.setProperty("notifyL2CacheInForeground", "true");
|
||||
props.setProperty("idType", "SEQUENCE");
|
||||
props.setProperty("mappingLocations", "classpath:/foo;bar");
|
||||
props.setProperty("namingConvention", "io.ebean.config.MatchingNamingConvention");
|
||||
|
||||
|
||||
serverConfig.loadFromProperties(props);
|
||||
|
||||
@@ -72,6 +74,7 @@ public class ServerConfigTest {
|
||||
assertTrue(serverConfig.isNotifyL2CacheInForeground());
|
||||
assertTrue(serverConfig.isDbOffline());
|
||||
assertTrue(serverConfig.isAutoReadOnlyDataSource());
|
||||
assertThat(serverConfig.getNamingConvention()).isInstanceOf(MatchingNamingConvention.class);
|
||||
|
||||
assertEquals(IdType.SEQUENCE, serverConfig.getIdType());
|
||||
assertEquals(PersistBatch.INSERT, serverConfig.getPersistBatch());
|
||||
|
||||
@@ -63,6 +63,10 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
"migtest_e_basic",
|
||||
"migtest_e_history",
|
||||
"migtest_e_history2",
|
||||
"migtest_e_history3",
|
||||
"migtest_e_history4",
|
||||
"migtest_e_history5",
|
||||
"migtest_e_history6",
|
||||
"migtest_e_ref",
|
||||
"migtest_e_softdelete",
|
||||
"migtest_e_user",
|
||||
@@ -98,6 +102,9 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
assertThat(server().execute(update)).isEqualTo(2);
|
||||
}
|
||||
|
||||
|
||||
createHistoryEntities();
|
||||
|
||||
// Run migration
|
||||
runScript(false, "1.1.sql");
|
||||
SqlQuery select = server().createSqlQuery("select * from migtest_e_basic order by id");
|
||||
@@ -154,6 +161,41 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
assertThat(row.keySet()).contains("old_boolean", "old_boolean2");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void createHistoryEntities() {
|
||||
SqlUpdate update = server().createSqlUpdate("insert into migtest_e_history (id, test_string) values (1, '42')");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
update = server().createSqlUpdate("update migtest_e_history set test_string = '45' where id = 1");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
|
||||
update = server().createSqlUpdate("insert into migtest_e_history2 (id, test_string, obsolete_string1, obsolete_string2) values (1, 'foo', 'bar', null)");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
update = server().createSqlUpdate("update migtest_e_history2 set test_string = 'baz' where id = 1");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
|
||||
update = server().createSqlUpdate("insert into migtest_e_history3 (id, test_string) values (1, '42')");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
update = server().createSqlUpdate("update migtest_e_history3 set test_string = '45' where id = 1");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
|
||||
update = server().createSqlUpdate("insert into migtest_e_history4 (id, test_number) values (1, 42)");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
update = server().createSqlUpdate("update migtest_e_history4 set test_number = 45 where id = 1");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
|
||||
update = server().createSqlUpdate("insert into migtest_e_history5 (id, test_number) values (1, 42)");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
update = server().createSqlUpdate("update migtest_e_history5 set test_number = 45 where id = 1");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
|
||||
update = server().createSqlUpdate("insert into migtest_e_history6 (id, test_number2) values (1, 7)");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
update = server().createSqlUpdate("update migtest_e_history6 set test_number2 = 45 where id = 1");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
}
|
||||
|
||||
private void cleanup(String ... tables) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String table : tables) {
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class BaseTableDdlTest {
|
||||
column.setName("col_name");
|
||||
column.setType("varchar(20)");
|
||||
|
||||
ddlGen.alterTableAddColumn(write.apply(), "mytable", column, false);
|
||||
ddlGen.alterTableAddColumn(write.apply(), "mytable", column, false, false);
|
||||
|
||||
String ddl = write.apply().getBuffer();
|
||||
assertThat(ddl).contains("alter table mytable add column col_name varchar2(20)");
|
||||
|
||||
+9
-2
@@ -34,8 +34,15 @@ public class H2HistoryDdlTest {
|
||||
h2Ddl.configure(ebeanServer.getServerConfig());
|
||||
h2Ddl.regenerateHistoryTriggers(write, update);
|
||||
|
||||
assertThat(write.applyHistory().isEmpty()).isFalse();
|
||||
assertThat(write.applyHistory().getBuffer()).contains("add one");
|
||||
assertThat(write.applyHistoryView().isEmpty()).isFalse();
|
||||
assertThat(write.applyHistoryTrigger().isEmpty()).isFalse();
|
||||
assertThat(write.applyHistoryView().getBuffer())
|
||||
.contains("create view")
|
||||
.doesNotContain("create trigger");
|
||||
assertThat(write.applyHistoryTrigger().getBuffer())
|
||||
.contains("add one")
|
||||
.contains("create trigger")
|
||||
.doesNotContain("create view");
|
||||
assertThat(write.dropAll().isEmpty()).isTrue();
|
||||
|
||||
}
|
||||
|
||||
@@ -57,4 +57,19 @@ public class TestRawSqlParsing extends BaseTestCase {
|
||||
|
||||
assertThat(list).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWhere() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
RawSql sql = RawSqlBuilder.parse("SELECT id, name FROM o_customer ${where}").create();
|
||||
|
||||
List<Customer> customers = Ebean.createQuery(Customer.class)
|
||||
.setRawSql(sql)
|
||||
.where().gt("id", 1)
|
||||
.findList();
|
||||
|
||||
assertThat(customers).isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,21 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history2")
|
||||
@History
|
||||
public class EHistory2 {
|
||||
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
|
||||
|
||||
String testString;
|
||||
|
||||
@HistoryExclude
|
||||
String obsoleteString1;
|
||||
|
||||
String obsoleteString2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history3")
|
||||
@History
|
||||
public class EHistory3 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String testString;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history4")
|
||||
@History
|
||||
public class EHistory4 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history5")
|
||||
@History
|
||||
public class EHistory5 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package misc.migration.v1_0;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history6")
|
||||
@History
|
||||
public class EHistory6 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber1;
|
||||
|
||||
@NotNull
|
||||
Integer testNumber2;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
@Entity
|
||||
@@ -20,7 +21,8 @@ public class EHistory2 {
|
||||
@NotNull
|
||||
@DbDefault("unknown")
|
||||
String testString;
|
||||
|
||||
|
||||
@HistoryExclude
|
||||
String testString2;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history3")
|
||||
@History
|
||||
public class EHistory3 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@HistoryExclude
|
||||
String testString;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history4")
|
||||
@History
|
||||
public class EHistory4 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Long testNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history5")
|
||||
@History
|
||||
public class EHistory5 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("false")
|
||||
Boolean testBoolean;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package misc.migration.v1_1;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history6")
|
||||
@History
|
||||
public class EHistory6 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("42")
|
||||
Integer testNumber1;
|
||||
|
||||
|
||||
Integer testNumber2;
|
||||
}
|
||||
@@ -6,15 +6,21 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.HistoryExclude;
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history2")
|
||||
@History
|
||||
public class EHistory2 {
|
||||
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
|
||||
|
||||
|
||||
String testString;
|
||||
|
||||
@HistoryExclude
|
||||
String obsoleteString1;
|
||||
|
||||
String obsoleteString2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history3")
|
||||
@History
|
||||
public class EHistory3 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String testString;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history4")
|
||||
@History
|
||||
public class EHistory4 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.History;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history5")
|
||||
@History
|
||||
public class EHistory5 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package misc.migration.v1_2;
|
||||
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.DbDefault;
|
||||
import io.ebean.annotation.History;
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "migtest_e_history6")
|
||||
@History
|
||||
public class EHistory6 {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Integer testNumber1;
|
||||
|
||||
@NotNull
|
||||
@DbDefault("7")
|
||||
Integer testNumber2;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.tests.cache;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.tests.model.basic.OCachedInhChildA;
|
||||
import org.tests.model.basic.OCachedInhRoot;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Test class testing deleting/invalidating of cached beans
|
||||
*/
|
||||
public class TestCacheManyToOne extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void crudInvoice() {
|
||||
|
||||
OCachedInhChildA bean = new OCachedInhChildA();
|
||||
bean.setName("Roland");
|
||||
bean.setChildAData("ChildData");
|
||||
Ebean.save(bean);
|
||||
|
||||
Ebean.find(OCachedInhRoot.class).select("id").where().idIn(bean.getId()).findEach(bean0 -> {
|
||||
assertNotNull(bean0);
|
||||
assertThat(bean0.getName()).isEqualTo("Roland");
|
||||
assertThat(((OCachedInhChildA)bean0).getChildAData()).isEqualTo("ChildData");
|
||||
});
|
||||
|
||||
Ebean.find(OCachedInhRoot.class).select("id").where().idIn(bean.getId()).findEach(bean1 -> {
|
||||
assertNotNull(bean1);
|
||||
assertThat(bean1.getName()).isEqualTo("Roland");
|
||||
// this will fail if the bean is loaded from cache and the wrong discriminator is used.
|
||||
assertThat(((OCachedInhChildA)bean1).getChildAData()).isEqualTo("ChildData");
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class DcDetail {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@ManyToOne
|
||||
DcMaster master;
|
||||
|
||||
String description;
|
||||
|
||||
long version;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DcMaster getMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public void setMaster(DcMaster master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import io.ebean.event.AbstractBeanPersistListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DcListener extends AbstractBeanPersistListener {
|
||||
|
||||
static List<Object> deleted = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return cls.equals(DcDetail.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleted(Object bean) {
|
||||
deleted.add(bean);
|
||||
}
|
||||
|
||||
static List<Object> deletedBeans() {
|
||||
List<Object> copy = new ArrayList<>(deleted);
|
||||
deleted.clear();
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Version;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class DcMaster {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToMany(mappedBy = "master", cascade = CascadeType.ALL)
|
||||
List<DcDetail> details;
|
||||
|
||||
@Version
|
||||
long version;
|
||||
|
||||
public DcMaster(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<DcDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<DcDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.tests.delete;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestDeleteCascadeWithListener extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
DcMaster m0 = new DcMaster("m0");
|
||||
m0.getDetails().add(new DcDetail());
|
||||
m0.getDetails().add(new DcDetail());
|
||||
m0.getDetails().add(new DcDetail());
|
||||
|
||||
Ebean.save(m0);
|
||||
|
||||
DcMaster found = Ebean.find(DcMaster.class, m0.getId());
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
Ebean.delete(found);
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(5);
|
||||
|
||||
assertThat(sql.get(0)).contains("select t0.id from dc_detail t0 where master_id=?");
|
||||
assertThat(sql.get(1)).contains("delete from dc_detail where id=?");
|
||||
assertThat(sql.get(3)).contains("delete from dc_detail where id=?");
|
||||
assertThat(sql.get(4)).contains("delete from dc_master where id=? and version=?");
|
||||
|
||||
awaitListenerPropagation();
|
||||
|
||||
List<Object> beans = DcListener.deletedBeans();
|
||||
assertThat(beans).hasSize(3);
|
||||
}
|
||||
|
||||
private void awaitListenerPropagation() {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.tests.inheritance.abstrakt;
|
||||
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "block")
|
||||
@Inheritance
|
||||
@DiscriminatorColumn(name = "case_type", discriminatorType = DiscriminatorType.INTEGER)
|
||||
public abstract class AbstractBaseBlock {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
long version;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.tests.inheritance.abstrakt;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue(value = "2")
|
||||
public class Block extends AbstractBaseBlock {
|
||||
|
||||
String notes;
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.tests.inheritance.abstrakt;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestInheritanceNum extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void basicIUD() {
|
||||
|
||||
Block block = new Block();
|
||||
block.setName("ibe");
|
||||
block.setNotes("try it");
|
||||
|
||||
Ebean.save(block);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package org.tests.inheritance.cache;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.tests.model.basic.cache.CInhOne;
|
||||
import org.tests.model.basic.cache.CInhRef;
|
||||
import org.tests.model.basic.cache.CInhRoot;
|
||||
import org.tests.model.basic.cache.CInhTwo;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
|
||||
public class TestInheritanceRefCache extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
CInhOne one = new CInhOne();
|
||||
one.setLicenseNumber("O12");
|
||||
one.setDriver("Jimmy");
|
||||
one.setNotes("Hello");
|
||||
|
||||
Ebean.save(one);
|
||||
|
||||
CInhRef ref = new CInhRef();
|
||||
ref.setRef(one);
|
||||
|
||||
Ebean.save(ref);
|
||||
|
||||
Integer id = ref.getId();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
CInhRef gotRef = Ebean.find(CInhRef.class).setId(id).findOne();
|
||||
|
||||
assertThat(gotRef).isInstanceOf(CInhRef.class);
|
||||
assertThat(gotRef.getRef()).isInstanceOf(CInhOne.class);
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("from cinh_ref").contains("left join cinh_root");
|
||||
|
||||
// fetch again - from cache (but fetch second bean from cache)
|
||||
LoggedSqlCollector.start();
|
||||
gotRef = Ebean.find(CInhRef.class).setId(id).findOne();
|
||||
|
||||
assertThat(gotRef).isInstanceOf(CInhRef.class);
|
||||
assertThat(gotRef.getRef()).isInstanceOf(CInhOne.class);
|
||||
sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("from cinh_root");
|
||||
|
||||
|
||||
// fetch again - both from cache
|
||||
LoggedSqlCollector.start();
|
||||
gotRef = Ebean.find(CInhRef.class).setId(id).findOne();
|
||||
|
||||
assertThat(gotRef).isInstanceOf(CInhRef.class);
|
||||
assertThat(gotRef.getRef()).isInstanceOf(CInhOne.class);
|
||||
sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMap() {
|
||||
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
|
||||
CInhOne one = new CInhOne();
|
||||
one.setLicenseNumber("O19");
|
||||
one.setDriver("Foo");
|
||||
one.setNotes("Hello");
|
||||
Ebean.save(one);
|
||||
|
||||
ids.add(one.getId());
|
||||
|
||||
CInhTwo two = new CInhTwo();
|
||||
two.setLicenseNumber("T23");
|
||||
two.setAction("Test");
|
||||
Ebean.save(two);
|
||||
|
||||
ids.add(two.getId());
|
||||
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
Ebean.find(CInhRoot.class).setUseQueryCache(true).where().idIn(ids).setMapKey("licenseNumber").findMap();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains("from cinh_root");
|
||||
|
||||
// try some cache finds
|
||||
Ebean.find(CInhRoot.class).setUseQueryCache(true).findList();
|
||||
Ebean.find(CInhRoot.class).setUseQueryCache(true).findList();
|
||||
Ebean.find(CInhRoot.class).setUseQueryCache(true).findList();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
Ebean.find(CInhRoot.class).setUseQueryCache(true).where().idIn(ids).setMapKey("licenseNumber").findMap();
|
||||
|
||||
sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
|
||||
/**
|
||||
* Child bean A
|
||||
*/
|
||||
@Entity
|
||||
@DiscriminatorValue("childA")
|
||||
public class OCachedInhChildA extends OCachedInhRoot {
|
||||
|
||||
String childAData;
|
||||
|
||||
/**
|
||||
* @return the childAData
|
||||
*/
|
||||
public String getChildAData() {
|
||||
return childAData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param childAData
|
||||
* the childAData to set
|
||||
*/
|
||||
public void setChildAData(String childAData) {
|
||||
this.childAData = childAData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
|
||||
/**
|
||||
* Child bean B
|
||||
*/
|
||||
@Entity
|
||||
@DiscriminatorValue("childB")
|
||||
public class OCachedInhChildB extends OCachedInhRoot {
|
||||
String childBData;
|
||||
|
||||
/**
|
||||
* @return the childBData
|
||||
*/
|
||||
public String getChildBData() {
|
||||
return childBData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param childBData
|
||||
* the childBData to set
|
||||
*/
|
||||
public void setChildBData(String childBData) {
|
||||
this.childBData = childBData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
/**
|
||||
* Cached entity for inheritance.
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "o_cached_inherit")
|
||||
@Inheritance
|
||||
@Cache
|
||||
public abstract class OCachedInhRoot {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.tests.model.basic.cache;
|
||||
|
||||
import org.tests.model.basic.BasicDomain;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
@Cache(enableQueryCache = true)
|
||||
public class CInhRef extends BasicDomain {
|
||||
private static final long serialVersionUID = -4673953370819311120L;
|
||||
|
||||
@ManyToOne(cascade = {})
|
||||
private CInhRoot ref;
|
||||
|
||||
public CInhRoot getRef() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
public void setRef(CInhRoot ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
|
||||
@Cache
|
||||
@Cache(enableQueryCache = true)
|
||||
@Entity
|
||||
@Inheritance
|
||||
@DiscriminatorColumn(length = 3)
|
||||
|
||||
@@ -5,11 +5,13 @@ import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.PersistenceContextScope;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebean.TxScope;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.EBasic;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestNestedSubTransaction extends BaseTestCase {
|
||||
|
||||
@@ -56,6 +58,156 @@ public class TestNestedSubTransaction extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void nestedUseSavepoint_doubleNested_rollbackCommit() {
|
||||
|
||||
EbeanServer server = server();
|
||||
|
||||
EBasic bean = new EBasic("start2");
|
||||
|
||||
try (Transaction txn0 = server.beginTransaction()) {
|
||||
txn0.setRollbackOnly();
|
||||
txn0.setNestedUseSavepoint();
|
||||
|
||||
server.save(bean);
|
||||
|
||||
try (Transaction txn1 = server.beginTransaction()) {
|
||||
bean.setName("updateNested");
|
||||
server.save(bean);
|
||||
|
||||
try (Transaction txn2 = server.beginTransaction()) {
|
||||
bean.setName("barney");
|
||||
Ebean.save(bean);
|
||||
txn2.commit();
|
||||
}
|
||||
|
||||
txn1.rollback();
|
||||
}
|
||||
|
||||
EBasic fresh = server.find(EBasic.class)
|
||||
.setId(bean.getId())
|
||||
.setPersistenceContextScope(PersistenceContextScope.QUERY)
|
||||
.findOne();
|
||||
|
||||
assertNotNull(fresh);
|
||||
assertThat(fresh.getName()).isEqualTo("start2");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedUseSavepoint_doubleNested_commitRollback() {
|
||||
|
||||
EbeanServer server = server();
|
||||
|
||||
EBasic bean = new EBasic("start3");
|
||||
|
||||
try (Transaction txn0 = server.beginTransaction()) {
|
||||
txn0.setRollbackOnly();
|
||||
txn0.setNestedUseSavepoint();
|
||||
|
||||
server.save(bean);
|
||||
|
||||
try (Transaction txn1 = server.beginTransaction()) {
|
||||
bean.setName("updateNested3");
|
||||
server.save(bean);
|
||||
|
||||
try (Transaction txn2 = server.beginTransaction()) {
|
||||
bean.setName("barney3");
|
||||
Ebean.save(bean);
|
||||
txn2.rollback();
|
||||
}
|
||||
|
||||
txn1.commit();
|
||||
}
|
||||
|
||||
EBasic fresh = server.find(EBasic.class)
|
||||
.setId(bean.getId())
|
||||
.setPersistenceContextScope(PersistenceContextScope.QUERY)
|
||||
.findOne();
|
||||
|
||||
assertNotNull(fresh);
|
||||
assertThat(fresh.getName()).isEqualTo("updateNested3");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedUseSavepoint_nested_RequiresNew() {
|
||||
|
||||
EbeanServer server = server();
|
||||
|
||||
EBasic bean = new EBasic("start4");
|
||||
|
||||
try (Transaction txn0 = server.beginTransaction()) {
|
||||
txn0.setRollbackOnly();
|
||||
txn0.setNestedUseSavepoint();
|
||||
|
||||
server.save(bean);
|
||||
|
||||
try (Transaction txn1 = server.beginTransaction(TxScope.requiresNew())) {
|
||||
bean.setName("updateNested4");
|
||||
server.save(bean);
|
||||
txn1.commit();
|
||||
}
|
||||
|
||||
EBasic fresh = server.find(EBasic.class)
|
||||
.setId(bean.getId())
|
||||
.setPersistenceContextScope(PersistenceContextScope.QUERY)
|
||||
.findOne();
|
||||
|
||||
assertNotNull(fresh);
|
||||
assertThat(fresh.getName()).isEqualTo("updateNested4");
|
||||
}
|
||||
|
||||
EBasic after = server.find(EBasic.class)
|
||||
.setId(bean.getId())
|
||||
.findOne();
|
||||
|
||||
assertNull(after);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedUseSavepoint() {
|
||||
|
||||
EbeanServer server = server();
|
||||
|
||||
EBasic bean = new EBasic("start1");
|
||||
|
||||
try (Transaction txn0 = server.beginTransaction()) {
|
||||
txn0.setRollbackOnly();
|
||||
txn0.setNestedUseSavepoint();
|
||||
|
||||
server.save(bean);
|
||||
|
||||
try (Transaction txn1 = server.beginTransaction()) {
|
||||
bean.setName("updateNested");
|
||||
server.save(bean);
|
||||
txn1.commit();
|
||||
}
|
||||
|
||||
EBasic fresh = server.find(EBasic.class, bean.getId());
|
||||
assertNotNull(fresh);
|
||||
assertThat(fresh.getName()).isEqualTo("updateNested");
|
||||
|
||||
try (Transaction txn2 = server.beginTransaction()) {
|
||||
bean.setName("barney");
|
||||
Ebean.save(bean);
|
||||
txn2.rollback();
|
||||
}
|
||||
|
||||
fresh = server.find(EBasic.class)
|
||||
.setId(bean.getId())
|
||||
.setPersistenceContextScope(PersistenceContextScope.QUERY)
|
||||
.findOne();
|
||||
|
||||
assertNotNull(fresh);
|
||||
assertThat(fresh.getName()).isEqualTo("updateNested");
|
||||
|
||||
} finally {
|
||||
cleanup(bean);
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanup(EBasic bean) {
|
||||
Ebean.delete(EBasic.class, bean.getId());
|
||||
}
|
||||
|
||||
@@ -85,9 +85,36 @@ create table migtest_e_history (
|
||||
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,
|
||||
|
||||
@@ -65,14 +65,22 @@ 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_history add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 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;
|
||||
|
||||
@@ -6,5 +6,9 @@ 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 drop column obsolete_string2;
|
||||
|
||||
drop table migtest_e_ref;
|
||||
drop sequence migtest_e_ref_seq;
|
||||
|
||||
@@ -40,6 +40,17 @@ 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_history4 alter column test_number integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 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_mgtst__b_eu8csq on migtest_e_basic (indextest1);
|
||||
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
|
||||
drop index ix_mgtst__b_eu8css;
|
||||
|
||||
@@ -17,10 +17,10 @@ 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_history5 drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
|
||||
@@ -85,9 +85,36 @@ create table migtest_e_history (
|
||||
create table migtest_e_history2 (
|
||||
id integer auto_increment 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 auto_increment not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer auto_increment not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer auto_increment not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer auto_increment 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 auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
@@ -141,9 +168,56 @@ alter table migtest_e_history2 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history2_history(
|
||||
id integer,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history3 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history3_history(
|
||||
id integer,
|
||||
test_string varchar(255),
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history4 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history4_history(
|
||||
id integer,
|
||||
test_number integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history5 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history5_history(
|
||||
id integer,
|
||||
test_number integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history6 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history6_history(
|
||||
id integer,
|
||||
test_number1 integer,
|
||||
test_number2 integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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";
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
-- 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 auto_increment not null,
|
||||
@@ -65,14 +71,26 @@ 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_history add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown';
|
||||
|
||||
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;
|
||||
@@ -108,7 +126,24 @@ create table migtest_e_history_history(
|
||||
);
|
||||
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]
|
||||
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";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
-- 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;
|
||||
|
||||
@@ -6,5 +9,16 @@ 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";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
-- 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 auto_increment not null,
|
||||
@@ -40,6 +45,20 @@ 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;
|
||||
@@ -47,3 +66,18 @@ 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";
|
||||
|
||||
@@ -6,6 +6,8 @@ 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;
|
||||
@@ -30,6 +32,9 @@ 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_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;
|
||||
@@ -38,6 +43,13 @@ 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 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";
|
||||
|
||||
@@ -85,9 +85,36 @@ create table migtest_e_history (
|
||||
create table migtest_e_history2 (
|
||||
id integer generated by default as identity (start with 1) 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 (start with 1) 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 (start with 1) 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 (start with 1) 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 (start with 1) 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 (start with 1) not null,
|
||||
name varchar(127) not null,
|
||||
|
||||
@@ -65,14 +65,22 @@ 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_history add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
|
||||
alter table migtest_e_history4 alter column test_number bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
||||
alter table migtest_e_history6 alter column test_number2 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;
|
||||
|
||||
@@ -6,5 +6,9 @@ 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 drop column obsolete_string2;
|
||||
|
||||
drop table if exists migtest_e_ref;
|
||||
drop sequence if exists migtest_e_ref_seq;
|
||||
|
||||
@@ -40,6 +40,17 @@ 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_history4 alter column test_number integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 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;
|
||||
|
||||
@@ -17,10 +17,10 @@ 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_history5 drop column test_boolean;
|
||||
|
||||
alter table migtest_e_softdelete drop column deleted;
|
||||
|
||||
|
||||
@@ -64,6 +64,25 @@
|
||||
<createTable name="migtest_e_history2" withHistory="true" pkName="pk_migtest_e_history2">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="test_string" type="varchar"/>
|
||||
<column name="obsolete_string1" type="varchar" historyExclude="true"/>
|
||||
<column name="obsolete_string2" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_e_history3" withHistory="true" pkName="pk_migtest_e_history3">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="test_string" type="varchar"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_e_history4" withHistory="true" pkName="pk_migtest_e_history4">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="test_number" type="integer"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_e_history5" withHistory="true" pkName="pk_migtest_e_history5">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="test_number" type="integer"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_e_history6" withHistory="true" pkName="pk_migtest_e_history6">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="test_number1" type="integer"/>
|
||||
<column name="test_number2" type="integer" notnull="true"/>
|
||||
</createTable>
|
||||
<createTable name="migtest_e_ref" pkName="pk_migtest_e_ref">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
|
||||
@@ -44,9 +44,16 @@
|
||||
<addTableComment name="migtest_e_history" comment="We have history now"/>
|
||||
<alterColumn columnName="test_string" tableName="migtest_e_history2" withHistory="true" currentType="varchar" defaultValue="'unknown'" notnull="true" currentNotnull="false"/>
|
||||
<addColumn tableName="migtest_e_history2" withHistory="true">
|
||||
<column name="test_string2" type="varchar"/>
|
||||
<column name="test_string2" type="varchar" historyExclude="true"/>
|
||||
<column name="test_string3" type="varchar" defaultValue="'unknown'" notnull="true"/>
|
||||
</addColumn>
|
||||
<alterColumn columnName="test_string" tableName="migtest_e_history3" withHistory="true" historyExclude="true"/>
|
||||
<alterColumn columnName="test_number" tableName="migtest_e_history4" withHistory="true" type="bigint" currentType="integer" currentNotnull="false"/>
|
||||
<addColumn tableName="migtest_e_history5" withHistory="true">
|
||||
<column name="test_boolean" type="boolean" defaultValue="false" notnull="true"/>
|
||||
</addColumn>
|
||||
<alterColumn columnName="test_number1" tableName="migtest_e_history6" withHistory="true" currentType="integer" defaultValue="42" notnull="true" currentNotnull="false"/>
|
||||
<alterColumn columnName="test_number2" tableName="migtest_e_history6" withHistory="true" currentType="integer" notnull="false" currentNotnull="true"/>
|
||||
<addColumn tableName="migtest_e_softdelete">
|
||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||
</addColumn>
|
||||
@@ -77,6 +84,8 @@
|
||||
<dropColumn columnName="old_boolean" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="old_boolean2" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="eref_id" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="obsolete_string1" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="obsolete_string2" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropTable name="migtest_e_ref" sequenceCol="id"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@@ -5,6 +5,8 @@
|
||||
<dropColumn columnName="old_boolean" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="old_boolean2" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="eref_id" tableName="migtest_e_basic"/>
|
||||
<dropColumn columnName="obsolete_string1" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="obsolete_string2" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropTable name="migtest_e_ref" sequenceCol="id"/>
|
||||
</changeSet>
|
||||
</migration>
|
||||
@@ -25,6 +25,14 @@
|
||||
<alterColumn columnName="test_string" tableName="migtest_e_history" withHistory="true" comment="DROP COMMENT"/>
|
||||
<addTableComment name="migtest_e_history" comment="DROP COMMENT"/>
|
||||
<alterColumn columnName="test_string" tableName="migtest_e_history2" withHistory="true" currentType="varchar" defaultValue="DROP DEFAULT" notnull="false" currentNotnull="true"/>
|
||||
<addColumn tableName="migtest_e_history2" withHistory="true">
|
||||
<column name="obsolete_string1" type="varchar" historyExclude="true"/>
|
||||
<column name="obsolete_string2" type="varchar"/>
|
||||
</addColumn>
|
||||
<alterColumn columnName="test_string" tableName="migtest_e_history3" withHistory="true" historyExclude="false"/>
|
||||
<alterColumn columnName="test_number" tableName="migtest_e_history4" withHistory="true" type="integer" currentType="bigint" currentNotnull="false"/>
|
||||
<alterColumn columnName="test_number1" tableName="migtest_e_history6" withHistory="true" currentType="integer" defaultValue="DROP DEFAULT" notnull="false" currentNotnull="true"/>
|
||||
<alterColumn columnName="test_number2" tableName="migtest_e_history6" withHistory="true" currentType="integer" defaultValue="7" notnull="true" currentNotnull="false"/>
|
||||
<createTable name="migtest_e_ref" pkName="pk_migtest_e_ref">
|
||||
<column name="id" type="integer" primaryKey="true"/>
|
||||
<column name="name" type="varchar(127)" notnull="true"/>
|
||||
@@ -47,6 +55,7 @@
|
||||
<dropHistoryTable baseTable="migtest_e_history"/>
|
||||
<dropColumn columnName="test_string2" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="test_string3" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="test_boolean" tableName="migtest_e_history5" withHistory="true"/>
|
||||
<dropColumn columnName="deleted" tableName="migtest_e_softdelete"/>
|
||||
<dropColumn columnName="master_id" tableName="migtest_oto_child"/>
|
||||
<dropTable name="migtest_e_user" sequenceCol="id"/>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<dropHistoryTable baseTable="migtest_e_history"/>
|
||||
<dropColumn columnName="test_string2" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="test_string3" tableName="migtest_e_history2" withHistory="true"/>
|
||||
<dropColumn columnName="test_boolean" tableName="migtest_e_history5" withHistory="true"/>
|
||||
<dropColumn columnName="deleted" tableName="migtest_e_softdelete"/>
|
||||
<dropColumn columnName="master_id" tableName="migtest_oto_child"/>
|
||||
<dropTable name="migtest_e_user" sequenceCol="id"/>
|
||||
|
||||
@@ -85,9 +85,36 @@ create table migtest_e_history (
|
||||
create table migtest_e_history2 (
|
||||
id integer auto_increment 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 auto_increment not null,
|
||||
test_string varchar(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id integer auto_increment not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id integer auto_increment not null,
|
||||
test_number integer,
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id integer auto_increment 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 auto_increment not null,
|
||||
name varchar(127) not null,
|
||||
@@ -141,17 +168,96 @@ alter table migtest_e_history2 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history2_history(
|
||||
id integer,
|
||||
test_string varchar(255),
|
||||
obsolete_string1 varchar(255),
|
||||
obsolete_string2 varchar(255),
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history3 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history3_history(
|
||||
id integer,
|
||||
test_string varchar(255),
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history4 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history4_history(
|
||||
id integer,
|
||||
test_number integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history5 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history5_history(
|
||||
id integer,
|
||||
test_number integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
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 datetime(6) default now(6);
|
||||
alter table migtest_e_history6 add column sys_period_end datetime(6);
|
||||
create table migtest_e_history6_history(
|
||||
id integer,
|
||||
test_number1 integer,
|
||||
test_number2 integer,
|
||||
sys_period_start datetime(6),
|
||||
sys_period_end datetime(6)
|
||||
);
|
||||
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
|
||||
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin
|
||||
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin
|
||||
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
|
||||
end$$
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
-- 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 auto_increment not null,
|
||||
@@ -63,14 +69,26 @@ alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique
|
||||
alter table migtest_e_history modify test_string bigint;
|
||||
alter table migtest_e_history comment = '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 test_string set default 'unknown';
|
||||
alter table migtest_e_history2 modify test_string varchar(255) 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_history add column test_string2 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255);
|
||||
alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown';
|
||||
|
||||
alter table migtest_e_history4 modify test_number bigint;
|
||||
alter table migtest_e_history4_history modify test_number bigint;
|
||||
alter table migtest_e_history5 add column test_boolean tinyint(1) default 0 not null;
|
||||
alter table migtest_e_history5_history add column test_boolean tinyint(1) default 0;
|
||||
|
||||
|
||||
-- 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 test_number1 set default 42;
|
||||
alter table migtest_e_history6 modify test_number1 integer not null;
|
||||
alter table migtest_e_history6 modify test_number2 integer;
|
||||
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
@@ -106,6 +124,14 @@ create table migtest_e_history_history(
|
||||
);
|
||||
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;
|
||||
|
||||
delimiter $$
|
||||
create trigger migtest_e_history_history_upd before update on migtest_e_history for each row begin
|
||||
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
@@ -115,17 +141,53 @@ delimiter $$
|
||||
create trigger migtest_e_history_history_del before delete on migtest_e_history for each row begin
|
||||
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
end$$
|
||||
lock tables migtest_e_history2 write, migtest_e_history3 write, migtest_e_history4 write, migtest_e_history5 write;
|
||||
-- changes: [add test_string2, add test_string3]
|
||||
lock tables migtest_e_history2 write;
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string2, test_string3) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string2, OLD.test_string3);
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, obsolete_string1, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.obsolete_string1, OLD.obsolete_string2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string2, test_string3) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string2, OLD.test_string3);
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, obsolete_string1, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.obsolete_string1, OLD.obsolete_string2);
|
||||
end$$
|
||||
-- changes: [exclude test_string]
|
||||
drop trigger migtest_e_history3_history_upd;
|
||||
drop trigger migtest_e_history3_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
|
||||
end$$
|
||||
-- changes: [alter test_number]
|
||||
drop trigger migtest_e_history4_history_upd;
|
||||
drop trigger migtest_e_history4_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
-- changes: [add test_boolean]
|
||||
drop trigger migtest_e_history5_history_upd;
|
||||
drop trigger migtest_e_history5_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
|
||||
end$$
|
||||
unlock tables;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
-- 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;
|
||||
|
||||
@@ -6,4 +9,26 @@ 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;
|
||||
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
|
||||
|
||||
lock tables migtest_e_history2 write;
|
||||
-- changes: [drop obsolete_string1, drop obsolete_string2]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3);
|
||||
end$$
|
||||
unlock tables;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
-- 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 auto_increment not null,
|
||||
@@ -35,6 +40,19 @@ alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique
|
||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
|
||||
alter table migtest_e_history comment = '';
|
||||
alter table migtest_e_history2 alter test_string drop default;
|
||||
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 modify test_number integer;
|
||||
alter table migtest_e_history4_history modify test_number integer;
|
||||
alter table migtest_e_history6 alter test_number1 drop default;
|
||||
|
||||
-- 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 test_number2 set default 7;
|
||||
alter table migtest_e_history6 modify test_number2 integer 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 ix_migtest_e_basic_indextest3 on migtest_e_basic;
|
||||
@@ -42,3 +60,47 @@ drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
|
||||
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;
|
||||
|
||||
lock tables migtest_e_history2 write, migtest_e_history3 write, migtest_e_history4 write;
|
||||
-- changes: [add obsolete_string1, add obsolete_string2]
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2, test_string2, test_string3) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2, OLD.test_string2, OLD.test_string3);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2, test_string2, test_string3) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2, OLD.test_string2, OLD.test_string3);
|
||||
end$$
|
||||
-- changes: [include test_string]
|
||||
drop trigger migtest_e_history3_history_upd;
|
||||
drop trigger migtest_e_history3_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
|
||||
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
end$$
|
||||
-- changes: [alter test_number]
|
||||
drop trigger migtest_e_history4_history_upd;
|
||||
drop trigger migtest_e_history4_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
|
||||
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
unlock tables;
|
||||
|
||||
@@ -7,6 +7,8 @@ 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;
|
||||
@@ -31,6 +33,9 @@ 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_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;
|
||||
@@ -38,17 +43,33 @@ alter table migtest_oto_child drop column master_id;
|
||||
drop table if exists migtest_e_user;
|
||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
||||
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;
|
||||
|
||||
lock tables migtest_e_history2 write, migtest_e_history5 write;
|
||||
-- changes: [drop test_string2, drop test_string3]
|
||||
lock tables migtest_e_history2 write;
|
||||
drop trigger migtest_e_history2_history_upd;
|
||||
drop trigger migtest_e_history2_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
|
||||
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
|
||||
end$$
|
||||
-- changes: [drop test_boolean]
|
||||
drop trigger migtest_e_history5_history_upd;
|
||||
drop trigger migtest_e_history5_history_del;
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
set NEW.sys_period_start = now(6);
|
||||
end$$
|
||||
delimiter $$
|
||||
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
|
||||
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
|
||||
end$$
|
||||
unlock tables;
|
||||
|
||||
@@ -95,10 +95,41 @@ create sequence migtest_e_history_seq;
|
||||
create table migtest_e_history2 (
|
||||
id number(10) not null,
|
||||
test_string varchar2(255),
|
||||
obsolete_string1 varchar2(255),
|
||||
obsolete_string2 varchar2(255),
|
||||
constraint pk_migtest_e_history2 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history2_seq;
|
||||
|
||||
create table migtest_e_history3 (
|
||||
id number(10) not null,
|
||||
test_string varchar2(255),
|
||||
constraint pk_migtest_e_history3 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history3_seq;
|
||||
|
||||
create table migtest_e_history4 (
|
||||
id number(10) not null,
|
||||
test_number number(10),
|
||||
constraint pk_migtest_e_history4 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history4_seq;
|
||||
|
||||
create table migtest_e_history5 (
|
||||
id number(10) not null,
|
||||
test_number number(10),
|
||||
constraint pk_migtest_e_history5 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history5_seq;
|
||||
|
||||
create table migtest_e_history6 (
|
||||
id number(10) not null,
|
||||
test_number1 number(10),
|
||||
test_number2 number(10) not null,
|
||||
constraint pk_migtest_e_history6 primary key (id)
|
||||
);
|
||||
create sequence migtest_e_history6_seq;
|
||||
|
||||
create table migtest_e_ref (
|
||||
id number(10) not null,
|
||||
name varchar2(127) not null,
|
||||
|
||||
@@ -66,12 +66,22 @@ comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history modify test_string number(19);
|
||||
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 modify test_string default 'unknown';
|
||||
alter table migtest_e_history2 modify test_string not null;
|
||||
alter table migtest_e_history2 add column test_string2 varchar2(255);
|
||||
alter table migtest_e_history2 add column test_string3 varchar2(255) default 'unknown' not null;
|
||||
|
||||
alter table migtest_e_history4 modify test_number number(19);
|
||||
alter table migtest_e_history5 add column test_boolean number(1) default 0 not null;
|
||||
|
||||
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 modify test_number1 default 42;
|
||||
alter table migtest_e_history6 modify test_number1 not null;
|
||||
alter table migtest_e_history6 modify test_number2 null;
|
||||
alter table migtest_e_softdelete add column deleted number(1) default 0 not null;
|
||||
|
||||
alter table migtest_oto_child add column master_id number(19);
|
||||
|
||||
@@ -6,5 +6,9 @@ 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 drop column obsolete_string2;
|
||||
|
||||
drop table migtest_e_ref cascade constraints purge;
|
||||
drop sequence migtest_e_ref_seq;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user