tx inputs directly reference tx ouputs
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE btc.tx_inputs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
tx_id INTEGER NOT NULL REFERENCES btc.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
index INTEGER NOT NULL,
|
||||
witness BYTEA[],
|
||||
sig_script BYTEA NOT NULL,
|
||||
outpoint_tx_hash VARCHAR(66) REFERENCES btc.transaction_cids (tx_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
outpoint_index BIGINT NOT NULL,
|
||||
UNIQUE (tx_id, index)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE btc.tx_inputs;
|
||||
@@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE btc.tx_inputs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
tx_id INTEGER NOT NULL REFERENCES btc.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
index INTEGER NOT NULL,
|
||||
witness BYTEA[],
|
||||
sig_script BYTEA NOT NULL,
|
||||
outpoint_id INTEGER REFERENCES btc.tx_outputs (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
UNIQUE (tx_id, index)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE btc.tx_inputs;
|
||||
+3
-4
@@ -112,8 +112,7 @@ CREATE TABLE btc.tx_inputs (
|
||||
index integer NOT NULL,
|
||||
witness bytea[],
|
||||
sig_script bytea NOT NULL,
|
||||
outpoint_tx_hash character varying(66),
|
||||
outpoint_index bigint NOT NULL
|
||||
outpoint_id integer
|
||||
);
|
||||
|
||||
|
||||
@@ -1746,11 +1745,11 @@ ALTER TABLE ONLY btc.transaction_cids
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_outpoint_tx_hash_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
-- Name: tx_inputs tx_inputs_outpoint_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_inputs
|
||||
ADD CONSTRAINT tx_inputs_outpoint_tx_hash_fkey FOREIGN KEY (outpoint_tx_hash) REFERENCES btc.transaction_cids(tx_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
ADD CONSTRAINT tx_inputs_outpoint_id_fkey FOREIGN KEY (outpoint_id) REFERENCES btc.tx_outputs(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user