SQLiteMigrationOperationPreProcessor:

The operations are classified as follows:

1. CreateTable
2. Table subordinate operations (involve ALTER TABLE ...). The subordinates are divided into: renames (RenameTable, MoveTable), supported (AddColumn) and unsupported (others). The renames are supported operations.
3. Other operations (AddIndex, CreateIndex, etc), including DropTableOperation.

The operation sequence is handled as follows:

1. The table operations are grouped as encountered (except DropTable). They are pending (not processed).
2. When encountering a DropTable, or a non-table operation, the pending operations are processed first, then the current operation.
3. When getting the result Statements the pending operations are processed before return.

There are 3 types of group handlers that store pending operations, each identified by the name of the table it operates on.

1. A CreateTableHandler is started when visiting a CreateTable operation.
2. An AlterTableHandler is started when visiting a supported subordinate operation on a table not associated with a handler.
3. A RebuildTableHandler is started when visiting an unsupported subordinate operation on a table not associated with a handler.

Note:
An AlterTableHandler is promoted to RebuildTableHandler if an unsupported subordinate operation on the corresponding table is encountered.

The pending operations are processed by each handler as follows:

1. context.Generator.Database is cloned and stored into context.Database
1. CreateTableHandler updates context.Database with all operations in the group, then generates a CreateTable operation for the up-to-date table.
2. AlterTableHandler simply returns the operations in the group.
3. RebuildTableHandler updates context.Database with all operations in the group, then generates a DropTable operation with the initial table name followed by a CreateTable operation for the up-to-date table. In the future this will include an operation for copying data (including rename if table name did not change)
4. The operations returned by handlers are processed, context.Generator.Database is updated, and the handlers removed.

Notes:
When the RenameTable and MoveTable operations are processed the TableName associated with the corresponding handler is updated.