Update migration_versions table when generating SQL

This means if you run the SQL generated in full, your migration_versions
table is consistent with your database, and migrations will continue
to work in future.