Commit 1a7326ba authored by DJ Mountney's avatar DJ Mountney

Switch the gitlab:db:configure task to use tables.any? instead of looking...

Switch the gitlab:db:configure task to use tables.any? instead of looking specifically for the schema_migrations table
parent 40d4d8a4
...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.9.0 (unreleased) v 8.9.0 (unreleased)
- Redesign navigation for project pages - Redesign navigation for project pages
- Use gitlab-shell v3.0.0 - Use gitlab-shell v3.0.0
- Add rake task 'gitlab:db:configure' for conditionally seeding or migrating the database
- Changed the Slack build message to use the singular duration if necessary (Aran Koning) - Changed the Slack build message to use the singular duration if necessary (Aran Koning)
- Fix issues filter when ordering by milestone - Fix issues filter when ordering by milestone
- Todos will display target state if issuable target is 'Closed' or 'Merged' - Todos will display target state if issuable target is 'Closed' or 'Merged'
...@@ -46,7 +47,6 @@ v 8.8.0 ...@@ -46,7 +47,6 @@ v 8.8.0
- Sanitize repo paths in new project error message - Sanitize repo paths in new project error message
- Bump mail_room to 0.7.0 to fix stuck IDLE connections - Bump mail_room to 0.7.0 to fix stuck IDLE connections
- Remove future dates from contribution calendar graph. - Remove future dates from contribution calendar graph.
- Add rake task 'gitlab:db:configure' for conditionally seeding or migrating the database
- Support e-mail notifications for comments on project snippets - Support e-mail notifications for comments on project snippets
- Fix API leak of notes of unauthorized issues, snippets and merge requests - Fix API leak of notes of unauthorized issues, snippets and merge requests
- Use ActionDispatch Remote IP for Akismet checking - Use ActionDispatch Remote IP for Akismet checking
......
...@@ -39,7 +39,7 @@ namespace :gitlab do ...@@ -39,7 +39,7 @@ namespace :gitlab do
desc 'Configures the database by running migrate, or by loading the schema and seeding if needed' desc 'Configures the database by running migrate, or by loading the schema and seeding if needed'
task configure: :environment do task configure: :environment do
if ActiveRecord::Base.connection.table_exists? 'schema_migrations' if ActiveRecord::Base.connection.tables.any?
Rake::Task['db:migrate'].invoke Rake::Task['db:migrate'].invoke
else else
Rake::Task['db:schema:load'].invoke Rake::Task['db:schema:load'].invoke
......
...@@ -20,7 +20,7 @@ describe 'gitlab:db namespace rake task' do ...@@ -20,7 +20,7 @@ describe 'gitlab:db namespace rake task' do
describe 'configure' do describe 'configure' do
it 'should invoke db:migrate when schema has already been loaded' 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:migrate']).to receive(:invoke)
expect(Rake::Task['db:schema:load']).not_to receive(:invoke) expect(Rake::Task['db:schema:load']).not_to receive(:invoke)
expect(Rake::Task['db:seed_fu']).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 ...@@ -28,7 +28,7 @@ describe 'gitlab:db namespace rake task' do
end end
it 'should invoke db:shema:load and db:seed_fu when schema is not loaded' do 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:schema:load']).to receive(:invoke)
expect(Rake::Task['db:seed_fu']).to receive(:invoke) expect(Rake::Task['db:seed_fu']).to receive(:invoke)
expect(Rake::Task['db:migrate']).not_to receive(:invoke) expect(Rake::Task['db:migrate']).not_to receive(:invoke)
...@@ -46,7 +46,7 @@ describe 'gitlab:db namespace rake task' do ...@@ -46,7 +46,7 @@ describe 'gitlab:db namespace rake task' do
end end
it 'should not invoke seed after a failed schema_load' do 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') 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:schema:load']).to receive(:invoke)
expect(Rake::Task['db:seed_fu']).not_to receive(:invoke) expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment