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.
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.