Does rake db:schema:load need the whole environment?

12 views
Skip to first unread message

brianp

unread,
Oct 28, 2013, 7:53:03 PM10/28/13
to rubyonra...@googlegroups.com
I ran into a "chicken before the egg" problem where a gem was expecting the tables to be present when loaded which was fine until you try and build the db from scratch using db:setup. When it hits db:schema:load the environment loads and the gem errors out as the tables aren't present. I made a custom task that connected to ActiveRecord and then loads the schema file. Using essentially the same methods as db:create uses to create the db and schema:load uses to load the schema. This seems to work without problems.

Is there a reason the environment is normally loaded for this task? Just wondering If I'm missing something that'll kick me in the ass later.

I read and followed some issues about it: https://github.com/rails/rails/issues/4772
but they don't say why they decided to load or not load the env at the time.

Cheers,
Brian
Reply all
Reply to author
Forward
0 new messages