diff options
author | DJ Mountney <david@twkie.net> | 2019-06-20 08:29:09 -0700 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2019-06-25 10:44:40 -0700 |
commit | f4232d848eebcdc709ccec9c2004753accb3f3b5 (patch) | |
tree | c6bd858b2ee38db5ede8204661ef9d23d14c10a2 | |
parent | f4e15535198da1d5a655b6abe0afafac47219ab5 (diff) | |
download | gitlab-ce-f4232d848eebcdc709ccec9c2004753accb3f3b5.tar.gz |
Fix db:migrate for fresh installs
-rw-r--r-- | lib/tasks/migrate/schema_check.rake | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/tasks/migrate/schema_check.rake b/lib/tasks/migrate/schema_check.rake index 1f2ed2f439c..e8505e576a4 100644 --- a/lib/tasks/migrate/schema_check.rake +++ b/lib/tasks/migrate/schema_check.rake @@ -1,6 +1,11 @@ desc 'Configures the database by running migrate, or by loading the schema and seeding if needed' task schema_version_check: :environment do - if ActiveRecord::Migrator.current_version < Gitlab::Database::MIN_SCHEMA_VERSION + schema_version = ActiveRecord::Migrator.current_version + + # Ensure migrations are being run from a supported schema version + # A schema verison of 0 is a fresh db, and should be safe to run migrations + # But a database with existing migrations less than our min version is not + if schema_version > 0 && schema_version < Gitlab::Database::MIN_SCHEMA_VERSION raise "Your current database version is too old to be migrated. " \ "You should upgrade to GitLab #{Gitlab::Database::MIN_SCHEMA_GITLAB_VERSION} before moving to this version. " \ "Please see https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations" |