[factory_girl] factory_girl breaks db:migrate Rake task on clean instance of DB

279 views
Skip to first unread message

Jared Luxenberg

unread,
May 18, 2010, 12:28:40 PM5/18/10
to factory_girl
If I delete my development database and try to restore its schema
using migrations, factory_girl loads as part of the migration process
before any migrations are run. It tries to use one of my ActiveRecord
objects before the tables in the database are created by my
migrations, causing an error like this (when using Postgres):

rake aborted!
PGError: ERROR: relation "licenses" does not exist
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"licenses"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum


Any thoughts on why factory_girl is attempting to load itself before
my migrations run?

--
Individuals over processes. Interactions over tools. Agile Rails training from thoughtbot, the makers of Clearance, Shoulda, & Factory Girl:
http://thoughtbot.com/services/training

You received this message because you are subscribed to the "factory_girl" mailing list.
To post to this group, send email to factor...@googlegroups.com
To unsubscribe from this group, send email to
factory_girl...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/factory_girl?hl=en

Jared Luxenberg

unread,
May 18, 2010, 12:55:29 PM5/18/10
to factory_girl
My mistake, I was using Factory directly in my define block, like this:
Factory.define :foo do |f|
f.bar Factory(:widget, :property => "baz")
end

rather than thunking the call to Factory with a block like this:
Factory.define :foo do |f|
f.bar do Factory(:widget, :property => "baz") end
end

- Jared
Reply all
Reply to author
Forward
0 new messages