Skip to content

Commit

Permalink
NEW: DDL generation can be invoked separately
Browse files Browse the repository at this point in the history
Fix for css
  • Loading branch information
rPraml committed Aug 9, 2023
1 parent 83e87b0 commit 8c501f8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
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 @@ -1509,4 +1509,8 @@ public interface Database {
*/
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 @@ -2255,4 +2255,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 @@ -616,6 +616,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 @@ -627,4 +627,9 @@ public void loadBeanL2(EntityBeanIntercept ebi) {
public void loadBean(EntityBeanIntercept ebi) {

}

@Override
public void runDdl() {

}
}

0 comments on commit 8c501f8

Please sign in to comment.