mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-03 08:24:23 +00:00
Feature/ddl migration (#1111)
* REFACTOR: use functions from ddl-help * NEW: Default values are written to DDL * fix testcase for sqlserver as default constraints will get names in future * Reading DbMigration * ADD: DbmIgrationGenerateTest * Tables must be created first * Sanity checks and some getters * DdlMigration gets applied now * ADD: Testcase and reference migration scripts * no effective code changes: add comments
This commit is contained in:
1 parent
73b3d1d977
commit
dd8fff0277
90 files changed
+2767
-70
No files matched your search
@@ -0,0 +1,71 @@
|
||||
package io.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.ebean.Platform;
|
||||
/**
|
||||
* Class to hold the DDL-migration information that is needed to do correct alters.
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
public class DbMigrationInfo {
|
||||
|
||||
private final List<String> preAdd;
|
||||
private final List<String> postAdd;
|
||||
private final List<String> preAlter;
|
||||
private final List<String> postAlter;
|
||||
private final List<Platform> platforms;
|
||||
|
||||
public DbMigrationInfo(String[] preAdd, String[] postAdd, String[] preAlter, String[] postAlter, Platform[] platforms) {
|
||||
this.preAdd = toList(preAdd);
|
||||
this.postAdd = toList(postAdd);
|
||||
this.preAlter = toList(preAlter);
|
||||
this.postAlter = toList(postAlter);
|
||||
this.platforms = toList(platforms);
|
||||
}
|
||||
|
||||
private <T> List<T> toList(T[] scripts) {
|
||||
if (scripts.length == 0) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return Collections.unmodifiableList(Arrays.asList(scripts));
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getPreAdd() {
|
||||
return preAdd;
|
||||
}
|
||||
public List<String> getPostAdd() {
|
||||
return postAdd;
|
||||
}
|
||||
public List<String> getPreAlter() {
|
||||
return preAlter;
|
||||
}
|
||||
public List<String> getPostAlter() {
|
||||
return postAlter;
|
||||
}
|
||||
public List<Platform> getPlatforms() {
|
||||
return platforms;
|
||||
}
|
||||
|
||||
public String joinPlatforms() {
|
||||
if (platforms.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Platform p : platforms) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(',');
|
||||
}
|
||||
sb.append(p.name().toLowerCase());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user