aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-09-23 13:45:32 +0000
committerJamis Buck <jamis@37signals.com>2005-09-23 13:45:32 +0000
commit119855c438812fb60abc51d0ca6ab30f14713941 (patch)
treed3e11a4bdb429bb71399b7f99a72e919e3dcabf2
parent7dc45818dc43c163700efc9896a0f3feafa31138 (diff)
downloadrails-119855c438812fb60abc51d0ca6ab30f14713941.tar.gz
rails-119855c438812fb60abc51d0ca6ab30f14713941.tar.bz2
rails-119855c438812fb60abc51d0ca6ab30f14713941.zip
Add db_schema_dump and db_schema_import rake tasks to work with the new ActiveRecord::SchemaDumper (for dumping a schema to and reading a schema from a ruby file).
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2313 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/tasks/databases.rake16
2 files changed, 17 insertions, 1 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 05856bfea8..ed54849e69 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add db_schema_dump and db_schema_import rake tasks to work with the new ActiveRecord::SchemaDumper (for dumping a schema to and reading a schema from a ruby file).
+
* Reformed all the config/environments/* files to conform to the new Rails::Configuration approach. Fully backwards compatible.
* Added create_sessions_table, drop_sessions_table, and purge_sessions_table as rake tasks for databases that supports migrations (MySQL, PostgreSQL, SQLite) to get a table for use with CGI::Session::ActiveRecordStore
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index f8ae465315..e3177b2bdf 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -12,6 +12,20 @@ task :load_fixtures => :environment do
end
end
+desc "Create a db/schema.rb file that can be portably used against any DB supported by AR."
+task :db_schema_dump => :environment do
+ require 'active_record/schema_dumper'
+ File.open("db/schema.rb", "w") do |file|
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
+ end
+end
+
+desc "Import a schema.rb file into the database."
+task :db_schema_import => :environment do
+ file = ENV['SCHEMA'] || "db/schema.rb"
+ load file
+end
+
desc "Recreate the test databases from the development structure"
task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
abcs = ActiveRecord::Base.configurations
@@ -118,4 +132,4 @@ end
desc "Drop and recreate the session table (much faster than 'DELETE * FROM sessions')"
task :purge_sessions_table => [ :drop_sessions_table, :create_sessions_table ] do
-end \ No newline at end of file
+end