#772 - DB Migration DDL - alter table add column ... needs type conversion when using multiple platforms. e.g. varchar(20) ... convert to varchar2(20) for Oracle

This commit is contained in:
Robin Bygrave
2016-07-11 21:25:58 +12:00
parent a1be7ba5dd
commit 8a853b28f3
2 changed files with 20 additions and 1 deletions
@@ -3,6 +3,7 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebean.config.dbplatform.H2Platform;
import com.avaje.ebean.config.dbplatform.OraclePlatform;
import com.avaje.ebean.dbmigration.ddlgeneration.DdlWrite;
import com.avaje.ebean.dbmigration.ddlgeneration.Helper;
import com.avaje.ebean.dbmigration.migration.AddTableComment;
@@ -40,6 +41,23 @@ public class BaseTableDdlTest {
assertThat(ddl).contains("alter table mytab add constraint ck_mytab_acol check (acol in ('A','B'))");
}
@Test
public void testAddColumn_withTypeConversion() throws IOException {
BaseTableDdl ddlGen = new BaseTableDdl(serverConfig, new OraclePlatform().getPlatformDdl());
DdlWrite write = new DdlWrite();
Column column = new Column();
column.setName("col_name");
column.setType("varchar(20)");
ddlGen.alterTableAddColumn(write.apply(), "mytable", column, false);
String ddl = write.apply().getBuffer();
assertThat(ddl).contains("alter table mytable add column col_name varchar2(20)");
}
@Test
public void testAlterColumnComment() throws IOException {