Update tend, flipkick and dent tables for consistency (#24)

This commit is contained in:
Elizabeth 2018-09-18 09:27:14 -05:00 committed by GitHub
parent 06881db350
commit 60901d9095
10 changed files with 69 additions and 50 deletions

View File

@ -1,13 +1,14 @@
CREATE TABLE maker.flip_kick (
db_id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
id NUMERIC NOT NULL UNIQUE,
lot NUMERIC,
bid NUMERIC,
gal VARCHAR,
"end" TIMESTAMP WITH TIME ZONE,
urn VARCHAR,
tab NUMERIC,
tx_idx INTEGER NOT NUll,
raw_log JSONB
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
bid_id NUMERIC NOT NULL,
lot NUMERIC,
bid NUMERIC,
gal VARCHAR,
"end" TIMESTAMP WITH TIME ZONE,
urn VARCHAR,
tab NUMERIC,
tx_idx INTEGER NOT NUll,
raw_log JSONB,
UNIQUE (header_id, tx_idx)
);

View File

@ -1,5 +1,5 @@
CREATE TABLE maker.tend (
db_id SERIAL PRIMARY KEY,
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
bid_id NUMERIC NOT NULL UNIQUE,
lot NUMERIC,
@ -7,5 +7,6 @@ CREATE TABLE maker.tend (
guy VARCHAR,
tic NUMERIC,
tx_idx INTEGER NOT NUll,
raw_log JSONB
raw_log JSONB,
UNIQUE (header_id, tx_idx)
);

View File

@ -1,5 +1,5 @@
CREATE TABLE maker.dent (
db_id SERIAL PRIMARY KEY,
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
bid_id NUMERIC NOT NULL UNIQUE,
lot NUMERIC,
@ -7,5 +7,6 @@ CREATE TABLE maker.dent (
guy BYTEA,
tic NUMERIC,
tx_idx INTEGER NOT NUll,
raw_log JSONB
raw_log JSONB,
UNIQUE (header_id, tx_idx)
);

View File

@ -133,7 +133,7 @@ ALTER SEQUENCE maker.deal_id_seq OWNED BY maker.deal.id;
--
CREATE TABLE maker.dent (
db_id integer NOT NULL,
id integer NOT NULL,
header_id integer NOT NULL,
bid_id numeric NOT NULL,
lot numeric,
@ -146,10 +146,10 @@ CREATE TABLE maker.dent (
--
-- Name: dent_db_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
-- Name: dent_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
--
CREATE SEQUENCE maker.dent_db_id_seq
CREATE SEQUENCE maker.dent_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -159,10 +159,10 @@ CREATE SEQUENCE maker.dent_db_id_seq
--
-- Name: dent_db_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
-- Name: dent_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
--
ALTER SEQUENCE maker.dent_db_id_seq OWNED BY maker.dent.db_id;
ALTER SEQUENCE maker.dent_id_seq OWNED BY maker.dent.id;
--
@ -306,9 +306,9 @@ ALTER SEQUENCE maker.drip_file_vow_id_seq OWNED BY maker.drip_file_vow.id;
--
CREATE TABLE maker.flip_kick (
db_id integer NOT NULL,
id integer NOT NULL,
header_id integer NOT NULL,
id numeric NOT NULL,
bid_id numeric NOT NULL,
lot numeric,
bid numeric,
gal character varying,
@ -321,10 +321,10 @@ CREATE TABLE maker.flip_kick (
--
-- Name: flip_kick_db_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
-- Name: flip_kick_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
--
CREATE SEQUENCE maker.flip_kick_db_id_seq
CREATE SEQUENCE maker.flip_kick_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -334,10 +334,10 @@ CREATE SEQUENCE maker.flip_kick_db_id_seq
--
-- Name: flip_kick_db_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
-- Name: flip_kick_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
--
ALTER SEQUENCE maker.flip_kick_db_id_seq OWNED BY maker.flip_kick.db_id;
ALTER SEQUENCE maker.flip_kick_id_seq OWNED BY maker.flip_kick.id;
--
@ -522,7 +522,7 @@ ALTER SEQUENCE maker.price_feeds_id_seq OWNED BY maker.price_feeds.id;
--
CREATE TABLE maker.tend (
db_id integer NOT NULL,
id integer NOT NULL,
header_id integer NOT NULL,
bid_id numeric NOT NULL,
lot numeric,
@ -535,10 +535,10 @@ CREATE TABLE maker.tend (
--
-- Name: tend_db_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
-- Name: tend_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
--
CREATE SEQUENCE maker.tend_db_id_seq
CREATE SEQUENCE maker.tend_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -548,10 +548,10 @@ CREATE SEQUENCE maker.tend_db_id_seq
--
-- Name: tend_db_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
-- Name: tend_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
--
ALTER SEQUENCE maker.tend_db_id_seq OWNED BY maker.tend.db_id;
ALTER SEQUENCE maker.tend_id_seq OWNED BY maker.tend.id;
--
@ -1005,10 +1005,10 @@ ALTER TABLE ONLY maker.deal ALTER COLUMN id SET DEFAULT nextval('maker.deal_id_s
--
-- Name: dent db_id; Type: DEFAULT; Schema: maker; Owner: -
-- Name: dent id; Type: DEFAULT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.dent ALTER COLUMN db_id SET DEFAULT nextval('maker.dent_db_id_seq'::regclass);
ALTER TABLE ONLY maker.dent ALTER COLUMN id SET DEFAULT nextval('maker.dent_id_seq'::regclass);
--
@ -1040,10 +1040,10 @@ ALTER TABLE ONLY maker.drip_file_vow ALTER COLUMN id SET DEFAULT nextval('maker.
--
-- Name: flip_kick db_id; Type: DEFAULT; Schema: maker; Owner: -
-- Name: flip_kick id; Type: DEFAULT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.flip_kick ALTER COLUMN db_id SET DEFAULT nextval('maker.flip_kick_db_id_seq'::regclass);
ALTER TABLE ONLY maker.flip_kick ALTER COLUMN id SET DEFAULT nextval('maker.flip_kick_id_seq'::regclass);
--
@ -1082,10 +1082,10 @@ ALTER TABLE ONLY maker.price_feeds ALTER COLUMN id SET DEFAULT nextval('maker.pr
--
-- Name: tend db_id; Type: DEFAULT; Schema: maker; Owner: -
-- Name: tend id; Type: DEFAULT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.tend ALTER COLUMN db_id SET DEFAULT nextval('maker.tend_db_id_seq'::regclass);
ALTER TABLE ONLY maker.tend ALTER COLUMN id SET DEFAULT nextval('maker.tend_id_seq'::regclass);
--
@ -1205,12 +1205,20 @@ ALTER TABLE ONLY maker.dent
ADD CONSTRAINT dent_bid_id_key UNIQUE (bid_id);
--
-- Name: dent dent_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.dent
ADD CONSTRAINT dent_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
--
-- Name: dent dent_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.dent
ADD CONSTRAINT dent_pkey PRIMARY KEY (db_id);
ADD CONSTRAINT dent_pkey PRIMARY KEY (id);
--
@ -1278,11 +1286,11 @@ ALTER TABLE ONLY maker.drip_file_vow
--
-- Name: flip_kick flip_kick_id_key; Type: CONSTRAINT; Schema: maker; Owner: -
-- Name: flip_kick flip_kick_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.flip_kick
ADD CONSTRAINT flip_kick_id_key UNIQUE (id);
ADD CONSTRAINT flip_kick_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
--
@ -1290,7 +1298,7 @@ ALTER TABLE ONLY maker.flip_kick
--
ALTER TABLE ONLY maker.flip_kick
ADD CONSTRAINT flip_kick_pkey PRIMARY KEY (db_id);
ADD CONSTRAINT flip_kick_pkey PRIMARY KEY (id);
--
@ -1381,12 +1389,20 @@ ALTER TABLE ONLY maker.tend
ADD CONSTRAINT tend_bid_id_key UNIQUE (bid_id);
--
-- Name: tend tend_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.tend
ADD CONSTRAINT tend_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
--
-- Name: tend tend_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
--
ALTER TABLE ONLY maker.tend
ADD CONSTRAINT tend_pkey PRIMARY KEY (db_id);
ADD CONSTRAINT tend_pkey PRIMARY KEY (id);
--

View File

@ -73,7 +73,7 @@ func (FlipKickConverter) ToModel(flipKick FlipKickEntity) (FlipKickModel, error)
rawLogString := string(rawLogJson)
return FlipKickModel{
Id: id,
BidId: id,
Lot: lot,
Bid: bid,
Gal: gal,

View File

@ -81,7 +81,7 @@ var _ = Describe("FlipKick Converter", func() {
model, err := converter.ToModel(emptyEntity)
Expect(err).NotTo(HaveOccurred())
Expect(model.Id).To(Equal("1"))
Expect(model.BidId).To(Equal("1"))
Expect(model.Lot).To(Equal(emptyString))
Expect(model.Bid).To(Equal(emptyString))
Expect(model.Gal).To(Equal(emptyAddressHex))

View File

@ -17,7 +17,7 @@ package flip_kick
import "time"
type FlipKickModel struct {
Id string
BidId string `db:"bid_id"`
Lot string
Bid string
Gal string

View File

@ -35,9 +35,9 @@ func NewFlipKickRepository(db *postgres.DB) FlipKickRepository {
}
func (fkr FlipKickRepository) Create(headerId int64, flipKick FlipKickModel) error {
_, err := fkr.DB.Exec(
`INSERT into maker.flip_kick (header_id, id, lot, bid, gal, "end", urn, tab, tx_idx, raw_log)
`INSERT into maker.flip_kick (header_id, bid_id, lot, bid, gal, "end", urn, tab, tx_idx, raw_log)
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
headerId, flipKick.Id, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.TransactionIndex, flipKick.Raw,
headerId, flipKick.BidId, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.TransactionIndex, flipKick.Raw,
)
return err
}

View File

@ -64,7 +64,7 @@ var _ = Describe("FlipKick Repository", func() {
err = flipKickRepository.DB.QueryRowx(`SELECT * FROM maker.flip_kick`).StructScan(&dbResult)
Expect(err).NotTo(HaveOccurred())
Expect(dbResult.HeaderId).To(Equal(headerId))
Expect(dbResult.Id).To(Equal(flipKick.Id))
Expect(dbResult.BidId).To(Equal(flipKick.BidId))
Expect(dbResult.Lot).To(Equal(flipKick.Lot))
Expect(dbResult.Bid).To(Equal(flipKick.Bid))
Expect(dbResult.Gal).To(Equal(flipKick.Gal))

View File

@ -80,7 +80,7 @@ var FlipKickEntity = flip_kick.FlipKickEntity{
}
var FlipKickModel = flip_kick.FlipKickModel{
Id: idString,
BidId: idString,
Lot: lotString,
Bid: bidString,
Gal: gal,
@ -92,7 +92,7 @@ var FlipKickModel = flip_kick.FlipKickModel{
}
type FlipKickDBRow struct {
DbID int64 `db:"db_id"`
ID int64
HeaderId int64 `db:"header_id"`
flip_kick.FlipKickModel
}