db: add script to create new migration files
This commit is contained in:
parent
bceb959488
commit
5652afa6d5
20
db/new.sh
Executable file
20
db/new.sh
Executable file
@ -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}"
|
Loading…
Reference in New Issue
Block a user