Remove tx from migrations (goose does it automagically)

This commit is contained in:
Edvard 2019-01-22 15:07:11 +01:00
parent bbb9260d13
commit 8de6fc45e1
62 changed files with 74 additions and 137 deletions

View File

@ -2,8 +2,8 @@
CREATE TABLE public.blocks
(
block_number BIGINT
)
);
-- +goose Down
DROP TABLE public.blocks
DROP TABLE public.blocks;

View File

@ -8,7 +8,7 @@ CREATE TABLE transactions
tx_gaslimit NUMERIC,
tx_gasprice NUMERIC,
tx_value NUMERIC
)
);
-- +goose Down
DROP TABLE transactions
DROP TABLE transactions;

View File

@ -1,5 +1,5 @@
-- +goose Up
ALTER TABLE blocks ADD COLUMN id SERIAL PRIMARY KEY
ALTER TABLE blocks ADD COLUMN id SERIAL PRIMARY KEY;
-- +goose Down
ALTER TABLE blocks DROP id
ALTER TABLE blocks DROP id;

View File

@ -3,9 +3,9 @@ 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
DROP COLUMN block_id;

View File

@ -3,4 +3,4 @@ CREATE INDEX block_number_index ON blocks (block_number);
-- +goose Down
DROP INDEX block_number_index;
DROP INDEX block_number_index;

View File

@ -5,7 +5,7 @@ ALTER TABLE blocks
ADD COLUMN block_nonce VARCHAR(20),
ADD COLUMN block_parenthash VARCHAR(66),
ADD COLUMN block_size BIGINT,
ADD COLUMN uncle_hash VARCHAR(66)
ADD COLUMN uncle_hash VARCHAR(66);
-- +goose Down
@ -15,4 +15,4 @@ ALTER TABLE blocks
drop COLUMN block_nonce,
drop COLUMN block_parenthash,
drop COLUMN block_size,
drop COLUMN uncle_hash
drop COLUMN uncle_hash;

View File

@ -3,7 +3,7 @@ CREATE TABLE watched_contracts
(
contract_id SERIAL PRIMARY KEY,
contract_hash VARCHAR(66)
)
);
-- +goose Down
DROP TABLE watched_contracts
DROP TABLE watched_contracts;

View File

@ -1,8 +1,8 @@
-- +goose Up
ALTER TABLE transactions
ADD COLUMN tx_from VARCHAR(66)
ADD COLUMN tx_from VARCHAR(66);
-- +goose Down
ALTER TABLE transactions
DROP COLUMN tx_from
DROP COLUMN tx_from;

View File

@ -4,4 +4,4 @@ ALTER TABLE watched_contracts
-- +goose Down
ALTER TABLE watched_contracts
DROP COLUMN contract_abi;
DROP COLUMN contract_abi;

View File

@ -7,4 +7,4 @@ CREATE TABLE nodes (
);
-- +goose Down
DROP TABLE nodes;
DROP TABLE nodes;

View File

@ -7,4 +7,4 @@ REFERENCES nodes (id);
-- +goose Down
ALTER TABLE blocks
DROP COLUMN node_id;
DROP COLUMN node_id;

View File

@ -5,4 +5,4 @@ ALTER TABLE watched_contracts
-- +goose Down
ALTER TABLE watched_contracts
DROP CONSTRAINT contract_hash_uc;
DROP CONSTRAINT contract_hash_uc;

View File

