PostgreSQL CASCADE not copied to test db

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., [email protected], [email protected]
http://www.io.com/~jimm

On 2/23/06, Jim M. [email protected] 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., [email protected], [email protected]
http://www.io.com/~jimm