From e25a9753b4300bffaac7efa3756ebedeb8af9a90 Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Fri, 27 Oct 2017 14:18:12 -0500 Subject: [PATCH] Add scripts to help with migrations --- README.md | 4 ++-- scripts/create_migration | 9 +++++++++ scripts/migrate | 3 +++ scripts/rollback | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 scripts/create_migration create mode 100755 scripts/migrate create mode 100755 scripts/rollback diff --git a/README.md b/README.md index d39f2cce..07549e74 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ 4. `go build -tags 'postgres' -o /usr/local/bin/migrate github.com/mattes/migrate/cli` 5. `createdb vulcanize` 6. `cd $GOPATH/src/github.com/8thlight/vulcanizedb` -7. `migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations up` +7. `./scripts/migrate` -Adding a new migration: `migrate -database postgresql://localhost:5432/postgres create -dir ./migrations -ext sql ` +Adding a new migration: `./scripts/create_migration ` ### Creating/Using a Private Blockchain diff --git a/scripts/create_migration b/scripts/create_migration new file mode 100755 index 00000000..5a8d66a9 --- /dev/null +++ b/scripts/create_migration @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ $# -eq 1 ] +then + migrate -database postgresql://localhost:5432/postgres create -dir ./migrations -ext sql $1 +else + echo "**An Error Occurred**" + echo "Usage: ./scripts/create_migration " +fi diff --git a/scripts/migrate b/scripts/migrate new file mode 100755 index 00000000..34826ab0 --- /dev/null +++ b/scripts/migrate @@ -0,0 +1,3 @@ +#!/bin/bash +migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations up +./scripts/dump_schema diff --git a/scripts/rollback b/scripts/rollback new file mode 100755 index 00000000..85b6656d --- /dev/null +++ b/scripts/rollback @@ -0,0 +1,3 @@ +#!/bin/bash +migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations down 1 +./scripts/dump_schema