@ -16,4 +16,4 @@ CREATE TABLE logs (
-- +goose Down
DROP TABLE logs;
DROP TABLE logs;

View File

@ -1,6 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE transactions
DROP CONSTRAINT fk_test;
@ -10,12 +8,8 @@ FOREIGN KEY (block_id)
REFERENCES blocks (id)
ON DELETE CASCADE;
COMMIT;
-- +goose Down
BEGIN;
ALTER TABLE transactions
DROP CONSTRAINT blocks_fk;
@ -23,5 +17,3 @@ ALTER TABLE transactions
ADD CONSTRAINT fk_test
FOREIGN KEY (block_id)
REFERENCES blocks (id);
COMMIT;

View File

@ -1,6 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE blocks
DROP CONSTRAINT node_fk;
@ -10,11 +8,7 @@ FOREIGN KEY (node_id)
REFERENCES nodes (id)
ON DELETE CASCADE;
COMMIT;
-- +goose Down
BEGIN;
ALTER TABLE blocks
DROP CONSTRAINT node_fk;
@ -22,5 +16,3 @@ ALTER TABLE blocks
ADD CONSTRAINT node_fk
FOREIGN KEY (node_id)
REFERENCES nodes (id);
COMMIT;

View File

@ -4,4 +4,4 @@ ALTER TABLE blocks
-- +goose Down
ALTER TABLE blocks
DROP COLUMN is_final;
DROP COLUMN is_final;

View File

@ -4,4 +4,4 @@ ALTER TABLE blocks
-- +goose Down
ALTER TABLE blocks
DROP CONSTRAINT node_id_block_number_uc;
DROP CONSTRAINT node_id_block_number_uc;

View File

@ -2,4 +2,4 @@
CREATE INDEX block_id_index ON transactions (block_id);
-- +goose Down
DROP INDEX block_id_index;
DROP INDEX block_id_index;

View File

@ -2,4 +2,4 @@
CREATE INDEX node_id_index ON blocks (node_id);
-- +goose Down
DROP INDEX node_id_index;
DROP INDEX node_id_index;

View File

@ -2,4 +2,4 @@
CREATE INDEX tx_to_index ON transactions(tx_to);
-- +goose Down
DROP INDEX tx_to_index;
DROP INDEX tx_to_index;

View File

@ -2,4 +2,4 @@
CREATE INDEX tx_from_index ON transactions(tx_from);
-- +goose Down
DROP INDEX tx_from_index;
DROP INDEX tx_from_index;

View File

@ -4,4 +4,4 @@ ALTER TABLE blocks
-- +goose Down
ALTER TABLE blocks
DROP COLUMN block_miner;
DROP COLUMN block_miner;

View File

@ -4,4 +4,4 @@ ALTER TABLE blocks
-- +goose Down
ALTER TABLE blocks
DROP COLUMN block_extra_data;
DROP COLUMN block_extra_data;

View File

@ -4,4 +4,4 @@ ALTER TABLE transactions
-- +goose Down
ALTER TABLE transactions
DROP COLUMN tx_input_data;
DROP COLUMN tx_input_data;

View File

@ -15,8 +15,5 @@ CREATE TABLE receipts
);
-- +goose Down
DROP TABLE receipts;

View File

@ -6,4 +6,4 @@ ALTER TABLE nodes
-- +goose Down
ALTER TABLE nodes
DROP COLUMN node_id,
DROP COLUMN client_name;
DROP COLUMN client_name;

View File

@ -1,22 +1,14 @@
-- +goose Up
BEGIN;
ALTER TABLE nodes
DROP CONSTRAINT node_uc;
ALTER TABLE nodes
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id);
COMMIT;
-- +goose Down
-- +goose Up
BEGIN;
ALTER TABLE nodes
DROP CONSTRAINT node_uc;
ALTER TABLE nodes
ADD CONSTRAINT node_uc UNIQUE (genesis_block, network_id);
COMMIT;

View File

@ -1,5 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE logs
DROP CONSTRAINT log_uc;
@ -12,11 +11,8 @@ FOREIGN KEY (receipt_id)
REFERENCES receipts (id)
ON DELETE CASCADE;
COMMIT;
-- +goose Down
BEGIN;
ALTER TABLE logs
DROP CONSTRAINT receipts_fk;
@ -25,5 +21,3 @@ ALTER TABLE logs
ALTER TABLE logs
ADD CONSTRAINT log_uc UNIQUE (block_number, index);
COMMIT;

View File

@ -13,4 +13,4 @@ CREATE TABLE log_filters (
);
-- +goose Down
DROP TABLE log_filters;
DROP TABLE log_filters;

View File

@ -1,5 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE blocks
ALTER COLUMN block_gaslimit TYPE BIGINT USING block_gaslimit :: BIGINT;
@ -15,12 +14,8 @@ ALTER TABLE blocks
ALTER TABLE blocks
ALTER COLUMN block_uncles_reward TYPE DOUBLE PRECISION USING block_time :: DOUBLE PRECISION;
COMMIT;
-- +goose Down
-- +goose Up
BEGIN;
ALTER TABLE blocks
ALTER COLUMN block_gaslimit TYPE DOUBLE PRECISION USING block_gaslimit :: DOUBLE PRECISION;
@ -35,5 +30,3 @@ ALTER TABLE blocks
ALTER TABLE blocks
ALTER COLUMN block_uncles_reward TYPE NUMERIC USING block_time :: NUMERIC;
COMMIT;

View File

