Dev database bootstrap

4 views
Skip to first unread message

theRocket

unread,
Aug 19, 2009, 3:04:41 AM8/19/09
to Racing on Rails
I would have posted this as a ticket on Trac, but that doesn't seem to
be working. Anyways, I think I know the solution, just wanted to run
it by the smart people (Scott).

Executing 'rake racing_on_rails:bootstrap' seems to be loading up db/
development_structure.sql, but there is a problem with the 'create
table' commands. They seem to be in alphabetical order, but there are
foreign key references that do not match that order. The MySQL error
bombs out the rake task.

I imported the file directly using my MySQL GUI of choice, Sequel Pro
(http://code.google.com/p/sequel-pro/). It gives the error code as
150, which fingered the foreign key constraint. However, several
tables were imported anyways. This gave me a hint that as long as the
table referenced exists already, the import could work.

So I went with the brute force approach -- I imported the
development_structure.sql FOUR TIMES until the only errors remaining
were about tables already existing and duplicate values.

It works, but I wonder if the 'create table' commands just need to be
ordered so the foreign key references appear after the creation of the
referenced table? Then the rake task might work.

RyanR>

Scott Willson

unread,
Aug 19, 2009, 3:03:36 PM8/19/09
to racing-...@googlegroups.com
Sorry about the Trac hiccup. I was getting Trac Wiki spam :(. You
should be able to create tickets, though … do you mind shooting me an
email with what (didn't) happen?

Bummer about the bootstrap. For sure, it's intended to work with a
fresh git clone, and not with "local." And I have to admit to not
testing it much.

For sure, if you're recreating a DB, it's best to drop it completely
first.

On the foreign keys: you're right, there's a dependency issue. Rails
and MySQL are smart enough to handle it. Try "SET
FOREIGN_KEY_CHECKS=0" before importing development_structure.sql, and
"SET FOREIGN_KEY_CHECKS=1" after. That's the bootstrap task does.

Scott
Reply all
Reply to author
Forward
0 new messages