forked from cerc-io/ipld-eth-server
Rename transactions to full_sync_transactions
- Table has foreign key to blocks - Add transaction RLP and transaction index to table - Enables other tables with standalone transactions or transactions associated with other data structures (e.g. headers)
This commit is contained in:
+6
-4
@@ -1,16 +1,18 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE transactions (
|
||||
CREATE TABLE full_sync_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),
|
||||
input_data VARCHAR,
|
||||
nonce NUMERIC,
|
||||
raw BYTEA,
|
||||
tx_from VARCHAR(66),
|
||||
tx_index INTEGER,
|
||||
tx_to VARCHAR(66),
|
||||
"value" NUMERIC
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE transactions;
|
||||
DROP TABLE full_sync_transactions;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX block_id_index ON full_sync_transactions (block_id);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX block_id_index;
|
||||
@@ -1,5 +0,0 @@
|
||||
-- +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 tx_to_index ON full_sync_transactions(tx_to);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX tx_to_index;
|
||||
@@ -1,5 +0,0 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX tx_to_index ON transactions(tx_to);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX tx_to_index;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX tx_from_index ON full_sync_transactions(tx_from);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX tx_from_index;
|
||||
@@ -1,5 +0,0 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX tx_from_index ON transactions(tx_from);
|
||||
|
||||
-- +goose Down
|
||||
DROP INDEX tx_from_index;
|
||||
@@ -2,16 +2,13 @@
|
||||
CREATE TABLE receipts
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
transaction_id INTEGER NOT NULL REFERENCES full_sync_transactions (id) ON DELETE CASCADE,
|
||||
contract_address VARCHAR(42),
|
||||
cumulative_gas_used NUMERIC,
|
||||
gas_used NUMERIC,
|
||||
state_root VARCHAR(66),
|
||||
status INTEGER,
|
||||
tx_hash VARCHAR(66),
|
||||
CONSTRAINT transaction_fk FOREIGN KEY (transaction_id)
|
||||
REFERENCES transactions (id)
|
||||
ON DELETE CASCADE
|
||||
tx_hash VARCHAR(66)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ ALTER TABLE receipts
|
||||
|
||||
UPDATE receipts
|
||||
SET block_id = (
|
||||
SELECT block_id FROM transactions WHERE transactions.id = receipts.transaction_id
|
||||
SELECT block_id FROM full_sync_transactions WHERE full_sync_transactions.id = receipts.transaction_id
|
||||
);
|
||||
|
||||
ALTER TABLE receipts
|
||||
@@ -28,7 +28,7 @@ CREATE INDEX transaction_id_index ON receipts (transaction_id);
|
||||
|
||||
UPDATE receipts
|
||||
SET transaction_id = (
|
||||
SELECT id FROM transactions WHERE transactions.hash = receipts.tx_hash
|
||||
SELECT id FROM full_sync_transactions WHERE full_sync_transactions.hash = receipts.tx_hash
|
||||
);
|
||||
|
||||
ALTER TABLE receipts
|
||||
@@ -37,7 +37,7 @@ ALTER TABLE receipts
|
||||
ALTER TABLE receipts
|
||||
ADD CONSTRAINT transaction_fk
|
||||
FOREIGN KEY (transaction_id)
|
||||
REFERENCES transactions (id)
|
||||
REFERENCES full_sync_transactions (id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE receipts
|
||||
|
||||
Reference in New Issue
Block a user