mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#636 - ENH: Add DB Migration runner (as alternative to running via FlywayDB etc)
This commit is contained in:
1 parent
a7b239a1b7
commit
abaa1ff934
22 files changed
+716
-151
No files matched your search
@@ -20,8 +20,8 @@ import com.avaje.ebean.event.readaudit.ReadAuditLogger;
|
||||
import com.avaje.ebean.event.readaudit.ReadAuditPrepare;
|
||||
import com.avaje.ebean.meta.MetaInfoManager;
|
||||
import com.avaje.ebean.plugin.BeanType;
|
||||
import com.avaje.ebean.plugin.SpiServer;
|
||||
import com.avaje.ebean.plugin.Plugin;
|
||||
import com.avaje.ebean.plugin.SpiServer;
|
||||
import com.avaje.ebean.text.csv.CsvReader;
|
||||
import com.avaje.ebean.text.json.JsonContext;
|
||||
import com.avaje.ebeaninternal.api.LoadBeanRequest;
|
||||
@@ -73,6 +73,7 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.persistence.NonUniqueResultException;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -80,7 +81,6 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.FutureTask;
|
||||
@@ -308,6 +308,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return autoTuneService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource getDataSource() {
|
||||
return transactionManager.getDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadAuditPrepare getReadAuditPrepare() {
|
||||
return readAuditPrepare;
|
||||
@@ -341,8 +346,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
migrationConfig.generateOnStart(this);
|
||||
}
|
||||
|
||||
MigrationRunner migrationRunner = new MigrationRunner(this);
|
||||
migrationRunner.run();
|
||||
if (migrationConfig.isRunMigration()) {
|
||||
new MigrationRunner(this, migrationConfig).run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,6 @@ public final class EncodeUtil {
|
||||
/* no instances */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* URL-encodes the specified UTF-8 string.
|
||||
*/
|
||||
|
||||
@@ -7,9 +7,10 @@ import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* Created by rob on 5/02/16.
|
||||
* Utilities for IO.
|
||||
*/
|
||||
public class IOUtils {
|
||||
|
||||
/**
|
||||
* Reads the entire contents of the specified input stream and returns them
|
||||
* as a byte array.
|
||||
@@ -44,6 +45,9 @@ public class IOUtils {
|
||||
return EncodeUtil.decodeBytes(read(in), encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the entire contents from the reader returning as a String.
|
||||
*/
|
||||
public static String read(Reader reader) throws IOException {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -23,4 +23,15 @@ public class JdbcClose {
|
||||
logger.warn("Error closing connection", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback the connection logging if an error occurs.
|
||||
*/
|
||||
public static void rollback(Connection connection) {
|
||||
try {
|
||||
connection.rollback();
|
||||
} catch (SQLException e) {
|
||||
logger.warn("Error on connection rollback", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user