@Test
public void alterColumnDefaultIdentity() {
final int id = createTable(SCHEMA, C_TABLE,
"id INT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY");
Column column = getTable(id).getColumn("id");
assertEquals("identity is default", true, column.getDefaultIdentity());
Sequence seq = column.getIdentityGenerator();
assertNotNull("id column has sequence", seq);
runAlter(ChangeLevel.METADATA, "ALTER TABLE c ALTER COLUMN id DROP DEFAULT");
assertNull("Old seq was dropped", ais().getSequence(seq.getSequenceName()));
runAlter(ChangeLevel.METADATA, "ALTER TABLE c ALTER COLUMN id SET GENERATED ALWAYS AS IDENTITY");
Column newColumn = getTable(id).getColumn("id");
assertEquals("altered is always", false, newColumn.getDefaultIdentity());
seq = newColumn.getIdentityGenerator();
assertEquals("Sequence name suffix",
true,
seq.getSequenceName().getTableName().endsWith("_seq"));
}