2019-01-22 12:15:29 +00:00
|
|
|
-- +goose Up
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
ADD COLUMN block_id INT;
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
UPDATE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
SET block_id = (
|
2019-03-22 03:43:06 +00:00
|
|
|
SELECT block_id FROM full_sync_transactions WHERE full_sync_transactions.id = full_sync_receipts.transaction_id
|
2019-01-22 12:15:29 +00:00
|
|
|
);
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
ALTER COLUMN block_id SET NOT NULL;
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-06-10 17:17:14 +00:00
|
|
|
ADD CONSTRAINT eth_blocks_fk
|
2019-01-22 12:15:29 +00:00
|
|
|
FOREIGN KEY (block_id)
|
2019-06-10 17:17:14 +00:00
|
|
|
REFERENCES eth_blocks (id)
|
2019-01-22 12:15:29 +00:00
|
|
|
ON DELETE CASCADE;
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
DROP COLUMN transaction_id;
|
|
|
|
|
|
|
|
|
|
|
|
-- +goose Down
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
ADD COLUMN transaction_id INT;
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
CREATE INDEX transaction_id_index ON full_sync_receipts (transaction_id);
|
2019-01-24 09:35:52 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
UPDATE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
SET transaction_id = (
|
2019-03-22 03:43:06 +00:00
|
|
|
SELECT id FROM full_sync_transactions WHERE full_sync_transactions.hash = full_sync_receipts.tx_hash
|
2019-01-22 12:15:29 +00:00
|
|
|
);
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
ALTER COLUMN transaction_id SET NOT NULL;
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
ADD CONSTRAINT transaction_fk
|
|
|
|
FOREIGN KEY (transaction_id)
|
2019-03-19 19:11:26 +00:00
|
|
|
REFERENCES full_sync_transactions (id)
|
2019-01-22 12:15:29 +00:00
|
|
|
ON DELETE CASCADE;
|
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-01-22 12:15:29 +00:00
|
|
|
DROP COLUMN block_id;
|