]> source.dussan.org Git - redmine.git/commitdiff
Check that target tables exist before proceeding.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Feb 2014 10:49:57 +0000 (10:49 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Feb 2014 10:49:57 +0000 (10:49 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12865 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/tasks/redmine.rake

index cd11796e3b6978e3114bafcbc2c9fef6a4e13560..c8d35afb28365980102330a61fa9d85f2d293591 100644 (file)
@@ -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)