diff --git a/db/new.sh b/db/new.sh new file mode 100755 index 0000000..8810eb0 --- /dev/null +++ b/db/new.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +timestamp=$(date +%Y%m%d%H%M%S) + +printf "rules:\n" +printf " * use hyphens to separate words (not spaces, not underscores)\n" +printf " * keep it as short as possible (add comments inside the file)\n" +printf " * try to keep each migration idempotent (roughly, the order of application shouldn't matter)\n" +printf "\n" +printf "good example: 20180416164303-init-schema.sql\n\n" +printf "filename: %s-" "${timestamp}" +read filename + +filename="${timestamp}-${filename}" +if [[ ! $filename =~ .sql$ ]]; then + filename="${filename}.sql" +fi + +touch "${filename}" +echo "created ${filename}"