Isn’t a database just a spreadsheet? No?! Oh man!
A database makes a website a web application…don’t take this power lightly. How do I interact with the data? How do I get this data to interact with that other data? Why is it so hard to access the frickin’ data?! Wait, what happened to all my data? There is much to learn, to remember, and to respect about working with databases.

Drop and recreate a rails database

08/31/17  Public, Databases

This will destroy your db and then create it and then migrate your current schema:


1 vote - harrylevine

Debugging & learning SQL in the rails console

11/19/15  Public, Databases, Troubleshooting, Other Languages

Sometimes examining the SQL generated by ActiveRecord query and finder methods can be useful in debugging and learning SQL. Rails' ActiveRecord provides the to_sql method to make this easy.

Open up the rails console with rails c or `rails c...

2 votes - eliotsykes

Adding a unique constraint to a Postgres database column

08/11/15  Public, Databases

1 vote - harrylevine

Command to access your Rails sqlite3 database from the command line

03/28/15  Public, Databases

$ sqlite3 db/development.sqlite3

Run .tables to get a list of database tables, to confirm you are in the right place

Then run .help for list of available commands

Reference site:

1 vote - harrylevine

Summary of rake database migration commands in development

11/16/14  Public, Command Line, Databases

$ rake db:migrate
$ rake db:migrate VERSION=0 --> Removes all migrations, resetting back to ground zero
$ rake db:migrate VERSION=20141013165213 --> Migrates back down to the specific named migration
$ rake db:migrate:status --> *P...

3 votes - plawler