(No, not that elephant.)
At some point in the last few weeks, I added this card to my Trello task-tracker:
All new Rails apps in postgres
And then I did nothing about it until I was trying to do something else and couldn’t get a program to load because of, oh yeah, postgres. Time to deal with that, I guess!
There are three popular options for running a Structured Query Language (SQL)–based database on Rails: MySQL (owned by Oracle), sqlite3 (comes built-in with new Rails apps), and PostgresQL… the one with the elephant that’s OK to run on Heroku.
I’ve been using the Rails built-in database mostly, switching over to Postgres for production on Heroku, but it’s a best practice to use the same database for your testing, development and production environments. I can’t really speak to the differences between the three except that my perception is that MySQL is widely hated and Postgres always takes some flailing around on my part to get it to start.
$ rake db:create $ rake db:migrate $ rake db:reset $ rake db:hello_is_anyone_listening
So I was excited to take on a project refactor this week built on Mongo DB, a no-SQL database. Rather than using Active Record and data migrations (hello, hello, is this thing on), Mongo stores database table information directly in the model records where they’re easy to add, delete, or change.
Hooray no migrations! Hooray another tool in my toolchest!
That bit of learning curve did not last long as we realized that what we want to build requires relational associations that a SQL-less database isn’t optimized to handle. I felt a bit sad about not getting to play with a new toy until I ran into this:
I’ve run into this “master-slave” business before in software and my response was a big “wtf” followed by an “I’m not using this.” And so far, I haven’t had to, since there have thus far been alternatives.
So over to Postgres we go! Commere you big lovable elephant. Give mama a slobber. I shall add to my box of tricks “converted an app from a no-SQL database to Postgres” and all shall be well.
- Here is a great (long) article by a programmer I admire titled Why you should never use Mongo DB. This is the type of technical writing to which I aspire.
- A cloud data storage option I am really excited about: The Art Guys Heads in a Cloud Data Storage Memory Services (I miss you, Houston!)
- Ok FINE here is A Young Woman’s Etiquette Guide to Coding but I have to say I am annoyed to the point of dismissal that Black Girls Code (a great organization) is listed here with the byline “powered by American Express.” Probably the author meant to say “powerful black girls and women.” Yes, that’s more like it. That downer aside, some good information here.