Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #48 from vulcanize/consolidate-migrations
Browse files Browse the repository at this point in the history
Consolidate migrations
  • Loading branch information
rmulhol authored Mar 28, 2019
2 parents 4941b64 + 723cf27 commit 6fe32c3
Show file tree
Hide file tree
Showing 48 changed files with 98 additions and 404 deletions.
22 changes: 18 additions & 4 deletions db/migrations/00001_create_blocks_table.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
-- +goose Up
CREATE TABLE public.blocks
(
block_number BIGINT
CREATE TABLE public.blocks (
id SERIAL PRIMARY KEY,
difficulty BIGINT,
extra_data VARCHAR,
gaslimit BIGINT,
gasused BIGINT,
hash VARCHAR(66),
miner VARCHAR(42),
nonce VARCHAR(20),
"number" BIGINT,
parenthash VARCHAR(66),
reward DOUBLE PRECISION,
uncles_reward DOUBLE PRECISION,
"size" VARCHAR,
"time" BIGINT,
is_final BOOLEAN,
uncle_hash VARCHAR(66)
);


-- +goose Down
DROP TABLE public.blocks;
DROP TABLE public.blocks;
13 changes: 0 additions & 13 deletions db/migrations/00002_add_columns_to_blocks.sql

This file was deleted.

16 changes: 16 additions & 0 deletions db/migrations/00002_create_transactions_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- +goose Up
CREATE TABLE transactions (
id SERIAL PRIMARY KEY,
block_id INTEGER NOT NULL REFERENCES blocks(id) ON DELETE CASCADE,
input_data VARCHAR,
tx_from VARCHAR(66),
gaslimit NUMERIC,
gasprice NUMERIC,
hash VARCHAR(66),
nonce NUMERIC,
tx_to VARCHAR(66),
"value" NUMERIC
);

-- +goose Down
DROP TABLE transactions;
6 changes: 6 additions & 0 deletions db/migrations/00003_add_block_index_to_blocks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- +goose Up
CREATE INDEX number_index ON blocks (number);


-- +goose Down
DROP INDEX number_index;
14 changes: 0 additions & 14 deletions db/migrations/00003_initial_transaction_table.sql

This file was deleted.

5 changes: 0 additions & 5 deletions db/migrations/00004_add_primary_key_to_blocks.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- +goose Up
CREATE TABLE watched_contracts
(
contract_id SERIAL PRIMARY KEY,
contract_hash VARCHAR(66)
contract_id SERIAL PRIMARY KEY,
contract_abi json,
contract_hash VARCHAR(66) UNIQUE
);

-- +goose Down
Expand Down
11 changes: 0 additions & 11 deletions db/migrations/00005_add_block_id_to_transactions.sql

This file was deleted.

12 changes: 12 additions & 0 deletions db/migrations/00005_create_nodes_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- +goose Up
CREATE TABLE nodes (
id SERIAL PRIMARY KEY,
client_name VARCHAR,
genesis_block VARCHAR(66),
network_id NUMERIC,
node_id VARCHAR(128),
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id)
);

-- +goose Down
DROP TABLE nodes;
6 changes: 0 additions & 6 deletions db/migrations/00006_add_block_index.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ ALTER TABLE blocks
ADD COLUMN node_id INTEGER NOT NULL,
ADD CONSTRAINT node_fk
FOREIGN KEY (node_id)
REFERENCES nodes (id);
REFERENCES nodes (id)
ON DELETE CASCADE;

-- +goose Down
ALTER TABLE blocks
Expand Down
18 changes: 0 additions & 18 deletions db/migrations/00007_add_blocks_columns.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- +goose Up
ALTER TABLE blocks
ADD CONSTRAINT node_id_block_number_uc UNIQUE (block_number, node_id);
ADD CONSTRAINT node_id_block_number_uc UNIQUE (number, node_id);

-- +goose Down
ALTER TABLE blocks
Expand Down
8 changes: 0 additions & 8 deletions db/migrations/00009_add_from_to_transactions.sql

This file was deleted.

7 changes: 0 additions & 7 deletions db/migrations/00010_add_abi_to_watched_contracts.sql

This file was deleted.

10 changes: 0 additions & 10 deletions db/migrations/00011_add_nodes_table.sql

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions db/migrations/00015_add_cascade_delete_to_transactions.sql

This file was deleted.

18 changes: 0 additions & 18 deletions db/migrations/00016_add_cascade_delete_to_blocks.sql

This file was deleted.

7 changes: 0 additions & 7 deletions db/migrations/00017_add_is_final_to_blocks.sql

This file was deleted.

7 changes: 0 additions & 7 deletions db/migrations/00023_add_miner.sql

This file was deleted.

7 changes: 0 additions & 7 deletions db/migrations/00024_add_extra_data.sql

This file was deleted.

10 changes: 0 additions & 10 deletions db/migrations/00025_add_block_reward_uncle_reward.sql

This file was deleted.

7 changes: 0 additions & 7 deletions db/migrations/00026_add_data_input_to_transactions.sql

This file was deleted.

9 changes: 0 additions & 9 deletions db/migrations/00029_add_fields_to_node.sql

This file was deleted.

14 changes: 0 additions & 14 deletions db/migrations/00030_update_node_index.sql

This file was deleted.

32 changes: 0 additions & 32 deletions db/migrations/00034_update_gas_limit_gas_used.sql

This file was deleted.

Loading

0 comments on commit 6fe32c3

Please sign in to comment.