Merge pull request #5 from 8thlight/VDB-281-Migrations-remake
VDB-281 Migrations remake
This commit is contained in:
commit
c474933432
@ -12,7 +12,7 @@ addons:
|
||||
go_import_path: github.com/vulcanize/vulcanizedb
|
||||
|
||||
before_install:
|
||||
# ginkgo golint dep migrate
|
||||
# ginkgo golint dep goose
|
||||
- make installtools
|
||||
- bash ./scripts/install-postgres-10.sh
|
||||
- npm install -g ganache-cli
|
||||
@ -23,6 +23,7 @@ before_install:
|
||||
before_script:
|
||||
- go get -u github.com/pressly/sup/cmd/sup
|
||||
- sudo -u postgres createdb vulcanize_private
|
||||
- make version_migrations
|
||||
- make migrate NAME=vulcanize_private
|
||||
- bash ./pkg/transformers/start_test_chain.sh
|
||||
- cd postgraphile && yarn
|
||||
|
74
Makefile
74
Makefile
@ -2,31 +2,37 @@ BIN = $(GOPATH)/bin
|
||||
BASE = $(GOPATH)/src/$(PACKAGE)
|
||||
PKGS = go list ./... | grep -v "^vendor/"
|
||||
|
||||
#Tools
|
||||
# Tools
|
||||
## Dependency management
|
||||
DEP = $(BIN)/dep
|
||||
$(BIN)/dep:
|
||||
go get -u github.com/golang/dep/cmd/dep
|
||||
|
||||
## Testing library
|
||||
GINKGO = $(BIN)/ginkgo
|
||||
$(BIN)/ginkgo:
|
||||
go get -u github.com/onsi/ginkgo/ginkgo
|
||||
|
||||
MIGRATE = $(BIN)/migrate
|
||||
$(BIN)/migrate:
|
||||
go get -u -d github.com/mattes/migrate/cli github.com/lib/pq
|
||||
go build -tags 'postgres' -o $(BIN)/migrate github.com/mattes/migrate/cli
|
||||
## Migration tool
|
||||
GOOSE = $(BIN)/goose
|
||||
$(BIN)/goose:
|
||||
go get -u -d github.com/pressly/goose/cmd/goose
|
||||
go build -tags='no_mysql no_sqlite' -o $(BIN)/goose github.com/pressly/goose/cmd/goose
|
||||
|
||||
## Source linter
|
||||
LINT = $(BIN)/golint
|
||||
$(BIN)/golint:
|
||||
go get -u golang.org/x/lint/golint
|
||||
|
||||
## Combination linter
|
||||
METALINT = $(BIN)/gometalinter.v2
|
||||
$(BIN)/gometalinter.v2:
|
||||
go get -u gopkg.in/alecthomas/gometalinter.v2
|
||||
$(METALINT) --install
|
||||
|
||||
|
||||
.PHONY: installtools
|
||||
installtools: | $(LINT) $(MIGRATE) $(GINKGO) $(DEP)
|
||||
installtools: | $(LINT) $(GOOSE) $(GINKGO) $(DEP)
|
||||
echo "Installing tools"
|
||||
|
||||
.PHONY: metalint
|
||||
@ -67,30 +73,74 @@ PORT = 5432
|
||||
NAME =
|
||||
CONNECT_STRING=postgresql://$(HOST_NAME):$(PORT)/$(NAME)?sslmode=disable
|
||||
|
||||
# Parameter checks
|
||||
## Check that DB variables are provided
|
||||
.PHONY: checkdbvars
|
||||
checkdbvars:
|
||||
test -n "$(HOST_NAME)" # $$HOST_NAME
|
||||
test -n "$(HOST_NAME)" # $$HOST_NAME
|
||||
test -n "$(PORT)" # $$PORT
|
||||
test -n "$(NAME)" # $$NAME
|
||||
@echo $(CONNECT_STRING)
|
||||
|
||||
## Check that the migration variable (id/timestamp) is provided
|
||||
.PHONY: checkmigration
|
||||
checkmigration:
|
||||
test -n "$(MIGRATION)" # $$MIGRATION
|
||||
|
||||
# Check that the migration name is provided
|
||||
.PHONY: checkmigname
|
||||
checkmigname:
|
||||
test -n "$(NAME)" # $$NAME
|
||||
|
||||
# Migration operations
|
||||
## Rollback the last migration
|
||||
.PHONY: rollback
|
||||
rollback: $(MIGRATE) checkdbvars
|
||||
$(MIGRATE) -database $(CONNECT_STRING) -path ./db/migrations down 1
|
||||
rollback: $(GOOSE) checkdbvars
|
||||
cd db/migrations;\
|
||||
$(GOOSE) postgres "$(CONNECT_STRING)" down
|
||||
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
||||
|
||||
|
||||
## Rollbackt to a select migration (id/timestamp)
|
||||
.PHONY: rollback_to
|
||||
rollback_to: $(GOOSE) checkmigration checkdbvars
|
||||
cd db/migrations;\
|
||||
$(GOOSE) postgres "$(CONNECT_STRING)" down-to "$(MIGRATION)"
|
||||
|
||||
## Apply all migrations not already run
|
||||
.PHONY: migrate
|
||||
migrate: $(MIGRATE) checkdbvars
|
||||
$(MIGRATE) -database $(CONNECT_STRING) -path ./db/migrations up
|
||||
migrate: $(GOOSE) checkdbvars
|
||||
cd db/migrations;\
|
||||
$(GOOSE) postgres "$(CONNECT_STRING)" up
|
||||
pg_dump -O -s $(CONNECT_STRING) > db/schema.sql
|
||||
|
||||
## Create a new migration file
|
||||
.PHONY: new_migration
|
||||
new_migration: $(GOOSE) checkmigname
|
||||
cd db/migrations;\
|
||||
$(GOOSE) create $(NAME) sql
|
||||
|
||||
## Check which migrations are applied at the moment
|
||||
.PHONY: migration_status
|
||||
migration_status: $(GOOSE) checkdbvars
|
||||
cd db/migrations;\
|
||||
$(GOOSE) postgres "$(CONNECT_STRING)" status
|
||||
|
||||
# Convert timestamped migrations to versioned (to be run in CI);
|
||||
# merge timestamped files to prevent conflict
|
||||
.PHONY: version_migrations
|
||||
version_migrations:
|
||||
cd db/migrations; $(GOOSE) fix
|
||||
|
||||
# Import a psql schema to the database
|
||||
.PHONY: import
|
||||
import:
|
||||
test -n "$(NAME)" # $$NAME
|
||||
psql $(NAME) < db/schema.sql
|
||||
|
||||
#Rinkeby docker environment
|
||||
|
||||
# Docker actions
|
||||
## Rinkeby docker environment
|
||||
RINKEBY_COMPOSE_FILE=dockerfiles/rinkeby/docker-compose.yml
|
||||
|
||||
.PHONY: rinkeby_env_up
|
||||
|
20
README.md
20
README.md
@ -46,18 +46,20 @@ Lastly, ensure that `GOPATH` is defined in your shell. If necessary, `GOPATH` ca
|
||||
## Setting up the Database
|
||||
1. Install Postgres
|
||||
1. Create a superuser for yourself and make sure `psql --list` works without prompting for a password.
|
||||
1. Execute `createdb vulcanize_public`
|
||||
1. Execute `cd $GOPATH/src/github.com/vulcanize/vulcanizedb`
|
||||
1. Run the migrations: `make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=<postgres port, default 5432>`
|
||||
1. `createdb vulcanize_public`
|
||||
1. `cd $GOPATH/src/github.com/vulcanize/vulcanizedb`
|
||||
1. Run the migrations: `make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=5432`
|
||||
- To rollback a single step: `make rollback NAME=vulcanize_public`
|
||||
- To rollback to a certain migration: `make rollback_to MIGRATION=n NAME=vulcanize_public`
|
||||
- To see status of migrations: `make migration_status NAME=vulcanize_public`
|
||||
|
||||
* See below for configuring additional environments
|
||||
|
||||
In some cases (such as recent Ubuntu systems), it may be necessary to overcome failures of password authentication from `localhost`. To allow access on Ubuntu, set localhost connections via hostname, ipv4, and ipv6 from `peer`/`md5` to `trust` in: `/etc/postgresql/<version>/pg_hba.conf`
|
||||
|
||||
(It should be noted that trusted auth should only be enabled on systems without sensitive data in them: development and local test databases.)
|
||||
|
||||
## Create a migration file (up and down)
|
||||
1. ./script/create_migrate create_bite_table
|
||||
## Create a migration file
|
||||
1. `make new_migration NAME=add_columnA_to_table1`
|
||||
- This will create a new timestamped migration file in `db/migrations`
|
||||
1. Write the migration code in the created file, under the respective `goose` pragma
|
||||
- Goose automatically runs each migration in a transaction; don't add `BEGIN` and `COMMIT` statements.
|
||||
|
||||
## Configuration
|
||||
- To use a local Ethereum node, copy `environments/public.toml.example` to
|
||||
|
3
Supfile
3
Supfile
@ -38,7 +38,8 @@ commands:
|
||||
run: >
|
||||
cd $VDB_PATH &&
|
||||
make installtools &&
|
||||
/root/go_projects/bin/migrate -database postgresql://$VDB_PG_USER:$VDB_PG_PW@127.0.0.1:5432/vulcanize_public?sslmode=disable -path ./db/migrations up
|
||||
cd db/migrations &&
|
||||
/root/go_projects/bin/goose postgres "postgresql://$(VDB_PG_USER):$(VDB_PG_PW)@127.0.0.1:5432/vulcanize_public?sslmode=disable" up
|
||||
buildPostgraphile:
|
||||
desc: build postgraphile app
|
||||
run: >
|
||||
|
9
db/migrations/00001_create_blocks_table.sql
Normal file
9
db/migrations/00001_create_blocks_table.sql
Normal file
@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE public.blocks
|
||||
(
|
||||
block_number BIGINT
|
||||
);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE public.blocks;
|
@ -1,4 +1,13 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN block_gaslimit DOUBLE PRECISION,
|
||||
ADD COLUMN block_gasused DOUBLE PRECISION,
|
||||
ADD COLUMN block_time DOUBLE PRECISION;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN block_gaslimit,
|
||||
DROP COLUMN block_gasused,
|
||||
DROP COLUMN block_time;
|
||||
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE transactions
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
@ -7,4 +8,7 @@ CREATE TABLE transactions
|
||||
tx_gaslimit NUMERIC,
|
||||
tx_gasprice NUMERIC,
|
||||
tx_value NUMERIC
|
||||
)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE transactions;
|
5
db/migrations/00004_add_primary_key_to_blocks.sql
Normal file
5
db/migrations/00004_add_primary_key_to_blocks.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks ADD COLUMN id SERIAL PRIMARY KEY;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks DROP id;
|
@ -1,5 +1,11 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions
|
||||
ADD COLUMN block_id INTEGER NOT NULL,
|
||||
ADD CONSTRAINT fk_test
|
||||
FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id)
|
||||
REFERENCES blocks (id);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions
|
||||
DROP COLUMN block_id;
|
6
db/migrations/00006_add_block_index.sql
Normal file
6
db/migrations/00006_add_block_index.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX block_number_index ON blocks (block_number);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX block_number_index;
|
18
db/migrations/00007_add_blocks_columns.sql
Normal file
18
db/migrations/00007_add_blocks_columns.sql
Normal file
@ -0,0 +1,18 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN block_difficulty BIGINT,
|
||||
ADD COLUMN block_hash VARCHAR(66),
|
||||
ADD COLUMN block_nonce VARCHAR(20),
|
||||
ADD COLUMN block_parenthash VARCHAR(66),
|
||||
ADD COLUMN block_size BIGINT,
|
||||
ADD COLUMN uncle_hash VARCHAR(66);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
Drop COLUMN block_difficulty,
|
||||
Drop COLUMN block_hash,
|
||||
drop COLUMN block_nonce,
|
||||
drop COLUMN block_parenthash,
|
||||
drop COLUMN block_size,
|
||||
drop COLUMN uncle_hash;
|
@ -1,5 +1,9 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE watched_contracts
|
||||
(
|
||||
contract_id SERIAL PRIMARY KEY,
|
||||
contract_hash VARCHAR(66)
|
||||
)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE watched_contracts;
|
8
db/migrations/00009_add_from_to_transactions.sql
Normal file
8
db/migrations/00009_add_from_to_transactions.sql
Normal file
@ -0,0 +1,8 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions
|
||||
ADD COLUMN tx_from VARCHAR(66);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions
|
||||
DROP COLUMN tx_from;
|
7
db/migrations/00010_add_abi_to_watched_contracts.sql
Normal file
7
db/migrations/00010_add_abi_to_watched_contracts.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE watched_contracts
|
||||
ADD COLUMN contract_abi json;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE watched_contracts
|
||||
DROP COLUMN contract_abi;
|
@ -1,6 +1,10 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE nodes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
genesis_block VARCHAR(66),
|
||||
network_id NUMERIC,
|
||||
CONSTRAINT node_uc UNIQUE (genesis_block, network_id)
|
||||
);
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE nodes;
|
@ -1,11 +1,10 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE blocks
|
||||
DROP CONSTRAINT node_fk;
|
||||
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN node_id INTEGER NOT NULL,
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (node_id)
|
||||
REFERENCES nodes (id);
|
||||
|
||||
COMMIT;
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN node_id;
|
@ -0,0 +1,8 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE watched_contracts
|
||||
ADD CONSTRAINT contract_hash_uc UNIQUE (contract_hash);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE watched_contracts
|
||||
DROP CONSTRAINT contract_hash_uc;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE logs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
@ -12,3 +13,7 @@ CREATE TABLE logs (
|
||||
CONSTRAINT log_uc UNIQUE (block_number, index)
|
||||
);
|
||||
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE logs;
|
19
db/migrations/00015_add_cascade_delete_to_transactions.sql
Normal file
19
db/migrations/00015_add_cascade_delete_to_transactions.sql
Normal file
@ -0,0 +1,19 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions
|
||||
DROP CONSTRAINT fk_test;
|
||||
|
||||
ALTER TABLE transactions
|
||||
ADD CONSTRAINT blocks_fk
|
||||
FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions
|
||||
DROP CONSTRAINT blocks_fk;
|
||||
|
||||
ALTER TABLE transactions
|
||||
ADD CONSTRAINT fk_test
|
||||
FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id);
|
18
db/migrations/00016_add_cascade_delete_to_blocks.sql
Normal file
18
db/migrations/00016_add_cascade_delete_to_blocks.sql
Normal file
@ -0,0 +1,18 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
DROP CONSTRAINT node_fk;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (node_id)
|
||||
REFERENCES nodes (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP CONSTRAINT node_fk;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (node_id)
|
||||
REFERENCES nodes (id);
|
7
db/migrations/00017_add_is_final_to_blocks.sql
Normal file
7
db/migrations/00017_add_is_final_to_blocks.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN is_final BOOLEAN;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN is_final;
|
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD CONSTRAINT node_id_block_number_uc UNIQUE (block_number, node_id);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP CONSTRAINT node_id_block_number_uc;
|
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX block_id_index ON transactions (block_id);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX block_id_index;
|
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX node_id_index ON blocks (node_id);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX node_id_index;
|
5
db/migrations/00021_tx_to_index.sql
Normal file
5
db/migrations/00021_tx_to_index.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX tx_to_index ON transactions(tx_to);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX tx_to_index;
|
5
db/migrations/00022_tx_from_index.sql
Normal file
5
db/migrations/00022_tx_from_index.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX tx_from_index ON transactions(tx_from);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX tx_from_index;
|
7
db/migrations/00023_add_miner.sql
Normal file
7
db/migrations/00023_add_miner.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN block_miner VARCHAR(42);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN block_miner;
|
7
db/migrations/00024_add_extra_data.sql
Normal file
7
db/migrations/00024_add_extra_data.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN block_extra_data VARCHAR;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN block_extra_data;
|
10
db/migrations/00025_add_block_reward_uncle_reward.sql
Normal file
10
db/migrations/00025_add_block_reward_uncle_reward.sql
Normal file
@ -0,0 +1,10 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN block_reward NUMERIC,
|
||||
ADD COLUMN block_uncles_reward NUMERIC;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN block_reward,
|
||||
DROP COLUMN block_uncles_reward;
|
7
db/migrations/00026_add_data_input_to_transactions.sql
Normal file
7
db/migrations/00026_add_data_input_to_transactions.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions
|
||||
ADD COLUMN tx_input_data VARCHAR;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions
|
||||
DROP COLUMN tx_input_data;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE receipts
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
@ -14,3 +15,5 @@ CREATE TABLE receipts
|
||||
);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE receipts;
|
@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX transaction_id_index ON receipts (transaction_id);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX transaction_id_index;
|
9
db/migrations/00029_add_fields_to_node.sql
Normal file
9
db/migrations/00029_add_fields_to_node.sql
Normal file
@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE nodes
|
||||
ADD COLUMN node_id VARCHAR(128),
|
||||
ADD COLUMN client_name VARCHAR;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE nodes
|
||||
DROP COLUMN node_id,
|
||||
DROP COLUMN client_name;
|
14
db/migrations/00030_update_node_index.sql
Normal file
14
db/migrations/00030_update_node_index.sql
Normal file
@ -0,0 +1,14 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE nodes
|
||||
DROP CONSTRAINT node_uc;
|
||||
|
||||
ALTER TABLE nodes
|
||||
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE nodes
|
||||
DROP CONSTRAINT node_uc;
|
||||
|
||||
ALTER TABLE nodes
|
||||
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id);
|
@ -1,4 +1,4 @@
|
||||
BEGIN;
|
||||
-- +goose Up
|
||||
ALTER TABLE logs
|
||||
DROP CONSTRAINT log_uc;
|
||||
|
||||
@ -11,4 +11,13 @@ FOREIGN KEY (receipt_id)
|
||||
REFERENCES receipts (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE logs
|
||||
DROP CONSTRAINT receipts_fk;
|
||||
|
||||
ALTER TABLE logs
|
||||
DROP COLUMN receipt_id;
|
||||
|
||||
ALTER TABLE logs
|
||||
ADD CONSTRAINT log_uc UNIQUE (block_number, index);
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE log_filters (
|
||||
id SERIAL,
|
||||
name VARCHAR NOT NULL CHECK (name <> ''),
|
||||
@ -9,4 +10,7 @@ CREATE TABLE log_filters (
|
||||
topic2 VARCHAR(66),
|
||||
topic3 VARCHAR(66),
|
||||
CONSTRAINT name_uc UNIQUE (name)
|
||||
);
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE log_filters;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE VIEW block_stats AS
|
||||
SELECT
|
||||
max(block_number) AS max_block,
|
||||
@ -26,4 +27,8 @@ CREATE VIEW watched_event_logs AS
|
||||
WHERE (log_filters.topic0 = logs.topic0 OR log_filters.topic0 ISNULL)
|
||||
AND (log_filters.topic1 = logs.topic1 OR log_filters.topic1 ISNULL)
|
||||
AND (log_filters.topic2 = logs.topic2 OR log_filters.topic2 ISNULL)
|
||||
AND (log_filters.topic3 = logs.topic3 OR log_filters.topic3 ISNULL);
|
||||
AND (log_filters.topic3 = logs.topic3 OR log_filters.topic3 ISNULL);
|
||||
|
||||
-- +goose Down
|
||||
DROP VIEW watched_event_logs;
|
||||
DROP VIEW block_stats;
|
32
db/migrations/00034_update_gas_limit_gas_used.sql
Normal file
32
db/migrations/00034_update_gas_limit_gas_used.sql
Normal file
@ -0,0 +1,32 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_gaslimit TYPE BIGINT USING block_gaslimit :: BIGINT;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_gasused TYPE BIGINT USING block_gasused :: BIGINT;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_time TYPE BIGINT USING block_time :: BIGINT;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_reward TYPE DOUBLE PRECISION USING block_time :: DOUBLE PRECISION;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_uncles_reward TYPE DOUBLE PRECISION USING block_time :: DOUBLE PRECISION;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_gaslimit TYPE DOUBLE PRECISION USING block_gaslimit :: DOUBLE PRECISION;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_gasused TYPE DOUBLE PRECISION USING block_gasused :: DOUBLE PRECISION;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_time TYPE DOUBLE PRECISION USING block_time :: DOUBLE PRECISION;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_reward TYPE NUMERIC USING block_time :: NUMERIC;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN block_uncles_reward TYPE NUMERIC USING block_time :: NUMERIC;
|
80
db/migrations/00035_rename_block_columns.sql
Normal file
80
db/migrations/00035_rename_block_columns.sql
Normal file
@ -0,0 +1,80 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_number TO number;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_gaslimit TO gaslimit;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_gasused TO gasused;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_time TO time;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_difficulty TO difficulty;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_hash TO hash;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_nonce TO nonce;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_parenthash TO parenthash;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_size TO size;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_miner TO miner;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_extra_data TO extra_data;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_reward TO reward;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN block_uncles_reward TO uncles_reward;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN number TO block_number;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN gaslimit TO block_gaslimit;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN gasused TO block_gasused;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN TIME TO block_time;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN difficulty TO block_difficulty;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN HASH TO block_hash;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN nonce TO block_nonce;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN parenthash TO block_parenthash;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN size TO block_size;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN miner TO block_miner;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN extra_data TO block_extra_data;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN reward TO block_reward;
|
||||
|
||||
ALTER TABLE blocks
|
||||
RENAME COLUMN uncles_reward TO block_uncles_reward;
|
38
db/migrations/00036_update_tx_table_names.sql
Normal file
38
db/migrations/00036_update_tx_table_names.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN tx_hash TO hash;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN tx_nonce TO nonce;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN tx_gaslimit TO gaslimit;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN tx_gasprice TO gasprice;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN tx_value TO value;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN tx_input_data TO input_data;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN hash TO tx_hash;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN nonce TO tx_nonce;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN gaslimit TO tx_gaslimit;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN gasprice TO tx_gasprice;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN value TO tx_value;
|
||||
|
||||
ALTER TABLE transactions
|
||||
RENAME COLUMN input_data TO tx_input_data;
|
@ -0,0 +1,14 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE log_filters
|
||||
DROP CONSTRAINT log_filters_from_block_check1;
|
||||
|
||||
ALTER TABLE log_filters
|
||||
ADD CONSTRAINT log_filters_to_block_check CHECK (to_block >= 0);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE log_filters
|
||||
DROP CONSTRAINT log_filters_to_block_check;
|
||||
|
||||
ALTER TABLE log_filters
|
||||
ADD CONSTRAINT log_filters_from_block_check1 CHECK (to_block >= 0);
|
8
db/migrations/00038_update_eth18_types.sql
Normal file
8
db/migrations/00038_update_eth18_types.sql
Normal file
@ -0,0 +1,8 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN size TYPE VARCHAR USING size::VARCHAR;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN size TYPE BIGINT USING size::BIGINT;
|
43
db/migrations/00039_rename_node_table.sql
Normal file
43
db/migrations/00039_rename_node_table.sql
Normal file
@ -0,0 +1,43 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE public.nodes RENAME TO eth_nodes;
|
||||
|
||||
ALTER TABLE public.eth_nodes RENAME COLUMN node_id TO eth_node_id;
|
||||
|
||||
ALTER TABLE public.eth_nodes DROP CONSTRAINT node_uc;
|
||||
ALTER TABLE public.eth_nodes
|
||||
ADD CONSTRAINT eth_node_uc UNIQUE (genesis_block, network_id, eth_node_id);
|
||||
|
||||
ALTER TABLE public.blocks RENAME COLUMN node_id TO eth_node_id;
|
||||
|
||||
ALTER TABLE public.blocks DROP CONSTRAINT node_id_block_number_uc;
|
||||
ALTER TABLE public.blocks
|
||||
ADD CONSTRAINT eth_node_id_block_number_uc UNIQUE (number, eth_node_id);
|
||||
|
||||
ALTER TABLE public.blocks DROP CONSTRAINT node_fk;
|
||||
ALTER TABLE public.blocks
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (eth_node_id) REFERENCES eth_nodes (id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE public.eth_nodes
|
||||
RENAME TO nodes;
|
||||
|
||||
ALTER TABLE public.nodes
|
||||
RENAME COLUMN eth_node_id TO node_id;
|
||||
|
||||
ALTER TABLE public.nodes
|
||||
DROP CONSTRAINT eth_node_uc;
|
||||
ALTER TABLE public.nodes
|
||||
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id);
|
||||
|
||||
ALTER TABLE public.blocks RENAME COLUMN eth_node_id TO node_id;
|
||||
|
||||
ALTER TABLE public.blocks DROP CONSTRAINT eth_node_id_block_number_uc;
|
||||
ALTER TABLE public.blocks
|
||||
ADD CONSTRAINT node_id_block_number_uc UNIQUE (number, node_id);
|
||||
|
||||
ALTER TABLE public.blocks DROP CONSTRAINT node_fk;
|
||||
ALTER TABLE public.blocks
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE;
|
@ -1,5 +1,26 @@
|
||||
BEGIN;
|
||||
-- +goose Up
|
||||
ALTER TABLE receipts
|
||||
ADD COLUMN block_id INT;
|
||||
|
||||
UPDATE receipts
|
||||
SET block_id = (
|
||||
SELECT block_id FROM transactions WHERE transactions.id = receipts.transaction_id
|
||||
);
|
||||
|
||||
ALTER TABLE receipts
|
||||
ALTER COLUMN block_id SET NOT NULL;
|
||||
|
||||
ALTER TABLE receipts
|
||||
ADD CONSTRAINT blocks_fk
|
||||
FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE receipts
|
||||
DROP COLUMN transaction_id;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE receipts
|
||||
ADD COLUMN transaction_id INT;
|
||||
|
||||
@ -21,5 +42,3 @@ ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE receipts
|
||||
DROP COLUMN block_id;
|
||||
|
||||
COMMIT;
|
@ -1,5 +1,4 @@
|
||||
BEGIN;
|
||||
|
||||
-- +goose Up
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN eth_node_fingerprint VARCHAR(128);
|
||||
|
||||
@ -11,4 +10,7 @@ UPDATE blocks
|
||||
ALTER TABLE blocks
|
||||
ALTER COLUMN eth_node_fingerprint SET NOT NULL;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN eth_node_fingerprint;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE token_supply (
|
||||
id SERIAL,
|
||||
block_id INTEGER NOT NULL,
|
||||
@ -6,4 +7,8 @@ CREATE TABLE token_supply (
|
||||
CONSTRAINT blocks_fk FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id)
|
||||
ON DELETE CASCADE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE token_supply;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE public.headers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
hash VARCHAR(66),
|
||||
@ -9,4 +10,8 @@ CREATE TABLE public.headers (
|
||||
CONSTRAINT eth_nodes_fk FOREIGN KEY (eth_node_id)
|
||||
REFERENCES eth_nodes (id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE public.headers;
|
@ -1,5 +1,9 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE public.checked_headers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER UNIQUE NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
price_feeds_checked BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE public.checked_headers;
|
6
db/migrations/00045_create_maker_schema.sql
Normal file
6
db/migrations/00045_create_maker_schema.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- +goose Up
|
||||
CREATE SCHEMA maker;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP SCHEMA maker;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.flip_kick (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -15,4 +16,11 @@ CREATE TABLE maker.flip_kick (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN flip_kick_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN flip_kick_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.flip_kick;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN flip_kick_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.frob (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -15,4 +16,11 @@ CREATE TABLE maker.frob (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN frob_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN frob_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.frob;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN frob_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.price_feeds (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT NOT NULL,
|
||||
@ -8,4 +9,8 @@ CREATE TABLE maker.price_feeds (
|
||||
tx_idx INTEGER NOT NULL,
|
||||
raw_log JSONB,
|
||||
UNIQUE (header_id, medianizer_address, tx_idx, log_idx)
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.price_feeds;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.tend (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -14,3 +15,10 @@ CREATE TABLE maker.tend (
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN tend_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.tend;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN tend_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.bite (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -15,4 +16,11 @@ CREATE TABLE maker.bite (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN bite_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN bite_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.bite;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN bite_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.dent (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -14,3 +15,10 @@ CREATE TABLE maker.dent (
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN dent_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.dent;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN dent_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.pit_file_ilk (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -39,4 +40,19 @@ ALTER TABLE public.checked_headers
|
||||
ADD COLUMN pit_file_ilk_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN pit_file_stability_fee_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN pit_file_stability_fee_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.pit_file_ilk;
|
||||
DROP TABLE maker.pit_file_stability_fee;
|
||||
DROP TABLE maker.pit_file_debt_ceiling;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN pit_file_debt_ceiling_checked;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN pit_file_ilk_checked;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN pit_file_stability_fee_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_init (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -9,4 +10,11 @@ CREATE TABLE maker.vat_init (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_init_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN vat_init_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_init;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_init_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.drip_file_ilk (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -39,4 +40,19 @@ ALTER TABLE public.checked_headers
|
||||
ADD COLUMN drip_file_repo_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN drip_file_vow_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN drip_file_vow_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.drip_file_ilk;
|
||||
DROP TABLE maker.drip_file_repo;
|
||||
DROP TABLE maker.drip_file_vow;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN drip_file_ilk_checked;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN drip_file_repo_checked;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN drip_file_vow_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.deal (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -10,4 +11,10 @@ CREATE TABLE maker.deal (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN deal_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN deal_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.deal;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN deal_checked;
|
@ -1,3 +1,5 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE OR REPLACE FUNCTION notify_pricefeed() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
PERFORM pg_notify(
|
||||
@ -7,8 +9,13 @@ BEGIN
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
-- +goose StatementEnd
|
||||
|
||||
CREATE TRIGGER notify_pricefeeds
|
||||
AFTER INSERT ON maker.price_feeds
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE notify_pricefeed();
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TRIGGER notify_pricefeeds ON maker.price_feeds;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.drip_drip (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -9,4 +10,11 @@ CREATE TABLE maker.drip_drip (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN drip_drip_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN drip_drip_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.drip_drip;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN drip_drip_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.cat_file_chop_lump (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -40,4 +41,19 @@ ALTER TABLE public.checked_headers
|
||||
ADD COLUMN cat_file_flip_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN cat_file_pit_vow_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN cat_file_pit_vow_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.cat_file_chop_lump;
|
||||
DROP TABLE maker.cat_file_flip;
|
||||
DROP TABLE maker.cat_file_pit_vow;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN cat_file_chop_lump_checked;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN cat_file_flip_checked;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN cat_file_pit_vow_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.flop_kick (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -13,4 +14,10 @@ CREATE TABLE maker.flop_kick (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN flop_kick_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN flop_kick_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.flop_kick;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN flop_kick_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_move (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -12,3 +13,9 @@ CREATE TABLE maker.vat_move (
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_move_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_move;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_move_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_fold (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -12,3 +13,9 @@ CREATE TABLE maker.vat_fold (
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_fold_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_fold;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_fold_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_heal (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -12,3 +13,9 @@ CREATE TABLE maker.vat_heal (
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_heal_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_heal;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_heal_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_toll (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -11,4 +12,10 @@ CREATE TABLE maker.vat_toll (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_toll_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN vat_toll_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_toll;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_toll_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_tune (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -14,4 +15,10 @@ CREATE TABLE maker.vat_tune (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_tune_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN vat_tune_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_tune;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_tune_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_grab (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -14,4 +15,10 @@ CREATE TABLE maker.vat_grab (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_grab_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN vat_grab_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_grab;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_grab_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_flux (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -13,3 +14,9 @@ CREATE TABLE maker.vat_flux (
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_flux_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_flux;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_flux_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_slip (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -11,4 +12,10 @@ CREATE TABLE maker.vat_slip (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vat_slip_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN vat_slip_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_slip;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vat_slip_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vow_flog (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -9,4 +10,10 @@ CREATE TABLE maker.vow_flog (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN vow_flog_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN vow_flog_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vow_flog;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN vow_flog_checked;
|
@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.flap_kick (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -13,4 +14,10 @@ CREATE TABLE maker.flap_kick (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN flap_kick_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN flap_kick_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.flap_kick;
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN flap_kick_checked;
|
@ -1,3 +1,11 @@
|
||||
-- +goose Up
|
||||
DROP TABLE maker.pit_file_stability_fee;
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
DROP COLUMN pit_file_stability_fee_checked;
|
||||
|
||||
|
||||
-- +goose Down
|
||||
CREATE TABLE maker.pit_file_stability_fee (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
@ -10,4 +18,4 @@ CREATE TABLE maker.pit_file_stability_fee (
|
||||
);
|
||||
|
||||
ALTER TABLE public.checked_headers
|
||||
ADD COLUMN pit_file_stability_fee_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ADD COLUMN pit_file_stability_fee_checked BOOLEAN NOT NULL DEFAULT FALSE;
|
@ -1 +0,0 @@
|
||||
DROP TABLE public.blocks
|
@ -1,4 +0,0 @@
|
||||
CREATE TABLE public.blocks
|
||||
(
|
||||
block_number BIGINT
|
||||
)
|
@ -1,5 +0,0 @@
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN block_gaslimit,
|
||||
DROP COLUMN block_gasused,
|
||||
DROP COLUMN block_time;
|
||||
|
@ -1 +0,0 @@
|
||||
DROP TABLE transactions
|
@ -1 +0,0 @@
|
||||
ALTER TABLE blocks DROP id
|
@ -1 +0,0 @@
|
||||
ALTER TABLE blocks ADD COLUMN id SERIAL PRIMARY KEY
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE transactions
|
||||
DROP COLUMN block_id
|
@ -1 +0,0 @@
|
||||
DROP INDEX block_number_index;
|
@ -1 +0,0 @@
|
||||
CREATE INDEX block_number_index ON blocks (block_number);
|
@ -1,7 +0,0 @@
|
||||
ALTER TABLE blocks
|
||||
Drop COLUMN block_difficulty,
|
||||
Drop COLUMN block_hash,
|
||||
drop COLUMN block_nonce,
|
||||
drop COLUMN block_parenthash,
|
||||
drop COLUMN block_size,
|
||||
drop COLUMN uncle_hash
|
@ -1,7 +0,0 @@
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN block_difficulty BIGINT,
|
||||
ADD COLUMN block_hash VARCHAR(66),
|
||||
ADD COLUMN block_nonce VARCHAR(20),
|
||||
ADD COLUMN block_parenthash VARCHAR(66),
|
||||
ADD COLUMN block_size BIGINT,
|
||||
ADD COLUMN uncle_hash VARCHAR(66)
|
@ -1 +0,0 @@
|
||||
DROP TABLE watched_contracts
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE transactions
|
||||
DROP COLUMN tx_from
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE transactions
|
||||
ADD COLUMN tx_from VARCHAR(66)
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE watched_contracts
|
||||
DROP COLUMN contract_abi;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE watched_contracts
|
||||
ADD COLUMN contract_abi json;
|
@ -1 +0,0 @@
|
||||
DROP TABLE nodes;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN node_id;
|
@ -1,5 +0,0 @@
|
||||
ALTER TABLE blocks
|
||||
ADD COLUMN node_id INTEGER NOT NULL,
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (node_id)
|
||||
REFERENCES nodes (id);
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE watched_contracts
|
||||
DROP CONSTRAINT contract_hash_uc;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE watched_contracts
|
||||
ADD CONSTRAINT contract_hash_uc UNIQUE (contract_hash);
|
@ -1 +0,0 @@
|
||||
DROP TABLE logs;
|
@ -1,11 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE transactions
|
||||
DROP CONSTRAINT blocks_fk;
|
||||
|
||||
ALTER TABLE transactions
|
||||
ADD CONSTRAINT fk_test
|
||||
FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id);
|
||||
|
||||
COMMIT;
|
@ -1,12 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE transactions
|
||||
DROP CONSTRAINT fk_test;
|
||||
|
||||
ALTER TABLE transactions
|
||||
ADD CONSTRAINT blocks_fk
|
||||
FOREIGN KEY (block_id)
|
||||
REFERENCES blocks (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
COMMIT;
|
@ -1,12 +0,0 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE blocks
|
||||
DROP CONSTRAINT node_fk;
|
||||
|
||||
ALTER TABLE blocks
|
||||
ADD CONSTRAINT node_fk
|
||||
FOREIGN KEY (node_id)
|
||||
REFERENCES nodes (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
COMMIT;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE blocks
|
||||
DROP COLUMN is_final;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user