@@ -60,9 +60,18 WARNING: All data in the development database is deleted. | |||||
60 | DESC |
|
60 | DESC | |
61 |
|
61 | |||
62 | task :migrate_dbms => :environment do |
|
62 | task :migrate_dbms => :environment do | |
|
63 | ActiveRecord::Base.establish_connection :development | |||
|
64 | target_tables = ActiveRecord::Base.connection.tables | |||
|
65 | ActiveRecord::Base.remove_connection | |||
|
66 | ||||
63 | ActiveRecord::Base.establish_connection :production |
|
67 | ActiveRecord::Base.establish_connection :production | |
|
68 | tables = ActiveRecord::Base.connection.tables.sort - %w(schema_migrations plugin_schema_info) | |||
|
69 | ||||
|
70 | if (tables - target_tables).any? | |||
|
71 | abort "The following table(s) are missing from the target database: #{(tables - target_tables).join(', ')}" | |||
|
72 | end | |||
64 |
|
73 | |||
65 | (ActiveRecord::Base.connection.tables - %w(schema_migrations plugin_schema_info)).each do |table_name| |
|
74 | tables.each do |table_name| | |
66 | Source = Class.new(ActiveRecord::Base) |
|
75 | Source = Class.new(ActiveRecord::Base) | |
67 | Target = Class.new(ActiveRecord::Base) |
|
76 | Target = Class.new(ActiveRecord::Base) | |
68 | Target.establish_connection(:development) |
|
77 | Target.establish_connection(:development) |
General Comments 0
You need to be logged in to leave comments.
Login now