I\'m trying to push a brand new Ruby on Rails app to Heroku. Currently, it sits on MySQL. It looks like Heroku doesn\'t really support MySQL and so we are considering using
Common issues:
char(n)
column unless your server is in strict mode, PostgreSQL will complain and make you truncate your string yourself.(1) will be an issue if you use AR's group
method in any of your queries or GROUP BY in any raw SQL. Do some searching for column "X" must appear in the GROUP BY clause or be used in an aggregate function
and you'll see some examples and common solutions.
(2) will be an issue if you use string columns anywhere in your application and your models aren't properly validating the length of all incoming string values. Note that creating a string column in Rails without specifying a limit actually creates a varchar(255)
column so there actually is an implicit :limit => 255
even though you didn't specify one. An alternative is to use t.text
for your strings instead of t.string
; this will let you work with arbitrarily large strings without penalty (for PostgreSQL at least). As Erwin notes below (and every other chance he gets), varchar(n)
is a bit of an anachronism in the PostgreSQL world.
(3) shouldn't be a problem unless you have raw SQL in your code.
(4) will be an issue if you're using LIKE anywhere in your application. You can fix this one by changing a like b
to lower(a) like lower(b)
(or upper(a) like upper(b)
if you like to shout) or a ilike b
but be aware that PostgreSQL's ILIKE is non-standard.
There are other differences that can cause trouble but those seem like the most common issues.
You'll have to review a few things to feel safe:
group
calls.where
calls).