mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 06:45:21 +00:00
reverted runDdl and runMigration method.
This commit is contained in:
1 parent
c1b928015b
commit
b7905eb0f6
6 files changed
+55
-77
No files matched your search
@@ -109,8 +109,12 @@ public final class DefaultContainer implements SpiContainer {
|
||||
InternalConfiguration c = new InternalConfiguration(online, clusterManager, executor, config, bootupClasses);
|
||||
DefaultServer server = new DefaultServer(c, c.cacheManager());
|
||||
// generate and run DDL if required plus other plugins
|
||||
|
||||
if (!DbOffline.isGenerateMigration()) {
|
||||
startServer(online, server);
|
||||
initServer(online, server);
|
||||
if (online && config.getTenantMode().isDdlEnabled() && !config.skipStart()) {
|
||||
server.start();
|
||||
}
|
||||
}
|
||||
DbOffline.reset();
|
||||
log.info("Started database[{}] platform[{}] in {}ms", config.getName(), config.getDatabasePlatform().getPlatform(), System.currentTimeMillis() - start);
|
||||
@@ -141,7 +145,7 @@ public final class DefaultContainer implements SpiContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private void startServer(boolean online, DefaultServer server) {
|
||||
private void initServer(boolean online, DefaultServer server) {
|
||||
server.executePlugins(online);
|
||||
// initialise prior to registering with clusterManager
|
||||
server.initialise();
|
||||
@@ -150,8 +154,6 @@ public final class DefaultContainer implements SpiContainer {
|
||||
clusterManager.registerServer(server);
|
||||
}
|
||||
}
|
||||
// start any services after registering with clusterManager
|
||||
server.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -357,54 +357,28 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
encryptKeyManager.initialise();
|
||||
}
|
||||
serverCacheManager.enabledRegions(config.getEnabledL2Regions());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start any services after registering with the ClusterManager.
|
||||
*/
|
||||
public void start() {
|
||||
|
||||
// check, if DB is available to run DDL and migration
|
||||
boolean dbAvailable = !config.isDocStoreOnly()
|
||||
&& !config.isDbOffline()
|
||||
&& config.getDataSource() != null
|
||||
&& config.getTenantMode().isDdlEnabled();
|
||||
|
||||
if (dbAvailable) {
|
||||
if (config.isDdlRun()) {
|
||||
runDdl();
|
||||
}
|
||||
if (config.isRunMigration()) {
|
||||
runMigration();
|
||||
}
|
||||
} else if (config.isDdlRun() || config.isRunMigration()) {
|
||||
log.warn("There was a request to run DDL or migration, but this is currently not possible, as the database is not available");
|
||||
}
|
||||
startQueryPlanCapture();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runDdl() {
|
||||
ddlGenerator.runDdl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runMigration() {
|
||||
final AutoMigrationRunner migrationRunner = ServiceUtil.service(AutoMigrationRunner.class);
|
||||
if (migrationRunner == null) {
|
||||
throw new IllegalStateException(
|
||||
"No AutoMigrationRunner found. Probably ebean-migration is not in the classpath?");
|
||||
public void start() {
|
||||
if (config.isRunMigration()) {
|
||||
final AutoMigrationRunner migrationRunner = ServiceUtil.service(AutoMigrationRunner.class);
|
||||
if (migrationRunner == null) {
|
||||
throw new IllegalStateException("No AutoMigrationRunner found. Probably ebean-migration is not in the classpath?");
|
||||
}
|
||||
final String dbSchema = config.getDbSchema();
|
||||
if (dbSchema != null) {
|
||||
migrationRunner.setDefaultDbSchema(dbSchema);
|
||||
}
|
||||
migrationRunner.setName(config.getName());
|
||||
migrationRunner.setPlatform(config.getDatabasePlatform().getPlatform().base().name().toLowerCase());
|
||||
migrationRunner.loadProperties(config.getProperties());
|
||||
migrationRunner.run(config.getDataSource());
|
||||
} else if (config.isDdlRun()) {
|
||||
ddlGenerator.runDdl();
|
||||
}
|
||||
|
||||
final String dbSchema = config.getDbSchema();
|
||||
if (dbSchema != null) {
|
||||
migrationRunner.setDefaultDbSchema(dbSchema);
|
||||
}
|
||||
migrationRunner.setName(config.getName());
|
||||
migrationRunner.setPlatform(config.getDatabasePlatform().getPlatform().base().name().toLowerCase());
|
||||
migrationRunner.loadProperties(config.getProperties());
|
||||
migrationRunner.run(dataSource());
|
||||
}
|
||||
|
||||
private void startQueryPlanCapture() {
|
||||
|
||||
Reference in new issue
Block a user