From bb56df12bd36f136c7ab5fbe8b7abacadd4de50f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 9 Nov 2018 03:18:20 +0100 Subject: .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. --- license-generator/.env.sample | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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/ +} -- cgit v1.2.3