aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-06-12 15:29:20 +0200
committerYves Senn <yves.senn@gmail.com>2014-06-12 15:29:20 +0200
commit46139d33c06715e74ad450428ece3ee84da98579 (patch)
tree28bab2fe3b127962321f5a765118ce9d5d812afe /activerecord
parent8f247871bb18b2e3036a05df5f62cbfe3b402586 (diff)
parentad42aaed04a6098732105c12c853bc912ee5cadd (diff)
downloadrails-46139d33c06715e74ad450428ece3ee84da98579.tar.gz
rails-46139d33c06715e74ad450428ece3ee84da98579.tar.bz2
rails-46139d33c06715e74ad450428ece3ee84da98579.zip
Merge pull request #15394 from morgoth/fix-automatic-maintaining-test-schema-for-sql-format
ActiveRecord::Migration.maintain_test_schema! doesn't work with structure.sql Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md7
-rw-r--r--activerecord/lib/active_record/tasks/database_tasks.rb2
-rw-r--r--activerecord/lib/active_record/tasks/sqlite_database_tasks.rb6
3 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index e0a7552921..efa4abfa4d 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,10 @@
+* Fixed automatic maintaining test schema to properly handle sql structure
+ schema format.
+
+ Fixes #15394.
+
+ *Wojciech Wnętrzak*
+
* Pluck now works when selecting columns from different tables with the same
name.
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb
index 168b338b97..dedbbd3585 100644
--- a/activerecord/lib/active_record/tasks/database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/database_tasks.rb
@@ -161,10 +161,12 @@ module ActiveRecord
when :ruby
file ||= File.join(db_dir, "schema.rb")
check_schema_file(file)
+ purge(current_config)
load(file)
when :sql
file ||= File.join(db_dir, "structure.sql")
check_schema_file(file)
+ purge(current_config)
structure_load(current_config, file)
else
raise ArgumentError, "unknown format #{format.inspect}"
diff --git a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb
index 5688931db2..9ab64d0325 100644
--- a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb
@@ -21,7 +21,11 @@ module ActiveRecord
FileUtils.rm(file) if File.exist?(file)
end
- alias :purge :drop
+
+ def purge
+ drop
+ create
+ end
def charset
connection.encoding