From 09ea8235b6c2f42080710d41485116b9eb93afee Mon Sep 17 00:00:00 2001 From: Eric Meyer Date: Mon, 30 Oct 2017 14:39:00 -0500 Subject: [PATCH] Add primary key column for blocks table --- integration_test/geth_blockchain_test.go | 7 ++-- ...9391861_add_primary_key_to_blocks.down.sql | 1 + ...509391861_add_primary_key_to_blocks.up.sql | 1 + migrations/schema.sql | 38 ++++++++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 migrations/1509391861_add_primary_key_to_blocks.down.sql create mode 100644 migrations/1509391861_add_primary_key_to_blocks.up.sql diff --git a/integration_test/geth_blockchain_test.go b/integration_test/geth_blockchain_test.go index 4109ccd1..e308e8c0 100644 --- a/integration_test/geth_blockchain_test.go +++ b/integration_test/geth_blockchain_test.go @@ -2,13 +2,14 @@ package integration_test import ( "fmt" - "github.com/8thlight/vulcanizedb/core" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" "math/big" "path" "path/filepath" "runtime" + + "github.com/8thlight/vulcanizedb/core" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) var ( diff --git a/migrations/1509391861_add_primary_key_to_blocks.down.sql b/migrations/1509391861_add_primary_key_to_blocks.down.sql new file mode 100644 index 00000000..8840f9d2 --- /dev/null +++ b/migrations/1509391861_add_primary_key_to_blocks.down.sql @@ -0,0 +1 @@ +ALTER TABLE blocks DROP id \ No newline at end of file diff --git a/migrations/1509391861_add_primary_key_to_blocks.up.sql b/migrations/1509391861_add_primary_key_to_blocks.up.sql new file mode 100644 index 00000000..e2b68955 --- /dev/null +++ b/migrations/1509391861_add_primary_key_to_blocks.up.sql @@ -0,0 +1 @@ +ALTER TABLE blocks ADD COLUMN id SERIAL PRIMARY KEY \ No newline at end of file diff --git a/migrations/schema.sql b/migrations/schema.sql index bc17a417..ae617c5b 100644 --- a/migrations/schema.sql +++ b/migrations/schema.sql @@ -42,10 +42,31 @@ CREATE TABLE blocks ( block_number bigint, block_gaslimit double precision, block_gasused double precision, - block_time double precision + block_time double precision, + id integer NOT NULL ); +-- +-- Name: blocks_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE blocks_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: blocks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE blocks_id_seq OWNED BY blocks.id; + + -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- @@ -56,6 +77,21 @@ CREATE TABLE schema_migrations ( ); +-- +-- Name: blocks id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY blocks ALTER COLUMN id SET DEFAULT nextval('blocks_id_seq'::regclass); + + +-- +-- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY blocks + ADD CONSTRAINT blocks_pkey PRIMARY KEY (id); + + -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - --