From 5652afa6d5ea778a2a1a42cdc0019e8e329ed0db Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Mon, 16 Apr 2018 22:31:59 +0530 Subject: [PATCH] db: add script to create new migration files --- db/new.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 db/new.sh 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}"