we would like to implement Alter-Column commands using Aurelius TDatabaseManager.
For this the Action-Procedures should be protected:
procedure ActionPrimaryKeyChanged(OldTable, NewTable: TTableMetadata);
procedure ActionUniqueKeyRemoved(UniqueKey: TUniqueKeyMetadata);
procedure ActionUniqueKeyAdded(UniqueKey: TUniqueKeyMetadata);
procedure ActionUniqueKeyChanged(OldUniqueKey, NewUniqueKey: TUniqueKeyMetadata);
procedure ActionDBIndexRemoved(DBIndex: TDBIndexMetadata);
procedure ActionDBIndexAdded(DBIndex: TDBIndexMetadata);
// procedure ActionDBIndexChanged(OldDBIndex, NewDBIndex: TDBIndexMetadata);
procedure ActionForeignKeyRemoved(ForeignKey: TForeignKeyMetadata);
procedure ActionForeignKeyAdded(ForeignKey: TForeignKeyMetadata);
procedure ActionForeignKeyChanged(OldForeignKey, NewForeignKey: TForeignKeyMetadata);
procedure ActionColumnRequiredChanged(OldColumn, NewColumn: TColumnMetadata);
procedure ActionColumnTypeChanged(OldColumn, NewColumn: TColumnMetadata);
procedure ActionColumnIdentityChanged(OldColumn, NewColumn: TColumnMetadata);
procedure ActionFieldSizeChanged(OldColumn, NewColumn: TColumnMetadata);
procedure ActionColumnRemoved(Column: TColumnMetadata);
procedure ActionColumnAdded(Column: TColumnMetadata);
procedure ActionTableRemoved(Table: TTableMetadata);
procedure ActionTableAdded(Table: TTableMetadata);
procedure ActionSequenceRemoved(Sequence: TSequenceMetadata);
procedure ActionSequenceAdded(Sequence: TSequenceMetadata);
2 protected procedures need to be added:
procedure AppendCommandsOrder(aCommandOrder: TDictionary<TClass, integer>); virtual;
procedure AfterCheckTable(aNewTable: TTableMetadata); virtual;
procedure CompareTables(OldTable, NewTable: TTableMetadata);
var
...
begin
...
AfterCheckTable(NewTable);
end;
CommandOrder := TDictionary<TClass, integer>.Create;
try
CommandOrder.Add(TDropDBIndexCommand, -60);
CommandOrder.Add(TDropForeignKeyCommand, -50);
CommandOrder.Add(TDropUniqueKeyCommand, -40);
CommandOrder.Add(TDropTableCommand, -30);
CommandOrder.Add(TDropSequenceCommand, -20);
CommandOrder.Add(TDropColumnCommand, -10);
CommandOrder.Add(TCreateColumnCommand, 10);
CommandOrder.Add(TCreateTableCommand, 20);
CommandOrder.Add(TCreateSequenceCommand, 30);
// CommandOrder.Add(TCreateUniqueKeyCommand, 40);
CommandOrder.Add(TCreateForeignKeyCommand, 50);
CommandOrder.Add(TCreateDBIndexCommand, 60);
AppendCommandsOrder(CommandOrder);
with this small changes we would be able to append our own Actions in your nice working DatabaseManager workflow.
for example I would do something like this:
AppendCommandsOrder:
aCommandOrder.Add(TAlterColumnName, 1);
aCommandOrder.Add(TAlterColumnType, 2);
aCommandOrder.Add(TAlterColumnDefault, 3);
aCommandOrder.Add(TAlterColumnNullable, 6);
Making all Action-procedures virtual, you would give us flexibility change behaviour, as we would need it (and know, that this works for us)
For Example, define our own (translateable) messages or stuff like this.