#2284 - ENH: ddl-generator - add optional generation of idx_<platform>.migrations file

This commit is contained in:
rbygrave committed 2021-08-02 23:59:49 +12:00
1 parent 4ba26ee7b7
commit 589ee7a5ea
17 files changed
+293 -9

No files matched your search

@@ -106,6 +106,7 @@ public class DefaultDbMigration implements DbMigration {
private boolean addForeignKeySkipCheck;
private int lockTimeoutSeconds;
protected boolean includeBuiltInPartitioning = true;
protected boolean includeIndex;
/**
* Create for offline migration generation.
@@ -182,6 +183,11 @@ public class DefaultDbMigration implements DbMigration {
this.generatePendingDrop = generatePendingDrop;
}
@Override
public void setIncludeIndex(boolean includeIndex) {
this.includeIndex = includeIndex;
}
@Override
public void setIncludeGeneratedFileComment(boolean includeGeneratedFileComment) {
this.includeGeneratedFileComment = includeGeneratedFileComment;
@@ -273,7 +279,26 @@ public class DefaultDbMigration implements DbMigration {
*/
@Override
public String generateMigration() throws IOException {
return generateMigrationFor(false);
final String version = generateMigrationFor(false);
if (includeIndex) {
generateIndex(version);
}
return version;
}
/**
* Generate the {@code idx_platform.migrations} file.
*/
private void generateIndex(String version) throws IOException {
final boolean overwrite = version != null;
final File topDir = migrationDirectory(false);
if (!platforms.isEmpty()) {
for (Pair pair : platforms) {
new IndexMigration(topDir, pair).generate(overwrite);
}
} else {
new IndexMigration(topDir, databasePlatform).generate(overwrite);
}
}
@Override