mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#699 - DB Migration not generating sql to alter check constraints
This commit is contained in:
+21
@@ -5,10 +5,12 @@ import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.H2Platform;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.DdlWrite;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.Helper;
|
||||
import com.avaje.ebean.dbmigration.migration.AlterColumn;
|
||||
import com.avaje.ebean.dbmigration.migration.Column;
|
||||
import com.avaje.ebean.dbmigration.migration.CreateTable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -18,6 +20,25 @@ public class BaseTableDdlTest {
|
||||
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
|
||||
@Test
|
||||
public void testAlterColumn() throws IOException {
|
||||
|
||||
BaseTableDdl ddlGen = new BaseTableDdl(serverConfig, new H2Platform().getPlatformDdl());
|
||||
|
||||
DdlWrite write = new DdlWrite();
|
||||
|
||||
AlterColumn alterColumn = new AlterColumn();
|
||||
alterColumn.setTableName("mytab");
|
||||
alterColumn.setCheckConstraint("check (acol in ('A','B'))");
|
||||
alterColumn.setCheckConstraintName("ck_mytab_acol");
|
||||
|
||||
ddlGen.generate(write, alterColumn);
|
||||
|
||||
String ddl = write.apply().getBuffer();
|
||||
assertThat(ddl).contains("alter table mytab drop constraint ck_mytab_acol");
|
||||
assertThat(ddl).contains("alter table mytab add constraint ck_mytab_acol check (acol in ('A','B'))");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerate() throws Exception {
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class MColumnTest {
|
||||
|
||||
assertChanges(diff);
|
||||
assertThat(getAlterColumn(diff).getCheckConstraint()).isEqualTo("abc");
|
||||
assertThat(getAlterColumn(diff).getDropCheckConstraint()).isEqualTo("d");
|
||||
assertThat(getAlterColumn(diff).getDropCheckConstraint()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user