Merge pull request #16 from vulcanize/vdb-380-ilks-table

(VDB-380) ilks table
This commit is contained in:
Rob Mulholand 2019-02-21 13:45:03 -06:00 committed by GitHub
commit e04a72b059
123 changed files with 885 additions and 149 deletions

View File

@ -0,0 +1,8 @@
-- +goose Up
CREATE TABLE maker.ilks (
id SERIAL PRIMARY KEY,
ilk TEXT UNIQUE
);
-- +goose Down
DROP TABLE maker.ilks;

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.frob (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
dink NUMERIC,
dart NUMERIC,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.bite (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
ink NUMERIC,
art NUMERIC,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.pit_file_ilk (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
what TEXT,
data NUMERIC,
log_idx INTEGER NOT NUll,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_init (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
log_idx INTEGER NOT NUll,
tx_idx INTEGER NOT NUll,
raw_log JSONB,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.drip_file_ilk (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
vow TEXT,
tax NUMERIC,
log_idx INTEGER NOT NUll,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.drip_drip (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
log_idx INTEGER NOT NUll,
tx_idx INTEGER NOT NUll,
raw_log JSONB,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.cat_file_chop_lump (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
what TEXT,
data NUMERIC,
tx_idx INTEGER NOT NUll,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_fold (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
rate NUMERIC,
log_idx INTEGER NOT NULL,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_toll (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
take NUMERIC,
tx_idx INTEGER NOT NULL,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_tune (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
v TEXT,
w TEXT,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_grab (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
v TEXT,
w TEXT,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_flux (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
src TEXT,
dst TEXT,
rad numeric,

View File

@ -2,7 +2,7 @@
CREATE TABLE maker.vat_slip (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
guy TEXT,
rad NUMERIC,
tx_idx INTEGER NOT NULL,

View File

@ -10,7 +10,7 @@ CREATE TABLE maker.pit_ilk_spot (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
spot NUMERIC NOT NULL
);
@ -18,7 +18,7 @@ CREATE TABLE maker.pit_ilk_line (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
line NUMERIC NOT NULL
);

View File

@ -17,7 +17,7 @@ CREATE TABLE maker.vat_ilk_art (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
art NUMERIC NOT NULL
);
@ -25,7 +25,7 @@ CREATE TABLE maker.vat_ilk_ink (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
ink NUMERIC NOT NULL
);
@ -33,7 +33,7 @@ CREATE TABLE maker.vat_ilk_rate (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
rate NUMERIC NOT NULL
);
@ -41,7 +41,7 @@ CREATE TABLE maker.vat_ilk_take (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
take NUMERIC NOT NULL
);
@ -49,7 +49,7 @@ CREATE TABLE maker.vat_urn_art (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
art TEXT
);
@ -58,7 +58,7 @@ CREATE TABLE maker.vat_urn_ink (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
urn TEXT,
ink NUMERIC NOT NULL
);
@ -67,7 +67,7 @@ CREATE TABLE maker.vat_gem (
id SERIAL PRIMARY KEY,
block_number BIGINT,
block_hash TEXT,
ilk TEXT,
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
guy TEXT,
gem NUMERIC NOT NULL
);

View File

@ -64,7 +64,7 @@ SET default_with_oids = false;
CREATE TABLE maker.bite (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
urn text,
ink numeric,
art numeric,
@ -104,7 +104,7 @@ ALTER SEQUENCE maker.bite_id_seq OWNED BY maker.bite.id;
CREATE TABLE maker.cat_file_chop_lump (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
what text,
data numeric,
tx_idx integer NOT NULL,
@ -675,7 +675,7 @@ ALTER SEQUENCE maker.dent_id_seq OWNED BY maker.dent.id;
CREATE TABLE maker.drip_drip (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
log_idx integer NOT NULL,
tx_idx integer NOT NULL,
raw_log jsonb
@ -709,7 +709,7 @@ ALTER SEQUENCE maker.drip_drip_id_seq OWNED BY maker.drip_drip.id;
CREATE TABLE maker.drip_file_ilk (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
vow text,
tax numeric,
log_idx integer NOT NULL,
@ -931,7 +931,7 @@ ALTER SEQUENCE maker.flop_kick_id_seq OWNED BY maker.flop_kick.id;
CREATE TABLE maker.frob (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
urn text,
dink numeric,
dart numeric,
@ -964,6 +964,36 @@ CREATE SEQUENCE maker.frob_id_seq
ALTER SEQUENCE maker.frob_id_seq OWNED BY maker.frob.id;
--
-- Name: ilks; Type: TABLE; Schema: maker; Owner: -
--
CREATE TABLE maker.ilks (
id integer NOT NULL,
ilk text
);
--
-- Name: ilks_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
--
CREATE SEQUENCE maker.ilks_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: ilks_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
--
ALTER SEQUENCE maker.ilks_id_seq OWNED BY maker.ilks.id;
--
-- Name: pit_drip; Type: TABLE; Schema: maker; Owner: -
--
@ -1038,7 +1068,7 @@ ALTER SEQUENCE maker.pit_file_debt_ceiling_id_seq OWNED BY maker.pit_file_debt_c
CREATE TABLE maker.pit_file_ilk (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
what text,
data numeric,
log_idx integer NOT NULL,
@ -1075,7 +1105,7 @@ CREATE TABLE maker.pit_ilk_line (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
line numeric NOT NULL
);
@ -1108,7 +1138,7 @@ CREATE TABLE maker.pit_ilk_spot (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
spot numeric NOT NULL
);
@ -1375,7 +1405,7 @@ ALTER SEQUENCE maker.vat_debt_id_seq OWNED BY maker.vat_debt.id;
CREATE TABLE maker.vat_flux (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
src text,
dst text,
rad numeric,
@ -1412,7 +1442,7 @@ ALTER SEQUENCE maker.vat_flux_id_seq OWNED BY maker.vat_flux.id;
CREATE TABLE maker.vat_fold (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
urn text,
rate numeric,
log_idx integer NOT NULL,
@ -1449,7 +1479,7 @@ CREATE TABLE maker.vat_gem (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
guy text,
gem numeric NOT NULL
);
@ -1482,7 +1512,7 @@ ALTER SEQUENCE maker.vat_gem_id_seq OWNED BY maker.vat_gem.id;
CREATE TABLE maker.vat_grab (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
urn text,
v text,
w text,
@ -1558,7 +1588,7 @@ CREATE TABLE maker.vat_ilk_art (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
art numeric NOT NULL
);
@ -1591,7 +1621,7 @@ CREATE TABLE maker.vat_ilk_ink (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
ink numeric NOT NULL
);
@ -1624,7 +1654,7 @@ CREATE TABLE maker.vat_ilk_rate (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
rate numeric NOT NULL
);
@ -1657,7 +1687,7 @@ CREATE TABLE maker.vat_ilk_take (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
take numeric NOT NULL
);
@ -1689,7 +1719,7 @@ ALTER SEQUENCE maker.vat_ilk_take_id_seq OWNED BY maker.vat_ilk_take.id;
CREATE TABLE maker.vat_init (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
log_idx integer NOT NULL,
tx_idx integer NOT NULL,
raw_log jsonb
@ -1792,7 +1822,7 @@ ALTER SEQUENCE maker.vat_sin_id_seq OWNED BY maker.vat_sin.id;
CREATE TABLE maker.vat_slip (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
guy text,
rad numeric,
tx_idx integer NOT NULL,
@ -1828,7 +1858,7 @@ ALTER SEQUENCE maker.vat_slip_id_seq OWNED BY maker.vat_slip.id;
CREATE TABLE maker.vat_toll (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
urn text,
take numeric,
tx_idx integer NOT NULL,
@ -1864,7 +1894,7 @@ ALTER SEQUENCE maker.vat_toll_id_seq OWNED BY maker.vat_toll.id;
CREATE TABLE maker.vat_tune (
id integer NOT NULL,
header_id integer NOT NULL,
ilk text,
ilk integer NOT NULL,
urn text,
v text,
w text,
@ -1904,7 +1934,7 @@ CREATE TABLE maker.vat_urn_art (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
urn text,
art text
);
@ -1938,7 +1968,7 @@ CREATE TABLE maker.vat_urn_ink (
id integer NOT NULL,
block_number bigint,
block_hash text,
ilk text,
ilk integer NOT NULL,
urn text,
ink numeric NOT NULL
);
@ -3019,6 +3049,13 @@ ALTER TABLE ONLY maker.flop_kick ALTER COLUMN id SET DEFAULT nextval('maker.flop
ALTER TABLE ONLY maker.frob ALTER COLUMN id SET DEFAULT nextval('maker.frob_id_seq'::regclass);
--
-- Name: ilks id; Type: DEFAULT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.ilks ALTER COLUMN id SET DEFAULT nextval('maker.ilks_id_seq'::regclass);
--
-- Name: pit_drip id; Type: DEFAULT; Schema: maker; Owner: -
--
@ -3710,6 +3747,22 @@ ALTER TABLE ONLY maker.frob
ADD CONSTRAINT frob_pkey PRIMARY KEY (id);
--
-- Name: ilks ilks_ilk_key; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.ilks
ADD CONSTRAINT ilks_ilk_key UNIQUE (ilk);
--
-- Name: ilks ilks_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.ilks
ADD CONSTRAINT ilks_pkey PRIMARY KEY (id);
--
-- Name: pit_drip pit_drip_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
--
@ -4320,6 +4373,14 @@ ALTER TABLE ONLY maker.bite
ADD CONSTRAINT bite_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: bite bite_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.bite
ADD CONSTRAINT bite_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: cat_file_chop_lump cat_file_chop_lump_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4328,6 +4389,14 @@ ALTER TABLE ONLY maker.cat_file_chop_lump
ADD CONSTRAINT cat_file_chop_lump_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: cat_file_chop_lump cat_file_chop_lump_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.cat_file_chop_lump
ADD CONSTRAINT cat_file_chop_lump_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: cat_file_flip cat_file_flip_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4368,6 +4437,14 @@ ALTER TABLE ONLY maker.drip_drip
ADD CONSTRAINT drip_drip_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: drip_drip drip_drip_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.drip_drip
ADD CONSTRAINT drip_drip_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: drip_file_ilk drip_file_ilk_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4376,6 +4453,14 @@ ALTER TABLE ONLY maker.drip_file_ilk
ADD CONSTRAINT drip_file_ilk_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: drip_file_ilk drip_file_ilk_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.drip_file_ilk
ADD CONSTRAINT drip_file_ilk_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: drip_file_repo drip_file_repo_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4424,6 +4509,14 @@ ALTER TABLE ONLY maker.frob
ADD CONSTRAINT frob_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: frob frob_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.frob
ADD CONSTRAINT frob_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: pit_file_debt_ceiling pit_file_debt_ceiling_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4440,6 +4533,30 @@ ALTER TABLE ONLY maker.pit_file_ilk
ADD CONSTRAINT pit_file_ilk_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: pit_file_ilk pit_file_ilk_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.pit_file_ilk
ADD CONSTRAINT pit_file_ilk_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: pit_ilk_line pit_ilk_line_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.pit_ilk_line
ADD CONSTRAINT pit_ilk_line_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: pit_ilk_spot pit_ilk_spot_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.pit_ilk_spot
ADD CONSTRAINT pit_ilk_spot_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: price_feeds price_feeds_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4464,6 +4581,14 @@ ALTER TABLE ONLY maker.vat_flux
ADD CONSTRAINT vat_flux_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_flux vat_flux_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_flux
ADD CONSTRAINT vat_flux_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_fold vat_fold_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4472,6 +4597,22 @@ ALTER TABLE ONLY maker.vat_fold
ADD CONSTRAINT vat_fold_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_fold vat_fold_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_fold
ADD CONSTRAINT vat_fold_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_gem vat_gem_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_gem
ADD CONSTRAINT vat_gem_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_grab vat_grab_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4480,6 +4621,14 @@ ALTER TABLE ONLY maker.vat_grab
ADD CONSTRAINT vat_grab_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_grab vat_grab_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_grab
ADD CONSTRAINT vat_grab_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_heal vat_heal_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4488,6 +4637,38 @@ ALTER TABLE ONLY maker.vat_heal
ADD CONSTRAINT vat_heal_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_ilk_art vat_ilk_art_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_ilk_art
ADD CONSTRAINT vat_ilk_art_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_ilk_ink vat_ilk_ink_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_ilk_ink
ADD CONSTRAINT vat_ilk_ink_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_ilk_rate vat_ilk_rate_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_ilk_rate
ADD CONSTRAINT vat_ilk_rate_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_ilk_take vat_ilk_take_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_ilk_take
ADD CONSTRAINT vat_ilk_take_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_init vat_init_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4496,6 +4677,14 @@ ALTER TABLE ONLY maker.vat_init
ADD CONSTRAINT vat_init_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_init vat_init_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_init
ADD CONSTRAINT vat_init_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_move vat_move_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4512,6 +4701,14 @@ ALTER TABLE ONLY maker.vat_slip
ADD CONSTRAINT vat_slip_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_slip vat_slip_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_slip
ADD CONSTRAINT vat_slip_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_toll vat_toll_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4520,6 +4717,14 @@ ALTER TABLE ONLY maker.vat_toll
ADD CONSTRAINT vat_toll_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_toll vat_toll_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_toll
ADD CONSTRAINT vat_toll_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_tune vat_tune_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
@ -4528,6 +4733,30 @@ ALTER TABLE ONLY maker.vat_tune
ADD CONSTRAINT vat_tune_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
--
-- Name: vat_tune vat_tune_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_tune
ADD CONSTRAINT vat_tune_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_urn_art vat_urn_art_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_urn_art
ADD CONSTRAINT vat_urn_art_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vat_urn_ink vat_urn_ink_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.vat_urn_ink
ADD CONSTRAINT vat_urn_ink_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
--
-- Name: vow_flog vow_flog_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
--

View File

@ -50,11 +50,20 @@ func (repository BiteRepository) Create(headerID int64, models []interface{}) er
return fmt.Errorf("model of type %T, not %T", model, BiteModel{})
}
ilkID, ilkErr := shared.GetOrCreateIlkInTransaction(biteModel.Ilk, tx)
if ilkErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {
log.Error("failed to rollback ", rollbackErr)
}
return ilkErr
}
_, execErr := tx.Exec(
`INSERT into maker.bite (header_id, ilk, urn, ink, art, iart, tab, nflip, log_idx, tx_idx, raw_log)
VALUES($1, $2, $3, $4::NUMERIC, $5::NUMERIC, $6::NUMERIC, $7::NUMERIC, $8::NUMERIC, $9, $10, $11)
ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET ilk = $2, urn = $3, ink = $4, art = $5, iart = $6, tab = $7, nflip = $8, raw_log = $11;`,
headerID, biteModel.Ilk, biteModel.Urn, biteModel.Ink, biteModel.Art, biteModel.IArt, biteModel.Tab, biteModel.NFlip, biteModel.LogIndex, biteModel.TransactionIndex, biteModel.Raw,
headerID, ilkID, biteModel.Urn, biteModel.Ink, biteModel.Art, biteModel.IArt, biteModel.Tab, biteModel.NFlip, biteModel.LogIndex, biteModel.TransactionIndex, biteModel.Raw,
)
if execErr != nil {
rollbackErr := tx.Rollback()

View File

@ -19,6 +19,8 @@ package bite_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
@ -67,7 +69,9 @@ var _ = Describe("Bite repository", func() {
var dbBite bite.BiteModel
err = db.Get(&dbBite, `SELECT ilk, urn, ink, art, tab, nflip, iart, log_idx, tx_idx, raw_log FROM maker.bite WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbBite.Ilk).To(Equal(test_data.BiteModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.BiteModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbBite.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbBite.Urn).To(Equal(test_data.BiteModel.Urn))
Expect(dbBite.Ink).To(Equal(test_data.BiteModel.Ink))
Expect(dbBite.Art).To(Equal(test_data.BiteModel.Art))

View File

@ -47,11 +47,20 @@ func (repository CatFileChopLumpRepository) Create(headerID int64, models []inte
return fmt.Errorf("model of type %T, not %T", model, CatFileChopLumpModel{})
}
ilkID, ilkErr := shared.GetOrCreateIlkInTransaction(chopLump.Ilk, tx)
if ilkErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {
log.Error("failed to rollback ", rollbackErr)
}
return ilkErr
}
_, execErr := tx.Exec(
`INSERT into maker.cat_file_chop_lump (header_id, ilk, what, data, tx_idx, log_idx, raw_log)
VALUES($1, $2, $3, $4::NUMERIC, $5, $6, $7)
ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET ilk = $2, what = $3, data = $4, raw_log = $7;`,
headerID, chopLump.Ilk, chopLump.What, chopLump.Data, chopLump.TransactionIndex, chopLump.LogIndex, chopLump.Raw,
headerID, ilkID, chopLump.What, chopLump.Data, chopLump.TransactionIndex, chopLump.LogIndex, chopLump.Raw,
)
if execErr != nil {
rollbackErr := tx.Rollback()

View File

@ -23,10 +23,12 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors"
"github.com/vulcanize/vulcanizedb/test_config"
"strconv"
)
var _ = Describe("Cat file chop lump repository", func() {
@ -65,7 +67,9 @@ var _ = Describe("Cat file chop lump repository", func() {
var dbResult chop_lump.CatFileChopLumpModel
err = db.Get(&dbResult, `SELECT ilk, what, data, tx_idx, log_idx, raw_log FROM maker.cat_file_chop_lump WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(test_data.CatFileChopModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.CatFileChopModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult.What).To(Equal(test_data.CatFileChopModel.What))
Expect(dbResult.Data).To(Equal(test_data.CatFileChopModel.Data))
Expect(dbResult.TransactionIndex).To(Equal(test_data.CatFileChopModel.TransactionIndex))
@ -83,7 +87,9 @@ var _ = Describe("Cat file chop lump repository", func() {
var dbResult chop_lump.CatFileChopLumpModel
err = db.Get(&dbResult, `SELECT ilk, what, data, tx_idx, log_idx, raw_log FROM maker.cat_file_chop_lump WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(test_data.CatFileLumpModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.CatFileLumpModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult.What).To(Equal(test_data.CatFileLumpModel.What))
Expect(dbResult.Data).To(Equal(test_data.CatFileLumpModel.Data))
Expect(dbResult.TransactionIndex).To(Equal(test_data.CatFileLumpModel.TransactionIndex))

View File

@ -46,11 +46,20 @@ func (repository DripDripRepository) Create(headerID int64, models []interface{}
return fmt.Errorf("model of type %T, not %T", model, DripDripModel{})
}
ilkID, ilkErr := shared.GetOrCreateIlkInTransaction(dripDrip.Ilk, tx)
if ilkErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {
log.Error("failed to rollback ", rollbackErr)
}
return ilkErr
}
_, execErr := tx.Exec(
`INSERT into maker.drip_drip (header_id, ilk, log_idx, tx_idx, raw_log)
VALUES($1, $2, $3, $4, $5)
ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET ilk= $2, raw_log = $5;`,
headerID, dripDrip.Ilk, dripDrip.LogIndex, dripDrip.TransactionIndex, dripDrip.Raw,
headerID, ilkID, dripDrip.LogIndex, dripDrip.TransactionIndex, dripDrip.Raw,
)
if execErr != nil {
rollbackErr := tx.Rollback()

View File

@ -24,10 +24,12 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_drip"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors"
"github.com/vulcanize/vulcanizedb/test_config"
"strconv"
)
var _ = Describe("Drip drip repository", func() {
@ -67,7 +69,9 @@ var _ = Describe("Drip drip repository", func() {
var dbDripDrip drip_drip.DripDripModel
err = db.Get(&dbDripDrip, `SELECT ilk, log_idx, tx_idx, raw_log FROM maker.drip_drip WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbDripDrip.Ilk).To(Equal(test_data.DripDripModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.DripDripModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbDripDrip.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbDripDrip.LogIndex).To(Equal(test_data.DripDripModel.LogIndex))
Expect(dbDripDrip.TransactionIndex).To(Equal(test_data.DripDripModel.TransactionIndex))
Expect(dbDripDrip.Raw).To(MatchJSON(test_data.DripDripModel.Raw))

View File

@ -47,10 +47,19 @@ func (repository DripFileIlkRepository) Create(headerID int64, models []interfac
return fmt.Errorf("model of type %T, not %T", model, DripFileIlkModel{})
}
ilkID, ilkErr := shared.GetOrCreateIlkInTransaction(ilk.Ilk, tx)
if ilkErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {
log.Error("failed to rollback ", rollbackErr)
}
return ilkErr
}
_, execErr := tx.Exec(
`INSERT into maker.drip_file_ilk (header_id, ilk, vow, tax, log_idx, tx_idx, raw_log)
VALUES($1, $2, $3, $4::NUMERIC, $5, $6, $7)`,
headerID, ilk.Ilk, ilk.Vow, ilk.Tax, ilk.LogIndex, ilk.TransactionIndex, ilk.Raw,
headerID, ilkID, ilk.Vow, ilk.Tax, ilk.LogIndex, ilk.TransactionIndex, ilk.Raw,
)
if execErr != nil {

View File

@ -24,10 +24,12 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors"
"github.com/vulcanize/vulcanizedb/test_config"
"strconv"
)
var _ = Describe("Drip file ilk repository", func() {
@ -67,7 +69,9 @@ var _ = Describe("Drip file ilk repository", func() {
var dbDripFileIlk ilk.DripFileIlkModel
err = db.Get(&dbDripFileIlk, `SELECT ilk, vow, tax, log_idx, tx_idx, raw_log FROM maker.drip_file_ilk WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbDripFileIlk.Ilk).To(Equal(test_data.DripFileIlkModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.DripFileIlkModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbDripFileIlk.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbDripFileIlk.Vow).To(Equal(test_data.DripFileIlkModel.Vow))
Expect(dbDripFileIlk.Tax).To(Equal(test_data.DripFileIlkModel.Tax))
Expect(dbDripFileIlk.LogIndex).To(Equal(test_data.DripFileIlkModel.LogIndex))

View File

@ -45,10 +45,19 @@ func (repository FrobRepository) Create(headerID int64, models []interface{}) er
return fmt.Errorf("model of type %T, not %T", model, FrobModel{})
}
ilkID, ilkErr := shared.GetOrCreateIlkInTransaction(frobModel.Ilk, tx)
if ilkErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {
log.Error("failed to rollback ", rollbackErr)
}
return ilkErr
}
_, execErr := tx.Exec(`INSERT INTO maker.frob (header_id, art, dart, dink, iart, ilk, ink, urn, raw_log, log_idx, tx_idx)
VALUES($1, $2::NUMERIC, $3::NUMERIC, $4::NUMERIC, $5::NUMERIC, $6, $7::NUMERIC, $8, $9, $10, $11)
ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET art = $2, dart = $3, dink = $4, iart = $5, ilk = $6, ink = $7, urn = $8, raw_log = $9;`,
headerID, frobModel.Art, frobModel.Dart, frobModel.Dink, frobModel.IArt, frobModel.Ilk, frobModel.Ink, frobModel.Urn, frobModel.Raw, frobModel.LogIndex, frobModel.TransactionIndex)
headerID, frobModel.Art, frobModel.Dart, frobModel.Dink, frobModel.IArt, ilkID, frobModel.Ink, frobModel.Urn, frobModel.Raw, frobModel.LogIndex, frobModel.TransactionIndex)
if execErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {

View File

@ -19,6 +19,8 @@ package frob_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
@ -67,7 +69,9 @@ var _ = Describe("Frob repository", func() {
err = db.Get(&dbFrob, `SELECT art, dart, dink, iart, ilk, ink, urn, log_idx, tx_idx, raw_log FROM maker.frob WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbFrob.Ilk).To(Equal(test_data.FrobModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.FrobModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbFrob.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbFrob.Urn).To(Equal(test_data.FrobModel.Urn))
Expect(dbFrob.Ink).To(Equal(test_data.FrobModel.Ink))
Expect(dbFrob.Art).To(Equal(test_data.FrobModel.Art))

View File

@ -19,6 +19,7 @@ package integration_tests
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
@ -83,7 +84,9 @@ var _ = Describe("Bite Transformer", func() {
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Art).To(Equal("149846666666666655744"))
Expect(dbResult[0].IArt).To(Equal("1645356666666666655736"))
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Ink).To(Equal("1000000000000000000"))
Expect(dbResult[0].NFlip).To(Equal("2"))
Expect(dbResult[0].Tab).To(Equal("149846666666666655744"))

View File

@ -23,6 +23,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"sort"
"strconv"
"github.com/ethereum/go-ethereum/ethclient"
. "github.com/onsi/ginkgo"
@ -97,12 +98,14 @@ var _ = Describe("Cat File transformer", func() {
Expect(len(dbResult)).To(Equal(2))
sort.Sort(byLogIndexChopLump(dbResult))
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].What).To(Equal("lump"))
Expect(dbResult[0].Data).To(Equal("10000.000000000000000000"))
Expect(dbResult[0].LogIndex).To(Equal(uint(3)))
Expect(dbResult[1].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
Expect(dbResult[1].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[1].What).To(Equal("chop"))
Expect(dbResult[1].Data).To(Equal("1.000000000000000000000000000"))
Expect(dbResult[1].LogIndex).To(Equal(uint(4)))

View File

@ -25,6 +25,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_drip"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
@ -86,7 +87,9 @@ var _ = Describe("DripDrip Transformer", func() {
Expect(len(dbResults)).To(Equal(1))
dbResult := dbResults[0]
Expect(dbResult.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
})
It("rechecks drip drip event", func() {

View File

@ -21,6 +21,7 @@ import (
"github.com/ethereum/go-ethereum/common"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
@ -94,7 +95,9 @@ var _ = Describe("Frob Transformer", func() {
Expect(dbResult[0].Dart).To(Equal("0"))
Expect(dbResult[0].Dink).To(Equal("10000000000000"))
Expect(dbResult[0].IArt).To(Equal("1495509999999999999992"))
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Ink).To(Equal("10050100000000000"))
Expect(dbResult[0].Urn).To(Equal("000000000000000000000000c8e093e5f3f9b5aa6a6b33ea45960b93c161430c"))
})
@ -139,7 +142,9 @@ var _ = Describe("Frob Transformer", func() {
Expect(dbResult[0].Dart).To(Equal("0"))
Expect(dbResult[0].Dink).To(Equal("10000000000000"))
Expect(dbResult[0].IArt).To(Equal("1495509999999999999992"))
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Ink).To(Equal("10050100000000000"))
Expect(dbResult[0].Urn).To(Equal("000000000000000000000000c8e093e5f3f9b5aa6a6b33ea45960b93c161430c"))
})

View File

@ -24,6 +24,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
@ -87,7 +88,9 @@ var _ = Describe("PitFileIlk LogNoteTransformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("0x4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].What).To(Equal("spot"))
Expect(dbResult[0].Data).To(Equal("139.840000000000003410605131648"))
})
@ -126,7 +129,9 @@ var _ = Describe("PitFileIlk LogNoteTransformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("0x4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].What).To(Equal("spot"))
Expect(dbResult[0].Data).To(Equal("139.840000000000003410605131648"))
})
@ -158,7 +163,9 @@ var _ = Describe("PitFileIlk LogNoteTransformer", func() {
pitFileIlkLineModel = result
}
}
Expect(pitFileIlkLineModel.Ilk).To(Equal("0x5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(pitFileIlkLineModel.Data).To(Equal("2000000.000000000000000000"))
})
})

View File

@ -22,6 +22,7 @@ import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
@ -74,7 +75,9 @@ var _ = Describe("VatFlux LogNoteTransformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Src).To(Equal("000000000000000000000000c0851f73cc8dd5c0765e71980ec7e7fd1ef74434"))
Expect(dbResult[0].Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
Expect(dbResult[0].Rad).To(Equal("1800000000000000000000000000000000000000000000"))
@ -138,7 +141,9 @@ var _ = Describe("VatFlux LogNoteTransformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Src).To(Equal("000000000000000000000000c0851f73cc8dd5c0765e71980ec7e7fd1ef74434"))
Expect(dbResult[0].Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
Expect(dbResult[0].Rad).To(Equal("1800000000000000000000000000000000000000000000"))

View File

@ -25,6 +25,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/test_config"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
@ -82,7 +83,9 @@ var _ = Describe("VatFold Transformer", func() {
Expect(len(dbResults)).To(Equal(1))
dbResult := dbResults[0]
Expect(dbResult.Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
Expect(dbResult.Rate).To(Equal("0.000000000000000000000000000"))
})
@ -136,7 +139,9 @@ var _ = Describe("VatFold Transformer", func() {
Expect(len(dbResults)).To(Equal(1))
dbResult := dbResults[0]
Expect(dbResult.Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
Expect(dbResult.Rate).To(Equal("0.000000000000000000000000000"))
})

View File

@ -21,6 +21,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"math/big"
"strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -75,7 +76,9 @@ var _ = Describe("Vat Grab Transformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c"))
Expect(dbResult[0].V).To(Equal("0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0")) //cat contract address as bytes32
Expect(dbResult[0].W).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
@ -143,7 +146,9 @@ var _ = Describe("Vat Grab Transformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("5245500000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c"))
Expect(dbResult[0].V).To(Equal("0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0")) //cat contract address
Expect(dbResult[0].W).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))

View File

@ -24,6 +24,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init"
"github.com/vulcanize/vulcanizedb/test_config"
@ -74,7 +75,9 @@ var _ = Describe("VatInit LogNoteTransformer", func() {
Expect(len(dbResults)).To(Equal(1))
dbResult := dbResults[0]
Expect(dbResult.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
})
It("rechecks vat init event", func() {
@ -134,6 +137,8 @@ var _ = Describe("VatInit LogNoteTransformer", func() {
Expect(len(dbResults)).To(Equal(1))
dbResult := dbResults[0]
Expect(dbResult.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.Ilk).To(Equal(strconv.Itoa(ilkID)))
})
})

View File

@ -6,6 +6,7 @@ import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
@ -66,7 +67,9 @@ var _ = Describe("Vat slip transformer", func() {
var model vat_slip.VatSlipModel
err = db.Get(&model, `SELECT ilk, guy, rad, tx_idx FROM maker.vat_slip WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(model.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(model.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(model.Guy).To(Equal("000000000000000000000000da15dce70ab462e66779f23ee14f21d993789ee3"))
Expect(model.Rad).To(Equal("100000000000000000000000000000000000000000000000"))
Expect(model.TransactionIndex).To(Equal(uint(0)))
@ -124,7 +127,9 @@ var _ = Describe("Vat slip transformer", func() {
var model vat_slip.VatSlipModel
err = db.Get(&model, `SELECT ilk, guy, rad, tx_idx FROM maker.vat_slip WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(model.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(model.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(model.Guy).To(Equal("000000000000000000000000da15dce70ab462e66779f23ee14f21d993789ee3"))
Expect(model.Rad).To(Equal("100000000000000000000000000000000000000000000000"))
Expect(model.TransactionIndex).To(Equal(uint(0)))

View File

@ -21,6 +21,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"math/big"
"strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -75,7 +76,9 @@ var _ = Describe("VatTune LogNoteTransformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
Expect(dbResult[0].V).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
Expect(dbResult[0].W).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
@ -142,7 +145,9 @@ var _ = Describe("VatTune LogNoteTransformer", func() {
Expect(err).NotTo(HaveOccurred())
Expect(len(dbResult)).To(Equal(1))
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
ilkID, err := shared.GetOrCreateIlk("4554480000000000000000000000000000000000000000000000000000000000", db)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult[0].Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
Expect(dbResult[0].V).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
Expect(dbResult[0].W).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))

View File

@ -37,7 +37,7 @@ func (PitFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error)
if err != nil {
return nil, err
}
ilk := ethLog.Topics[2].Hex()
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
dataBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:]
data, err := getData(dataBytes, what)

View File

@ -47,11 +47,20 @@ func (repository PitFileIlkRepository) Create(headerID int64, models []interface
return fmt.Errorf("model of type %T, not %T", model, PitFileIlkModel{})
}
ilkID, ilkErr := shared.GetOrCreateIlkInTransaction(pitFileIlk.Ilk, tx)
if ilkErr != nil {
rollbackErr := tx.Rollback()
if rollbackErr != nil {
log.Error("failed to rollback ", rollbackErr)
}
return ilkErr
}
_, execErr := tx.Exec(
`INSERT into maker.pit_file_ilk (header_id, ilk, what, data, log_idx, tx_idx, raw_log)
VALUES($1, $2, $3, $4::NUMERIC, $5, $6, $7)
ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET ilk = $2, what = $3, data = $4, raw_log = $7;`,
headerID, pitFileIlk.Ilk, pitFileIlk.What, pitFileIlk.Data, pitFileIlk.LogIndex, pitFileIlk.TransactionIndex, pitFileIlk.Raw,
headerID, ilkID, pitFileIlk.What, pitFileIlk.Data, pitFileIlk.LogIndex, pitFileIlk.TransactionIndex, pitFileIlk.Raw,
)
if execErr != nil {
rollbackErr := tx.Rollback()

View File

@ -19,6 +19,8 @@ package ilk_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"strconv"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
@ -67,7 +69,9 @@ var _ = Describe("Pit file ilk repository", func() {
var dbPitFile ilk.PitFileIlkModel
err = db.Get(&dbPitFile, `SELECT ilk, what, data, log_idx, tx_idx, raw_log FROM maker.pit_file_ilk WHERE header_id = $1`, headerID)
Expect(err).NotTo(HaveOccurred())
Expect(dbPitFile.Ilk).To(Equal(test_data.PitFileIlkSpotModel.Ilk))
ilkID, err := shared.GetOrCreateIlk(test_data.PitFileIlkSpotModel.Ilk, db)
Expect(err).NotTo(HaveOccurred())
Expect(dbPitFile.Ilk).To(Equal(strconv.Itoa(ilkID)))
Expect(dbPitFile.What).To(Equal(test_data.PitFileIlkSpotModel.What))
Expect(dbPitFile.Data).To(Equal(test_data.PitFileIlkSpotModel.Data))
Expect(dbPitFile.LogIndex).To(Equal(test_data.PitFileIlkSpotModel.LogIndex))

Some files were not shown because too many files have changed in this diff Show More