Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] NEW: DDL generation can be invoked separately #3151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ebean-api/src/main/java/io/ebean/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -1520,4 +1520,8 @@ static DatabaseBuilder builder() {
*/
void truncate(Class<?>... beanTypes);

/**
* RunDdl manually. This can be used if 'db.ddl.run=false' is set and you plan to run DDL manually.
*/
void runDdl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public interface SpiDdlGenerator {
*/
void execute(boolean online);

/**
* Run DDL manually. This can be used to initialize multi tenant environments or if you plan not to run
* DDL on startup
*/
void runDdl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2285,4 +2285,9 @@ List<MetaQueryPlan> queryPlanInit(QueryPlanInit initRequest) {
List<MetaQueryPlan> queryPlanCollectNow(QueryPlanRequest request) {
return queryPlanManager.collect(request);
}

@Override
public void runDdl() {
ddlGenerator.runDdl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ private static class NoopDdl implements SpiDdlGenerator {
this.ddlRun = ddlRun;
}

@Override
public void runDdl() {
CoreLog.log.log(ERROR, "Manual DDL run not possible");
}

@Override
public void execute(boolean online) {
if (online && ddlRun) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ public DdlGenerator(SpiEbeanServer server) {
if (!config.getTenantMode().isDdlEnabled() && config.isDdlRun()) {
log.log(WARNING, "DDL can''t be run on startup with TenantMode " + config.getTenantMode());
this.runDdl = false;
this.useMigrationStoredProcedures = false;
} else {
this.runDdl = config.isDdlRun();
this.useMigrationStoredProcedures = config.getDatabasePlatform().useMigrationStoredProcedures();
}
this.useMigrationStoredProcedures = config.getDatabasePlatform() != null && config.getDatabasePlatform().useMigrationStoredProcedures();
this.scriptTransform = createScriptTransform(config);
this.baseDir = initBaseDir();
}
Expand All @@ -85,7 +84,7 @@ private File initBaseDir() {
@Override
public void execute(boolean online) {
generateDdl();
if (online) {
if (online && runDdl) {
runDdl();
}
}
Expand All @@ -105,16 +104,15 @@ protected void generateDdl() {
/**
* Run the DDL drop and DDL create scripts if properties have been set.
*/
protected void runDdl() {
if (runDdl) {
Connection connection = null;
try {
connection = obtainConnection();
runDdlWith(connection);
} finally {
JdbcClose.rollback(connection);
JdbcClose.close(connection);
}
@Override
public void runDdl() {
Connection connection = null;
try {
connection = obtainConnection();
runDdlWith(connection);
} finally {
JdbcClose.rollback(connection);
JdbcClose.close(connection);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,4 +632,9 @@ public void loadBeanL2(EntityBeanIntercept ebi) {
public void loadBean(EntityBeanIntercept ebi) {

}

@Override
public void runDdl() {

}
}