From 99c3003ba87e2ff3a54903004a335398573996ea Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Wed, 25 Oct 2017 10:05:29 -0500 Subject: [PATCH] Add instructions for creating the database and the initial table --- README.md | 13 +++++++++++++ migrations/1508943247_create_blocks_table.down.sql | 1 + migrations/1508943247_create_blocks_table.up.sql | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 migrations/1508943247_create_blocks_table.down.sql create mode 100644 migrations/1508943247_create_blocks_table.up.sql diff --git a/README.md b/README.md index f6464bcf..3f169743 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ ### Dependencies - Go 1.9+ + - https://github.com/golang/dep + - Postgres 10 ### Cloning the Repository @@ -18,6 +20,17 @@ - This will take a while and gives poor indication of progress. 4. `go install github.com/ethereum/go-ethereum/cmd/geth` +### Setting up the Development Database + +1. Install Postgres +2. Create a superuser for yourself and make sure `psql --list` works without prompting for a password. +3. `go get -u -d github.com/mattes/migrate/cli github.com/lib/pq` +4. `go build -tags 'postgres' -o /usr/local/bin/migrate github.com/mattes/migrate/cli` +5. `createdb vulcanize` +6. `migrate -database 'postgresql://localhost:5432/vulcanize?sslmode=disable' -path ./migrations up` + +Adding a new migration: `migrate -database postgresql://localhost:5432/postgres create -dir ./migrations -ext sql ` + ### Creating/Using a Private Blockchain Syncing the public blockchain takes many hours for the initial sync and will download 20+ GB of data. diff --git a/migrations/1508943247_create_blocks_table.down.sql b/migrations/1508943247_create_blocks_table.down.sql new file mode 100644 index 00000000..8ea49617 --- /dev/null +++ b/migrations/1508943247_create_blocks_table.down.sql @@ -0,0 +1 @@ +DROP TABLE public.blocks diff --git a/migrations/1508943247_create_blocks_table.up.sql b/migrations/1508943247_create_blocks_table.up.sql new file mode 100644 index 00000000..398bc2c7 --- /dev/null +++ b/migrations/1508943247_create_blocks_table.up.sql @@ -0,0 +1,4 @@ +CREATE TABLE public.blocks +( + block_number BIGINT +)