mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2287 - ebean-migration: For multiple platforms automatically run the correct migrations
This commit is contained in:
1 parent
d98a31fa6b
commit
f34e0f5f2b
10 files changed
+21
-44
No files matched your search
+4
-5
@@ -281,7 +281,7 @@ public class DefaultDbMigration implements DbMigration {
|
||||
public String generateMigration() throws IOException {
|
||||
final String version = generateMigrationFor(false);
|
||||
if (includeIndex) {
|
||||
generateIndex(version);
|
||||
generateIndex();
|
||||
}
|
||||
return version;
|
||||
}
|
||||
@@ -289,15 +289,14 @@ public class DefaultDbMigration implements DbMigration {
|
||||
/**
|
||||
* Generate the {@code idx_platform.migrations} file.
|
||||
*/
|
||||
private void generateIndex(String version) throws IOException {
|
||||
final boolean overwrite = version != null;
|
||||
private void generateIndex() throws IOException {
|
||||
final File topDir = migrationDirectory(false);
|
||||
if (!platforms.isEmpty()) {
|
||||
for (Pair pair : platforms) {
|
||||
new IndexMigration(topDir, pair).generate(overwrite);
|
||||
new IndexMigration(topDir, pair).generate();
|
||||
}
|
||||
} else {
|
||||
new IndexMigration(topDir, databasePlatform).generate(overwrite);
|
||||
new IndexMigration(topDir, databasePlatform).generate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,7 @@ class IndexMigration {
|
||||
return new File(topDir, name);
|
||||
}
|
||||
|
||||
void generate(boolean overwrite) throws IOException {
|
||||
if (!overwrite && indexFile.exists()) {
|
||||
return;
|
||||
}
|
||||
void generate() throws IOException {
|
||||
readSqlFiles(topDir);
|
||||
generateIndex();
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ public class IndexMigrationTest {
|
||||
}
|
||||
DatabasePlatform pg = new PostgresPlatform();
|
||||
IndexMigration indexMigration = new IndexMigration(topDir, pg);
|
||||
indexMigration.generate(true);
|
||||
indexMigration.generate();
|
||||
|
||||
|
||||
File expected = new File(topDir, "idx_postgres.migrations");
|
||||
@@ -48,7 +48,7 @@ public class IndexMigrationTest {
|
||||
}
|
||||
DatabasePlatform pg = new H2Platform();
|
||||
IndexMigration indexMigration = new IndexMigration(topDir, pg);
|
||||
indexMigration.generate(true);
|
||||
indexMigration.generate();
|
||||
|
||||
File expected = new File(topDir, "idx_h2.migrations");
|
||||
assertThat(expected).exists();
|
||||
|
||||
Reference in new issue
Block a user