Merge pull request #29 from 8thlight/add-migrate-script

Add scripts to help with migrations
This commit is contained in:
ericmeyer 2017-10-27 15:19:36 -05:00 committed by GitHub
commit 66ac0728a6
4 changed files with 17 additions and 2 deletions

View File

@ -30,9 +30,9 @@
4. `go build -tags 'postgres' -o /usr/local/bin/migrate github.com/mattes/migrate/cli` 4. `go build -tags 'postgres' -o /usr/local/bin/migrate github.com/mattes/migrate/cli`
5. `createdb vulcanize` 5. `createdb vulcanize`
6. `cd $GOPATH/src/github.com/8thlight/vulcanizedb` 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 <migration-name>` Adding a new migration: `./scripts/create_migration <migration-name>`
### Creating/Using a Private Blockchain ### Creating/Using a Private Blockchain

9
scripts/create_migration Executable file
View File

@ -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 <migration-name>"
fi

3
scripts/migrate Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations up
./scripts/dump_schema

3
scripts/rollback Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations down 1
./scripts/dump_schema