Skip to content

Instantly share code, notes, and snippets.

@hadrienblanc
Created April 30, 2024 20:09
Show Gist options
  • Save hadrienblanc/3fc4d3254029865e5b5ec22805251e9f to your computer and use it in GitHub Desktop.
Save hadrienblanc/3fc4d3254029865e5b5ec22805251e9f to your computer and use it in GitHub Desktop.
if ok :
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;
$$;
@hadrienblanc
Copy link
Author

https://www.davidko.ca/articles/debugging-activerecord-fixture-associations

note : ActiveRecord::Base.logger = Logger.new(STDOUT)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment