AdamT
AdamT

Reputation: 6485

Roll back all rails migrations or drop tables and modify migrations (start from scratch)

I'm new to Rails and have started a project that I'm unhappy with my models and db schema.

I'd like to start again from scratch but keep all my views, controllers.

What's the best way to go about doing this?

I want to remove all my migrations and all my models. There should be no irrelevant files left after this process (like migrations that are no longer in use).

If it helps, I'm using Rails 3.1

Thanks!

Upvotes: 17

Views: 19525

Answers (2)

Sean Hill
Sean Hill

Reputation: 15056

First, rollback your migrations to version 0.

rake db:migrate VERSION=0

Then you manually delete your migrations and models, leaving the controllers and views intact.

Upvotes: 48

Alex Peattie
Alex Peattie

Reputation: 27697

Just delete all files in app/models and db/migrate then run:

rake db:reset

Upvotes: 16

Related Questions