Oracle does not support autoincrement, so I would like to extend the CreateTableChange.
Everytime a table is created, a sequence for the autoincrement column will be created, too (when using Oracle).
And when the table is dropped the sequence will be dropped.
The problem is, that the ChangeFactory can only hold one implementation for createTable and the last one loaded wins.
Is it possible to chain changes like you can do with the SQL generators?
Are you using 2.0 or 1.x? The extension system in 2.0 has been greatly enhanced, I’m not sure if you can do what you want in 1.9, but it would be no problem in 2.0.
With 2.0, there is a getPriority() call on all the Change and SqlGenerator classes to control the one that is used. I’m still working on the docs, there is some at the extension portal (http://liquibase.jira.com/wiki/display/CONTRIB/LiquiBase+Extensions+Portal) under the “Resources” panel.
Nathan
I am using 2.0 (trunk), but I think this is not working.
I want to implement some funktionality on top of CreateTableChange. In my case I want to create a sequence when a table is created and I want to drop the sequence when the table is dropped.
public class CreateTableChangeOracle extends AbstractChange {
public CreateTableChangeOracle() {
super(“createTable”, “Create Table”, ChangeMetaData.PRIORITY_DEFAULT + 10);
}
@Override
public SqlStatement[] generateStatements(Database database) {
return new SqlStatement[] {
new CreateSequenceStatement(…);
};
}
@Override
protected Change[] createInverses() {
return new Change[] {
new DropSequenceChange()
};
}
@Override
public String getConfirmationMessage() {
// TODO Auto-generated method stub
return null;
}
}
When the ChangeFactory initializes its registry, it uses a Hash to cache the implementations. When the classes are loaded in the seuqence CreateTableChange -> CreateTableChangeOracle, the factory hash has [createTable => CreateTableChangeOracle]. So there is no chaining like the SQL generators do. In this case only one change implementation will be executed.
The way you are doing it should be correct. I will look into it http://liquibase.jira.com/browse/CORE-546
Nathan