Skip to content

Instantly share code, notes, and snippets.

@benjie
Created December 12, 2017 15:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjie/fdb9a01171a8bad85cafb2c08f2b035a to your computer and use it in GitHub Desktop.
Save benjie/fdb9a01171a8bad85cafb2c08f2b035a to your computer and use it in GitHub Desktop.
# Ensure all foreign key constraints heve 'ON DELETE' clauses
grep 'FOREIGN KEY.* REFERENCES .*' db/schema.sql | grep -v ' ON DELETE '
if [ "$?" == "0" ]; then
echo "Foreign key constraints without delete instructions - aborting"
exit 2;
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment