1

I am using PgTap to unit test a Postgres (v9.4) database structure in a continuous migration process. It works great.

Here is my question: « Is there a way to control that a foreign key constraint is deferrable (initially immediate) ? »

I do already check foreign keys but I want to ensure some of them are deferrable.

Thank you for your help.

1

Ok, it appears there are no methods to test such thing with PgTap for now so I ended up with

SELECT results_eq(
    $$select condeferrable, condeferred from pg_catalog.pg_constraint where conname = 'default_article_id_fk'$$,
    $$values ('t'::bool, 'f'::bool)$$,
    '"default_article_id_fk" is deferrable initially immediate.'
);

That does the job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.