aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-09 03:18:20 +0100
committerTeddy Wing2018-11-09 03:35:35 +0100
commitbb56df12bd36f136c7ab5fbe8b7abacadd4de50f (patch)
treea7ca6eff4f9c99ee2cc3b627ace578c491fa8cf8
parentd3fa3ce3712e6a46b1e9d1a2f3c8ac0ca6d5e25b (diff)
downloaddome-key-web-bb56df12bd36f136c7ab5fbe8b7abacadd4de50f.tar.bz2
.env.sample: Add `migrate` function
Wraps the `migrate` command (https://github.com/golang-migrate/migrate). The command requires you to pass in a bunch of shell options that should be constant for an application. Encode those constants in this wrapper function. Now all you need to do is run: $ migrate migration_name and the correct migrations will be generated. The migrations get created in the current directory. I tried passing -source file://migrations , -source file://./migrations , and -path migrations but no combination seemed to put the generated migration files in the migrations/ directory. Settled on moving the files manually in the helper function.
-rw-r--r--license-generator/.env.sample14
1 files changed, 14 insertions, 0 deletions
diff --git a/license-generator/.env.sample b/license-generator/.env.sample
index 7ed6243..325a279 100644
--- a/license-generator/.env.sample
+++ b/license-generator/.env.sample
@@ -1,3 +1,17 @@
export DATABASE_NAME=""
export DATABASE_USER=""
export DATABASE_PASSWORD=""
+
+
+function migrate () {
+ local migration_name="$1"
+
+ command migrate \
+ -database 'mysql://localhost:3306/dome_key' \
+ create \
+ -ext sql \
+ -format '20060102150405' \
+ "$migration_name"
+
+ mv *.sql migrations/
+}