From eb853940d1aa5c92359b8d9fbc79142a03e9d238 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 1 Oct 2012 20:49:04 -0400 Subject: instructions for running migrations in another ENV --- guides/source/migrations.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'guides/source/migrations.md') diff --git a/guides/source/migrations.md b/guides/source/migrations.md index ccbdffc9c7..2d633175d1 100644 --- a/guides/source/migrations.md +++ b/guides/source/migrations.md @@ -544,7 +544,7 @@ support](#active-record-and-referential-integrity). If the helpers provided by Active Record aren't enough you can use the `execute` method to execute arbitrary SQL. -For more details and examples of individual methods, check the API documentation. +For more details and examples of individual methods, check the API documentation. In particular the documentation for [`ActiveRecord::ConnectionAdapters::SchemaStatements`](http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html) (which provides the methods available in the `up` and `down` methods), @@ -700,6 +700,14 @@ will run the `up` method from the 20080906120000 migration. This task will first check whether the migration is already performed and will do nothing if Active Record believes that it has already been run. +### Running Migrations in Different Environments + +By default running `rake db:migrate` will run in the `development` environment. To run migrations against another environment you can specify it using the `RAILS_ENV` environment variable while running the command. For example to run migrations against the `test` environment you could run: + +```bash +$ rake db:migrate RAILS_ENV=test +``` + ### Changing the Output of Running Migrations By default migrations tell you exactly what they're doing and how long it took. -- cgit v1.2.3