summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2016-05-15 07:59:49 -0700
committerDJ Mountney <david@twkie.net>2016-05-15 07:59:49 -0700
commit8d26837d781f4fd1c7210c4fc2998460a4b5fd94 (patch)
treeb427adcb9fbab95f92abc19ac0316d83bad801bf
parent6acb123f64b389a9a54b3753ae397a4d2b10e721 (diff)
downloadgitlab-ce-db-configure-rake-task.tar.gz
Switch the gitlab:db:configure task to use tables.any? instead of looking specifically for the schema_migrations tabledb-configure-rake-task
-rw-r--r--lib/tasks/gitlab/db.rake2
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb6
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index 4d7184c5340..67fe136ed3c 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -34,7 +34,7 @@ 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.table_exists? 'schema_migrations'
+ if ActiveRecord::Base.connection.tables.any?
Rake::Task['db:migrate'].invoke
else
Rake::Task['db:schema:load'].invoke
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index fe70d5bcbf4..36d03a224e4 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -20,7 +20,7 @@ describe 'gitlab:db namespace rake task' do
describe 'configure' do
it 'should invoke db:migrate when schema has already been loaded' do
- allow(ActiveRecord::Base.connection).to receive(:table_exists?).and_return(true)
+ allow(ActiveRecord::Base.connection).to receive(:tables).and_return(['default'])
expect(Rake::Task['db:migrate']).to receive(:invoke)
expect(Rake::Task['db:schema:load']).not_to receive(:invoke)
expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)
@@ -28,7 +28,7 @@ describe 'gitlab:db namespace rake task' do
end
it 'should invoke db:shema:load and db:seed_fu when schema is not loaded' do
- allow(ActiveRecord::Base.connection).to receive(:table_exists?).and_return(false)
+ allow(ActiveRecord::Base.connection).to receive(:tables).and_return([])
expect(Rake::Task['db:schema:load']).to receive(:invoke)
expect(Rake::Task['db:seed_fu']).to receive(:invoke)
expect(Rake::Task['db:migrate']).not_to receive(:invoke)
@@ -46,7 +46,7 @@ describe 'gitlab:db namespace rake task' do
end
it 'should not invoke seed after a failed schema_load' do
- allow(ActiveRecord::Base.connection).to receive(:table_exists?).and_return(false)
+ allow(ActiveRecord::Base.connection).to receive(:tables).and_return([])
allow(Rake::Task['db:schema:load']).to receive(:invoke).and_raise(RuntimeError, 'error')
expect(Rake::Task['db:schema:load']).to receive(:invoke)
expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)