database reset

Completely new to programming and ROR so please ignore my amateurishness :wink:

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.

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

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