mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
WIP: Db migration alterColumn ...
This commit is contained in:
@@ -9,6 +9,7 @@ import javax.sql.DataSource;
|
||||
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.*;
|
||||
import com.avaje.ebean.dbmigration.DbOffline;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -30,11 +31,17 @@ public class DatabasePlatformFactory {
|
||||
|
||||
try {
|
||||
|
||||
String offlinePlatform = DbOffline.getPlatform();
|
||||
if (offlinePlatform != null) {
|
||||
logger.info("offline platform [{}]", offlinePlatform);
|
||||
return byDatabaseName(offlinePlatform);
|
||||
}
|
||||
|
||||
if (serverConfig.getDatabasePlatformName() != null) {
|
||||
// choose based on dbName
|
||||
return byDatabaseName(serverConfig.getDatabasePlatformName());
|
||||
|
||||
}
|
||||
|
||||
if (serverConfig.getDataSourceConfig().isOffline()) {
|
||||
String m = "You must specify a DatabasePlatformName when you are offline";
|
||||
throw new PersistenceException(m);
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.avaje.ebean.config.PropertyMap;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.UnderscoreNamingConvention;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.dbmigration.DbOffline;
|
||||
import com.avaje.ebeaninternal.api.SpiBackgroundExecutor;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.cache.DefaultServerCacheFactory;
|
||||
@@ -113,9 +114,6 @@ public class DefaultContainer implements SpiContainer {
|
||||
serverConfig.getDatabasePlatform().setDbEncrypt(serverConfig.getDbEncrypt());
|
||||
}
|
||||
|
||||
DatabasePlatform dbPlatform = serverConfig.getDatabasePlatform();
|
||||
|
||||
|
||||
// inform the NamingConvention of the associated DatabasePlaform
|
||||
serverConfig.getNamingConvention().setDatabasePlatform(serverConfig.getDatabasePlatform());
|
||||
|
||||
@@ -169,6 +167,7 @@ public class DefaultContainer implements SpiContainer {
|
||||
|
||||
// start any services after registering with clusterManager
|
||||
server.start();
|
||||
DbOffline.reset();
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -284,6 +283,11 @@ public class DefaultContainer implements SpiContainer {
|
||||
|
||||
private DataSource getDataSourceFromConfig(ServerConfig config) {
|
||||
|
||||
if (DbOffline.isSet()) {
|
||||
logger.trace("... DbOffline using platform [{}]", DbOffline.getPlatform());
|
||||
return null;
|
||||
}
|
||||
|
||||
DataSource ds;
|
||||
|
||||
if (config.getDataSourceJndiName() != null) {
|
||||
@@ -324,6 +328,10 @@ public class DefaultContainer implements SpiContainer {
|
||||
*/
|
||||
private boolean checkDataSource(ServerConfig serverConfig) {
|
||||
|
||||
if (DbOffline.isSet()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (serverConfig.getDataSource() == null) {
|
||||
if (serverConfig.getDataSourceConfig().isOffline()) {
|
||||
// this is ok - offline DDL generation etc
|
||||
|
||||
@@ -185,7 +185,6 @@ public final class ConvertInetAddresses {
|
||||
boolean isIpv6 = false;
|
||||
|
||||
// handle IPv6 forms of IPv4 addresses
|
||||
// TODO: use Ascii.toUpperCase() when available
|
||||
if (ipString.toUpperCase(Locale.US).startsWith("::FFFF:")) {
|
||||
ipString = ipString.substring(7);
|
||||
} else if (ipString.startsWith("::")) {
|
||||
|
||||
Reference in New Issue
Block a user