mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 12:19:09 +00:00
#1937 - When add a new col with @DbComment in Entity,the DbMigration does not generate comment ddl
This commit is contained in:
@@ -951,6 +951,10 @@ public class BaseTableDdl implements TableDdl {
|
||||
}
|
||||
|
||||
platformDdl.alterTableAddColumn(buffer, tableName, column, onHistoryTable, help.getDefaultValue());
|
||||
final String comment = column.getComment();
|
||||
if (comment != null && !comment.isEmpty()) {
|
||||
platformDdl.addColumnComment(buffer, tableName, column.getName(), comment);
|
||||
}
|
||||
|
||||
if (!onHistoryTable) {
|
||||
help.writeAfter(buffer);
|
||||
|
||||
+16
@@ -19,6 +19,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
public class BaseTableDdlTest {
|
||||
@@ -98,6 +99,21 @@ public class BaseTableDdlTest {
|
||||
assertThat(ddl).contains("comment on column mytab.acol is 'my comment'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alterTableAddColumnWithComment() throws IOException {
|
||||
BaseTableDdl ddl = new BaseTableDdl(serverConfig, h2ddl);
|
||||
DdlWrite write = new DdlWrite();
|
||||
Column column = new Column();
|
||||
column.setName("my_column");
|
||||
column.setComment("some comment");
|
||||
column.setType("int");
|
||||
|
||||
ddl.alterTableAddColumn(write.apply(), "my_table", column, false, false);
|
||||
assertEquals(
|
||||
"alter table my_table add column my_column int;\n" +
|
||||
"comment on column my_table.my_column is 'some comment';\n", write.apply().getBuffer());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddTableComment() throws IOException {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user