@ -1,5 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE blocks
RENAME COLUMN block_number TO number;
@ -38,21 +37,9 @@ ALTER TABLE blocks
ALTER TABLE blocks
RENAME COLUMN block_uncles_reward TO uncles_reward;
COMMIT;
-- +goose Down
BEGIN;
ALTER TABLE blocks
RENAME COLUMN number TO block_number;
@ -91,4 +78,3 @@ ALTER TABLE blocks
ALTER TABLE blocks
RENAME COLUMN uncles_reward TO block_uncles_reward;
COMMIT;

View File

@ -1,5 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE transactions
RENAME COLUMN tx_hash TO hash;
@ -17,12 +16,9 @@ ALTER TABLE transactions
ALTER TABLE transactions
RENAME COLUMN tx_input_data TO input_data;
COMMIT;
-- +goose Down
-- +goose Up
BEGIN;
ALTER TABLE transactions
RENAME COLUMN hash TO tx_hash;
@ -40,4 +36,3 @@ ALTER TABLE transactions
ALTER TABLE transactions
RENAME COLUMN input_data TO tx_input_data;
COMMIT;

View File

@ -1,19 +1,14 @@
-- +goose Up
BEGIN;
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);
COMMIT;
-- +goose Down
-- +goose Up
BEGIN;
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);
COMMIT;

View File

@ -4,6 +4,5 @@ ALTER TABLE blocks
-- +goose Down
-- +goose Up
ALTER TABLE blocks
ALTER COLUMN size TYPE BIGINT USING size::BIGINT;

View File

@ -1,5 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE public.nodes RENAME TO eth_nodes;
ALTER TABLE public.eth_nodes RENAME COLUMN node_id TO eth_node_id;
@ -19,10 +18,8 @@ ALTER TABLE public.blocks
ADD CONSTRAINT node_fk
FOREIGN KEY (eth_node_id) REFERENCES eth_nodes (id) ON DELETE CASCADE;
COMMIT;
-- +goose Down
BEGIN;
ALTER TABLE public.eth_nodes
RENAME TO nodes;
@ -44,4 +41,3 @@ 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;
COMMIT;

View File

@ -1,6 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE receipts
ADD COLUMN block_id INT;
@ -21,12 +19,8 @@ ON DELETE CASCADE;
ALTER TABLE receipts
DROP COLUMN transaction_id;
COMMIT;
-- +goose Down
BEGIN;
ALTER TABLE receipts
ADD COLUMN transaction_id INT;
@ -46,5 +40,3 @@ ON DELETE CASCADE;
ALTER TABLE receipts
DROP COLUMN block_id;
COMMIT;

View File

@ -1,6 +1,4 @@
-- +goose Up
BEGIN;
ALTER TABLE blocks
ADD COLUMN eth_node_fingerprint VARCHAR(128);
@ -12,8 +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;
DROP COLUMN eth_node_fingerprint;

View File

@ -7,9 +7,8 @@ CREATE TABLE token_supply (
CONSTRAINT blocks_fk FOREIGN KEY (block_id)
REFERENCES blocks (id)
ON DELETE CASCADE
)
);
-- +goose Down
-- +goose Up
DROP TABLE token_supply;
DROP TABLE token_supply;

View File

@ -12,5 +12,6 @@ CREATE TABLE public.headers (
ON DELETE CASCADE
);
-- +goose Down
DROP TABLE public.headers;
DROP TABLE public.headers;

View File

@ -6,4 +6,4 @@ CREATE TABLE public.checked_headers (
);
-- +goose Down
DROP TABLE public.checked_headers;
DROP TABLE public.checked_headers;

View File

@ -2,6 +2,5 @@
CREATE SCHEMA maker;
-- +goose Down
DROP SCHEMA maker;

View File

