aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-09 04:46:00 +0100
committerTeddy Wing2018-11-09 04:46:00 +0100
commit0f8ab2e4cbac41d88a51b88b841b84406439a270 (patch)
tree50606f359b877c580684ca4647f23211c3af397a
parentbb56df12bd36f136c7ab5fbe8b7abacadd4de50f (diff)
downloaddome-key-web-0f8ab2e4cbac41d88a51b88b841b84406439a270.tar.bz2
.env.sample: Add `migrate` wrapper functions
Wrap all `migrate` subcommands. Turns out we do need the `-path` argument for the other commands. Doesn't appear to work correctly for `create`, but for the others it works fine.
-rw-r--r--license-generator/.env.sample63
1 files changed, 60 insertions, 3 deletions
diff --git a/license-generator/.env.sample b/license-generator/.env.sample
index 325a279..14866f0 100644
--- a/license-generator/.env.sample
+++ b/license-generator/.env.sample
@@ -2,12 +2,15 @@ export DATABASE_NAME=""
export DATABASE_USER=""
export DATABASE_PASSWORD=""
+export DATABASE_URL="mysql://tcp(localhost:3306)/dome_key"
-function migrate () {
+
+function migrate-create () {
local migration_name="$1"
- command migrate \
- -database 'mysql://localhost:3306/dome_key' \
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
create \
-ext sql \
-format '20060102150405' \
@@ -15,3 +18,57 @@ function migrate () {
mv *.sql migrations/
}
+
+function migrate-goto () {
+ local version="$1"
+
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
+ goto \
+ "$version"
+}
+
+function migrate-up () {
+ local count="$1"
+
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
+ up \
+ "$count"
+}
+
+function migrate-down () {
+ local count="$1"
+
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
+ down \
+ "$count"
+}
+
+function migrate-drop () {
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
+ drop
+}
+
+function migrate-force () {
+ local version="$1"
+
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
+ force \
+ "$version"
+}
+
+function migrate-version () {
+ migrate \
+ -path migrations \
+ -database "$DATABASE_URL" \
+ version
+}