Skip to content

Instantly share code, notes, and snippets.

@nilbus
Last active February 19, 2020 16:45
Show Gist options
  • Save nilbus/dffbb5ad3e4ba69e5096716622d5e237 to your computer and use it in GitHub Desktop.
Save nilbus/dffbb5ad3e4ba69e5096716622d5e237 to your computer and use it in GitHub Desktop.
Count the number of migrations per repo that modify existing schema structure
# make a temp directory for each repo to examine
mkdir doximity doc-news activities
# copy in migrations from 2019
for dir in *; do cp ~/work/$dir/db/migrate/2019* $dir/; done
# remove migration reversal code to exclude from search
sed -i'' -re '/def down/,$d' */*
# count unique migration files per repo that modify existing schema structure (tables, columns)
# depends on ag silver searcher but could be modified to use grep
ag -l -i '(remove|drop|rename|alter|change)[ _](?!(foreign_key|index|column_(null|default)))' |cut -d/ -f1 |sort |uniq -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment