summaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-02-09 10:49:57 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-02-09 10:49:57 +0000
commitfa31229a2338706455dd754fd57e7f7e8ebf26a7 (patch)
treeb751e37c105e3e778f2dd00f281198fb191cfa6d /lib/tasks
parent8e00c6ebb9f0ba82b9bc6254b4f6accb395222ea (diff)
downloadredmine-fa31229a2338706455dd754fd57e7f7e8ebf26a7.tar.gz
redmine-fa31229a2338706455dd754fd57e7f7e8ebf26a7.zip
Check that target tables exist before proceeding.
git-svn-id: http://svn.redmine.org/redmine/trunk@12865 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/redmine.rake11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/tasks/redmine.rake b/lib/tasks/redmine.rake
index cd11796e3..c8d35afb2 100644
--- a/lib/tasks/redmine.rake
+++ b/lib/tasks/redmine.rake
@@ -60,9 +60,18 @@ WARNING: All data in the development database is deleted.
DESC
task :migrate_dbms => :environment do
+ ActiveRecord::Base.establish_connection :development
+ target_tables = ActiveRecord::Base.connection.tables
+ ActiveRecord::Base.remove_connection
+
ActiveRecord::Base.establish_connection :production
+ tables = ActiveRecord::Base.connection.tables.sort - %w(schema_migrations plugin_schema_info)
+
+ if (tables - target_tables).any?
+ abort "The following table(s) are missing from the target database: #{(tables - target_tables).join(', ')}"
+ end
- (ActiveRecord::Base.connection.tables - %w(schema_migrations plugin_schema_info)).each do |table_name|
+ tables.each do |table_name|
Source = Class.new(ActiveRecord::Base)
Target = Class.new(ActiveRecord::Base)
Target.establish_connection(:development)