mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2284 - ENH: ddl-generator - add optional generation of idx_<platform>.migrations file
This commit is contained in:
1 parent
4ba26ee7b7
commit
589ee7a5ea
17 files changed
+293
-9
No files matched your search
+26
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user