From 0139ad891ea6ef32006e87a0b13744ecb9d790f3 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 21 Jan 2022 17:20:21 +1300 Subject: [PATCH] #2403 - table partitioning (Postgres only at this point) is always included + simplify skip logic --- .../io/ebeaninternal/dbmigration/DdlGenerator.java | 2 +- .../ebeaninternal/dbmigration/DefaultDbMigration.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java index 1670848429..b9fead35b6 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java @@ -212,7 +212,7 @@ protected void runCreateSql(Connection connection) throws IOException { if (extraDdl && jaxbPresent) { if (currentModel().isTablePartitioning()) { String extraPartitioning = ExtraDdlXmlReader.buildPartitioning(platform); - if (extraPartitioning != null && !extraPartitioning.isEmpty() && useMigrationStoredProcedures) { + if (extraPartitioning != null && !extraPartitioning.isEmpty()) { runScript(connection, false, extraPartitioning, "builtin-partitioning-ddl"); } } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java index 8d1bb22b40..4add6fe133 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java @@ -397,23 +397,20 @@ private void configurePlatforms() { private void generateExtraDdl(File migrationDir, DatabasePlatform dbPlatform, boolean tablePartitioning) throws IOException { if (dbPlatform != null) { if (tablePartitioning && includeBuiltInPartitioning) { - generateExtraDdlFor(migrationDir, dbPlatform, ExtraDdlXmlReader.readBuiltinTablePartitioning(), true); + generateExtraDdlFor(migrationDir, dbPlatform, ExtraDdlXmlReader.readBuiltinTablePartitioning(), false); } + // skip built-in migration stored procedures based on isUseMigrationStoredProcedures generateExtraDdlFor(migrationDir, dbPlatform, ExtraDdlXmlReader.readBuiltin(), true); generateExtraDdlFor(migrationDir, dbPlatform, ExtraDdlXmlReader.read(), false); } } - private void generateExtraDdlFor(File migrationDir, DatabasePlatform dbPlatform, ExtraDdl extraDdl, boolean isBuiltin) throws IOException { + private void generateExtraDdlFor(File migrationDir, DatabasePlatform dbPlatform, ExtraDdl extraDdl, boolean checkSkip) throws IOException { if (extraDdl != null) { List ddlScript = extraDdl.getDdlScript(); for (DdlScript script : ddlScript) { if (!script.isDrop() && matchPlatform(dbPlatform.getPlatform(), script.getPlatforms())) { - if (script.isInit()) { - if (!isBuiltin || dbPlatform.isUseMigrationStoredProcedures()) { - writeExtraDdl(migrationDir, script); - } - } else { + if (!checkSkip || dbPlatform.isUseMigrationStoredProcedures()) { writeExtraDdl(migrationDir, script); } }