Closed fljdin closed 1 year ago
Yes, that sounds viable.
Perhaps it would be a good idea to provide an additional function that would execute the SQL statement, print the exception detail and log it. That could be handy for people who want to parallelize migrating indexes.
db_migrate_indexes
would then become a very simple wrapper.
I have made a working branch with unit testing
execute_statement(text,name,name,text)
function, used by db_migrate_*
methodsconstruct_indexes_statements(name, name)
table-functiondb_migrate_indexes()
becomes a wrapper that links theses new functions togetherhttps://github.com/cybertec-postgresql/db_migrator/compare/master..26-statements-functions
I am a bit confused by the two branches 26-statements-functions
and 26-execute_statement
.
Are these two implementations of the same thing? Which branch should I review?
Branch 26-execute_statement
is a complete implementation for a generic execution method (with errors handling), independent from this current issue (or not?).
The second one was an experimentation, attached to this issue. I just realized that a bit tricky to do that way, please forgive me. I'll clean existing branches and work on an unique one.
A refactor could be made by using table functions returning statements per relations, in that way, it could be easier to separate looping over staging tables and statement execution like I suggested in #24.
Example with
db_indexes_statements
table function:With this uncorrelated system, it becomes possible to perform migration by external tools without calling neither
db_migrate
nor anydb_migrate_*
methods.External tools in any language may consume
db_migrator
API (staging tables and statement table-functions as proposed) to execute statements and catch exceptions. From my point of view, it will provide a better way to speed-up migration with multiple processes.