How to drop table and recreate the table using migrate

I did something wrong during first migration. I would like to drop the
table and call migration again to re-create the table. but don’t know
the appropriate way to do it.

any idea?

Yan wrote:

I did something wrong during first migration. I would like to drop the
table and call migration again to re-create the table. but don’t know
the appropriate way to do it.

Get into the database (maybe mysql -u root), drop the database, and
recreate it.


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

rake db:migrate VERSION=0
rake db:migrate

good luck!
Tim

unknown wrote:

rake db:migrate VERSION=0
rake db:migrate

good luck!
Tim

It doesn’t work. I don’t know why. It seems I have to go to mysql to
drop the entire database.

rake db:migrate VERSION=0
rake db:migrate

It doesn’t work. I don’t know why. It seems I have to go to mysql to
drop the entire database.

If something unexpected happens, the rake migrate task will leave it
up to you to clean up manually. It’s not smart enough to recover from
the many different things that can go wrong.

You can run your migrations first as

rake db:migrate --dry-run --trace

That’ll catch some possible errors before running the migration for
real.

rake db:migrate VERSION=0
rake db:migrate

Yan wrote:

It doesn’t work.

It probably requires effective self.down methods. I suspect that
some people slack off on those. Not me, of course!


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

Jim L. wrote:

rake db:migrate VERSION=0
rake db:migrate

It doesn’t work. I don’t know why. It seems I have to go to mysql to
drop the entire database.

If something unexpected happens, the rake migrate task will leave it
up to you to clean up manually. It’s not smart enough to recover from
the many different things that can go wrong.

You can run your migrations first as

rake db:migrate --dry-run --trace

That’ll catch some possible errors before running the migration for
real.

Below is waht I got:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute (dry run) environment
** Execute (dry run) db:migrate

On Jan 30, 7:40 am, “Jim L.” [email protected] wrote:

rake db:migrate VERSION=0
rake db:migrate

It doesn’t work. I don’t know why. It seems I have to go to mysql to
drop the entire database.If something unexpected happens, the rake migrate task will leave it
up to you to clean up manually. It’s not smart enough to recover from
the many different things that can go wrong.

Yeah - that’s a bit of an issue if you don’t capture the correct steps
to migrate back down.
Personally, I check I can migrate up and back down each step of the
way (unless data is being destroyed in the migration, which make them
very scary).

You can run your migrations first as

rake db:migrate --dry-run --trace

That’ll catch some possible errors before running the migration for real.

Nice tip.

I would also recommend looking at “:force=>true” whenever you are
creating a new table.