From a9fcf968566a63cc5af70789e9b7e558c68585c2 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Wed, 27 Jun 2018 13:34:45 -0700 Subject: [PATCH] Fixes an issue where migrations instead of schema loading were run If you called rake gitlab:db:drop_tables before running gitlab-ctl reconfigure (or rake gitlab:db:configure) --- changelogs/unreleased/db-configure-after-drop-tables.yml | 5 +++++ lib/tasks/gitlab/db.rake | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/db-configure-after-drop-tables.yml diff --git a/changelogs/unreleased/db-configure-after-drop-tables.yml b/changelogs/unreleased/db-configure-after-drop-tables.yml new file mode 100644 index 00000000000..00844b334fa --- /dev/null +++ b/changelogs/unreleased/db-configure-after-drop-tables.yml @@ -0,0 +1,5 @@ +--- +title: Fixes an issue where migrations instead of schema loading were run +merge_request: 20227 +author: +type: changed diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 139ab70e125..69166851816 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -46,7 +46,9 @@ namespace :gitlab do desc 'Configures the database by running migrate, or by loading the schema and seeding if needed' task configure: :environment do - if ActiveRecord::Base.connection.tables.any? + # Check if we have existing db tables + # The schema_migrations table will still exist if drop_tables was called + if ActiveRecord::Base.connection.tables.count > 1 Rake::Task['db:migrate'].invoke else Rake::Task['db:schema:load'].invoke