Abel,
In addition to Joe''s suggestions, you can also execute this MySQL
query from command line, or any other gui tool that allows you to
input direct queries:
TRUNCATE TABLE `my_table`;
As long as you don''t have foreign keys in a InnoDB table, this will
effectively drop and recreate the table for you, which is much faster
than deleting rows one-by-one as "DELETE FROM" would do.
"TRUNCATE
TABLE" also resets the auto_increment counter, which "DELETE
FROM"
doesn''t.
Unless I''m missing something, this is most likely the easiest way of
doing what you want; emptying a table. Re-running migrations seems
like overkill to me if you haven''t made any structural changes, and
it''s faster and more effective than a "DELETE FROM" query.
Regards,
Sebastian
On Nov 16, 8:55 am, "Joe McGlynn"
<j...-WSbigQczdccj0o55a+Ij8ljMPmZJtkid@public.gmane.org>
wrote:> There are a lot of ways...
>
> From the command line you can
> rake db:migrate VERSION=0
>
> and then re-run db:migrate without the version
>
> OR you can drop and re-create the database
>
> OR you can delete all of the records from each table (using delete from in
> sql)
>
> Joe
>
>
>
> -----Original Message-----
> From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>
> [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf
Of abel
> Sent: Sunday, November 15, 2009 12:48 PM
> To: Ruby on Rails: Talk
> Subject: [Rails] database reset
>
> Completely new to programming and ROR so please ignore my
> amateurishness ;)
>
> how do I reset a database to have no posts.
> am following a tutorial to make this app that allows to post entries
> sort of like blog posts.
> so how to i clear the database so that all the posts i did during the
> testing phase get erased?
> thanks
> abel.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=.