Rails 2.0 DB create/drop tasks

Posted by Tejus Parikh on February 14, 2008

It’s impossible to get a database model right the first time. Often, you end up with a db with a half-finished, garbage schema. Hibernate makes this more tolerable, if you set the hibernate.hbm2ddl.auto flag to create it will just wipe the DB when your container restarts.

Until 2.0, Rails didn’t have something similar and I either had to manually drop/create the DB, or hope that rake db:migrate VERSION=0 did what I needed. Thankfully, Rails 2.0 offers the perfect set of rake tasks:
rake db:create and rake db:drop. Just another way the Rails team alleviates some of the pain of web development.

Tejus Parikh

I'm a software engineer that writes occasionally about building software, software culture, and tech adjacent hobbies. If you want to get in touch, send me an email at [my_first_name]@tejusparikh.com.