aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorWojciech Wnętrzak <w.wnetrzak@gmail.com>2014-06-01 17:41:04 +0200
committerWojciech Wnętrzak <w.wnetrzak@gmail.com>2014-06-12 13:08:56 +0200
commitad42aaed04a6098732105c12c853bc912ee5cadd (patch)
treef5c0e595888cb97038ed5b3804f3fca5c1eb64bf /activerecord
parentdf6dc1b51a95947f26e35edda9005f0b2a2e7df7 (diff)
downloadrails-ad42aaed04a6098732105c12c853bc912ee5cadd.tar.gz
rails-ad42aaed04a6098732105c12c853bc912ee5cadd.tar.bz2
rails-ad42aaed04a6098732105c12c853bc912ee5cadd.zip
Fixed automatic maintaining test schema to properly handle sql structure schema format.
Additionally: * It changes `purge` task on `sqlite3` adapter to recreate database file, to be consistent with other adapters. * Adds `purge` step when loading from `schema.rb`
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md5
-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, 12 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 078d63f8f2..9a5d27ef92 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Fixed automatic maintaining test schema to properly handle sql structure
+ schema format. Fixes #15394.
+
+ *Wojciech Wnętrzak*
+
* PostgreSQL support default values for enum types. Fixes #7814.
*Yves Senn*
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