aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2011-12-09 20:53:55 +0100
committerPiotr Sarnacki <drogus@gmail.com>2011-12-09 22:00:51 +0100
commit35a1744a45501fe79660ba11fbee35a7bf099bce (patch)
tree4aabbe1efd034f5f019f7ee6f99e3455e984aad9 /activerecord
parentf0b782d060f76647e36adc40fe5fe818ec8e2c66 (diff)
downloadrails-35a1744a45501fe79660ba11fbee35a7bf099bce.tar.gz
rails-35a1744a45501fe79660ba11fbee35a7bf099bce.tar.bz2
rails-35a1744a45501fe79660ba11fbee35a7bf099bce.zip
Allow to run migrations with given scope, with SCOPE=<scope>
Scope in migrations can be defined by adding suffix in filename, like: 01_a_migration.blog.rb. Such migration have blog scope. Scope is automatically added while copying migrations from engine, so if you want to revert all of the migrations from given engine, you can just run db:migrate with SCOPE, like: rake db:migrate SCOPE=blog
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md12
-rw-r--r--activerecord/lib/active_record/railties/databases.rake4
2 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 888bc43ec9..268799b4b3 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,17 @@
## Rails 3.2.0 (unreleased) ##
+* Added ability to run migrations only for given scope, which allows
+ to run migrations only from one engine (for example to revert changes
+ from engine that you want to remove).
+
+ Example:
+ rake db:migrate SCOPE=blog
+
+ *Piotr Sarnacki*
+
+* Migrations copied from engines are now scoped with engine's name,
+ for example 01_create_posts.blog.rb. *Piotr Sarnacki*
+
* Implements `AR::Base.silence_auto_explain`. This method allows the user to
selectively disable automatic EXPLAINs within a block. *fxn*
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index abd71793fd..0aafb5184f 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -149,7 +149,9 @@ db_namespace = namespace :db do
desc "Migrate the database (options: VERSION=x, VERBOSE=false)."
task :migrate => [:environment, :load_config] do
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
+ ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
+ ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
+ end
db_namespace['_dump'].invoke
end