I would like to run some SQL after the schema migration has been performed.
Some points:
-
If I execute the SQL during the Up function call, it is not executing with the latest schema version because the schema update takes effect afterwards.
-
Calling Database.Commit() commits the changes immediately, but the connection is closed therefore cannot execute SQL.
-
Calling my SQL in the AfterUp() function the connection is also closed.
How am I supposed to execute some SQL after the schema has been updated?
Immediately after asking this question it hit me … Create another migration which just does the data. It will have an open connection and will only be performed once the schema migration has passed.