Use rake db:migrate:status to check for pending migrations
This is a small rewrite of the database migrations trigger. Instead of comparing the gitlab-rails version we can look for pending database migrations.
Merge request reports
Activity
@jacobvosmaer Yup, this was my comment as well so trying to see if we can do this better or if the can live with the slowness. It would be so much easier if we can just connect to the database and look at the
schema_migrations
table and if it doesn't match the db/schema.rb version trigger a migration...Actually, there is some room to improve this without loading rake task or going into the db.
I think we could adapt migrate_database definition and pipe the result of the run to a file. On next reconfigure run we can just check if the file has the expected value, if not run the migration again.
Still I think we are looking for a faster solution which will never be so solid as
rake db:migrate:status
, for the record the command will run forreal 0m11.745s
.Or if 11 seconds is really too long we can simple add the commit hash in VERSION as well.
Edited by username-removed-29582@jnijhof That is correct, we won't find as solid solution as
db:migrate:status
. The time is highly dependent on the environment, for me this showedreal 0m18.063s
on a VM, it is safe to assume this varies based on the machine. We have other tasks that we run so we need to be careful to not make the reconfigure run very slow. For this specific case we still have options so lets see if we can use those first :)mentioned in merge request !700 (merged)
closing in favor of !700 (merged)
mentioned in commit 3b42520a