Created
April 30, 2024 20:09
-
-
Save hadrienblanc/3fc4d3254029865e5b5ec22805251e9f to your computer and use it in GitHub Desktop.
if ok :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do $$ | |
declare r record; | |
BEGIN | |
FOR r IN ( | |
SELECT FORMAT( | |
'UPDATE pg_constraint SET convalidated=false WHERE conname = ''%I'' AND connamespace::regnamespace = ''%I''::regnamespace; ALTER TABLE %I.%I VALIDATE CONSTRAINT %I;', | |
constraint_name, | |
table_schema, | |
table_schema, | |
table_name, | |
constraint_name | |
) AS constraint_check | |
FROM information_schema.table_constraints WHERE constraint_type = 'FOREIGN KEY' | |
) | |
LOOP | |
EXECUTE (r.constraint_check); | |
END LOOP; | |
END; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.davidko.ca/articles/debugging-activerecord-fixture-associations
note : ActiveRecord::Base.logger = Logger.new(STDOUT)