Skip to content

Commit

Permalink
Merge pull request #326 from genome/issue-318
Browse files Browse the repository at this point in the history
stop-gap measure for #318 allows forced db updates from rake task
  • Loading branch information
acoffman authored May 31, 2017
2 parents 03e35df + 34476a8 commit c408c07
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following will set up the server side application and load the database sche

For convenience, a sanitized version of a recent database backup is provided for your local development environment. You can load it with the following command:

rake civic:load
rake civic:load[force]

Finally, start the CIViC rails server

Expand Down
4 changes: 2 additions & 2 deletions lib/database/upgrade.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Database
class Upgrade
def self.upgrade_if_needed
def self.upgrade_if_needed (force = false)
data_dump_version = Rails.configuration.data_dump_version
current_database_version = DataVersion.maximum(:version) || 0

if data_dump_version > current_database_version
if data_dump_version > current_database_version || force
puts "Database out of date - loading the new data dump."
Rake::Task['db:migrate'].execute
truncate_tables
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/import.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace :civic do
desc 'if the current data dump is newer than the contents of the database, this loads the newer data dump'
task :load, [] => :environment do |_, args|
Database::Upgrade.upgrade_if_needed
task :load, [:force] => :environment do |_, args|
Database::Upgrade.upgrade_if_needed args[:force]
if Rails.env.production?
Dir.chdir(Rails.root) do
system('bin/delayed_job', '-n 3', 'restart')
Expand Down

0 comments on commit c408c07

Please sign in to comment.