Awais
Awais

Reputation: 1811

Roll back a specific migration without rolling back other migrations

I mistakenly ran the second to last db migration wrong, but the last migration is fine. Now I want to roll back my second to last migration without reverting the last migration. Please share your knowledge with me and others.

Upvotes: 10

Views: 3763

Answers (4)

Awais
Awais

Reputation: 1811

simple answer i found is

rake db:rollback STEP=X 

where X is the number of migration you want to play with(rollback). LIKE

rake db:rollback STEP=3

Upvotes: 2

Pavan
Pavan

Reputation: 33542

You can specify your Migration file version number to rollback that Migration.

You can achieve it by either of these

rake db:migrate:down VERSION=your_file_version

OR

rake db:rollback:up VERSION=your_file_version

Upvotes: 2

Santhosh
Santhosh

Reputation: 29094

rake db:migrate:down VERSION=20140804301246

Upvotes: 8

Wit Wikky
Wit Wikky

Reputation: 1542

You can use rake db:migrate:down VERSION=xxxxx where xxx is your migration version number for more see this

Upvotes: 16

Related Questions