@@ -60,9 +60,18 WARNING: All data in the development database is deleted. | |||
|
60 | 60 | DESC |
|
61 | 61 | |
|
62 | 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 | 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 | 75 | Source = Class.new(ActiveRecord::Base) |
|
67 | 76 | Target = Class.new(ActiveRecord::Base) |
|
68 | 77 | Target.establish_connection(:development) |
General Comments 0
You need to be logged in to leave comments.
Login now