@ -18,8 +18,9 @@ CREATE TABLE maker.flip_kick (
ALTER TABLE public.checked_headers
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;
DROP COLUMN flip_kick_checked;

View File

@ -18,8 +18,9 @@ CREATE TABLE maker.frob (
ALTER TABLE public.checked_headers
ADD COLUMN frob_checked BOOLEAN NOT NULL DEFAULT FALSE;
-- +goose Down
DROP TABLE maker.frob;
ALTER TABLE public.checked_headers
DROP COLUMN frob_checked;
DROP COLUMN frob_checked;

View File

@ -11,5 +11,6 @@ CREATE TABLE maker.price_feeds (
UNIQUE (header_id, medianizer_address, tx_idx, log_idx)
);
-- +goose Down
DROP TABLE maker.price_feeds;
DROP TABLE maker.price_feeds;

View File

@ -21,4 +21,4 @@ ALTER TABLE public.checked_headers
DROP TABLE maker.tend;
ALTER TABLE public.checked_headers
DROP COLUMN tend_checked;
DROP COLUMN tend_checked;

View File

@ -18,8 +18,9 @@ CREATE TABLE maker.bite (
ALTER TABLE public.checked_headers
ADD COLUMN bite_checked BOOLEAN NOT NULL DEFAULT FALSE;
-- +goose Down
DROP TABLE maker.bite;
ALTER TABLE public.checked_headers
DROP COLUMN bite_checked;
DROP COLUMN bite_checked;

View File

@ -42,6 +42,7 @@ ALTER TABLE public.checked_headers
ALTER TABLE public.checked_headers
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;
@ -54,4 +55,4 @@ ALTER TABLE public.checked_headers
DROP COLUMN pit_file_ilk_checked;
ALTER TABLE public.checked_headers
DROP COLUMN pit_file_stability_fee_checked;
DROP COLUMN pit_file_stability_fee_checked;

View File

@ -12,6 +12,7 @@ CREATE TABLE maker.vat_init (
ALTER TABLE public.checked_headers
ADD COLUMN vat_init_checked BOOLEAN NOT NULL DEFAULT FALSE;
-- +goose Down
DROP TABLE maker.vat_init;

View File

@ -42,6 +42,7 @@ ALTER TABLE public.checked_headers
ALTER TABLE public.checked_headers
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;
@ -54,4 +55,4 @@ ALTER TABLE public.checked_headers
DROP COLUMN drip_file_repo_checked;
ALTER TABLE public.checked_headers
DROP COLUMN drip_file_vow_checked;
DROP COLUMN drip_file_vow_checked;

View File

@ -17,4 +17,4 @@ ALTER TABLE public.checked_headers
DROP TABLE maker.deal;
ALTER TABLE public.checked_headers
DROP COLUMN deal_checked;
DROP COLUMN deal_checked;

View File

@ -1,4 +1,5 @@
-- +goose Up
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION notify_pricefeed() RETURNS trigger AS $$
BEGIN
PERFORM pg_notify(
@ -8,6 +9,7 @@ BEGIN
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- +goose StatementEnd
CREATE TRIGGER notify_pricefeeds
AFTER INSERT ON maker.price_feeds

View File

@ -12,8 +12,9 @@ CREATE TABLE maker.drip_drip (
ALTER TABLE public.checked_headers
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;
DROP COLUMN drip_drip_checked;

View File

@ -43,6 +43,7 @@ ALTER TABLE public.checked_headers
ALTER TABLE public.checked_headers
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;
@ -55,4 +56,4 @@ ALTER TABLE public.checked_headers
DROP COLUMN cat_file_flip_checked;
ALTER TABLE public.checked_headers
DROP COLUMN cat_file_pit_vow_checked;
DROP COLUMN cat_file_pit_vow_checked;

View File

@ -16,7 +16,8 @@ CREATE TABLE maker.flop_kick (
ALTER TABLE public.checked_headers
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;
DROP COLUMN flop_kick_checked;

View File

@ -18,4 +18,4 @@ ALTER TABLE public.checked_headers
-- +goose Down
DROP TABLE maker.vat_move;
ALTER TABLE public.checked_headers
DROP COLUMN vat_move_checked;
DROP COLUMN vat_move_checked;

View File

@ -14,7 +14,8 @@ CREATE TABLE maker.vat_toll (
ALTER TABLE public.checked_headers
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;
DROP COLUMN vat_toll_checked;

View File

@ -17,7 +17,8 @@ CREATE TABLE maker.vat_tune (
ALTER TABLE public.checked_headers
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;
DROP COLUMN vat_tune_checked;

View File

@ -17,7 +17,8 @@ CREATE TABLE maker.vat_grab (
ALTER TABLE public.checked_headers
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;
DROP COLUMN vat_grab_checked;

View File

@ -14,7 +14,8 @@ CREATE TABLE maker.vat_slip (
ALTER TABLE public.checked_headers
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;
DROP COLUMN vat_slip_checked;

View File

@ -12,7 +12,8 @@ CREATE TABLE maker.vow_flog (
ALTER TABLE public.checked_headers
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;
DROP COLUMN vow_flog_checked;

View File

@ -16,7 +16,8 @@ CREATE TABLE maker.flap_kick (
ALTER TABLE public.checked_headers
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;
DROP COLUMN flap_kick_checked;

View File

@ -18,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;