Forum: Ruby on Rails PostgreSQL CASCADE not copied to test db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jim M. (Guest)
on 2006-02-24 01:17
(Received via mailing list)
When the unit test harness creates a test database from the
development database, the ON DELETE CASCADE constraints I have on my
foreign keys are not copied into the test database. (I can tell by
looking at db/development_structure.sql.)

That means the fixtures can't load/unload from the test database
properly. In other words, all my tests fail with the same error
message:

ActiveRecord::StatementInvalid: PGError: ERROR:  update or delete on
"orders" violates foreign key constraint
"redeemed_coupons_order_id_fkey" on "redeemed_coupons"
DETAIL:  Key (id)=(1) is still referenced from table "redeemed_coupons".

Is this a bug or intended behavior? If it is intended behavior, then
what am I doing wrong?

Thanks for your help.

Jim
--
Jim M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
http://www.io.com/~jimm
Jim M. (Guest)
on 2006-02-24 06:02
(Received via mailing list)
On 2/23/06, Jim M. <removed_email_address@domain.invalid> wrote:
> When the unit test harness creates a test database from the
> development database, the ON DELETE CASCADE constraints I have on my
> foreign keys are not copied into the test database. (I can tell by
> looking at db/development_structure.sql.)

Never mind; I was wrong. Some combination of deleting
db/development_structure.sql and recreating my development or test
databases fixed the problem. The ON DELETE CASCADE constraints are
indeed inside db/development_structure.sql and are copied.

Sorry about coming to the list with this problem. I spent hours trying
to figure out why I was getting the error message in the original
post. Sigh.

Jim
--
Jim M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
http://www.io.com/~jimm
This topic is locked and can not be replied to.