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)
This commit is contained in:
DJ Mountney 2018-06-27 13:34:45 -07:00
parent 5c13af58b8
commit a9fcf96856
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
title: Fixes an issue where migrations instead of schema loading were run
merge_request: 20227
author:
type: changed

View File

@ -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