2019-01-22 12:15:29 +00:00
|
|
|
-- +goose Up
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
ADD COLUMN block_id INT;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
UPDATE full_sync_receipts
|
2019-08-06 21:57:08 +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-08-06 21:57:08 +00:00
|
|
|
);
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
ALTER COLUMN block_id SET NOT NULL;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
ADD CONSTRAINT blocks_fk
|
|
|
|
FOREIGN KEY (block_id)
|
|
|
|
REFERENCES blocks (id)
|
|
|
|
ON DELETE CASCADE;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP COLUMN transaction_id;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- +goose Down
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
ADD COLUMN transaction_id INT;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
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-08-06 21:57:08 +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-08-06 21:57:08 +00:00
|
|
|
);
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
ALTER COLUMN transaction_id SET NOT NULL;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
ADD CONSTRAINT transaction_fk
|
|
|
|
FOREIGN KEY (transaction_id)
|
|
|
|
REFERENCES full_sync_transactions (id)
|
|
|
|
ON DELETE CASCADE;
|
2019-01-22 12:15:29 +00:00
|
|
|
|
2019-03-22 03:43:06 +00:00
|
|
|
ALTER TABLE full_sync_receipts
|
2019-08-06 21:57:08 +00:00
|
|
|
DROP COLUMN block_id;
|