Skip to content

Commit

Permalink
stellar#4728: review feedback, changed is_payment db type to boolean,…
Browse files Browse the repository at this point in the history
… nullable, no default
  • Loading branch information
sreuland committed Mar 17, 2023
1 parent b7f1ac8 commit f9ea51b
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 59 deletions.
2 changes: 1 addition & 1 deletion services/horizon/internal/db2/history/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (q *OperationsQ) OnlyPayments() *OperationsQ {
xdr.OperationTypePathPaymentStrictSend,
xdr.OperationTypeAccountMerge,
}},
sq.Eq{"hop.is_payment": 1}})
sq.Eq{"hop.is_payment": true}})

return q
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ func (i *operationBatchInsertBuilder) Add(
sourceAccountMuxed null.String,
isPayment bool,
) error {
dbIsPayment := 0
if isPayment {
dbIsPayment = 1
}
return i.builder.Row(ctx, map[string]interface{}{
"id": id,
"transaction_id": transactionID,
Expand All @@ -64,7 +60,7 @@ func (i *operationBatchInsertBuilder) Add(
"details": details,
"source_account": sourceAccount,
"source_account_muxed": sourceAccountMuxed,
"is_payment": dbIsPayment,
"is_payment": isPayment,
})

}
Expand Down
6 changes: 3 additions & 3 deletions services/horizon/internal/db2/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- +migrate Up

ALTER TABLE history_operations ADD is_payment smallint DEFAULT 0;
ALTER TABLE history_operations ADD is_payment boolean;
CREATE INDEX "index_history_operations_on_is_payment" ON history_operations USING btree (is_payment);

-- +migrate Down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{},
//
// SAC events that involve asset balance changes follow some standard data formats:
// The 'amount' in the event is expressed as Int128Parts, however it's expected that it's value will not be signed.
// It represents a absolute delta, the event type can provide the context of whether an amount
// It represents a absolute delta, the event type can provide the context of whether an amount
// was considered incremental or decreental, i.e. credit or debit to a balance.
//
func (operation *transactionOperationWrapper) parseAssetBalanceChangesFromContractEvents() ([]map[string]interface{}, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean
);


Expand Down Expand Up @@ -580,9 +580,9 @@ SELECT pg_catalog.setval('history_operation_participants_id_seq', 6, true);
-- Data for Name: history_operations; Type: TABLE DATA; Schema: public; Owner: -
--

INSERT INTO history_operations VALUES (12884905985, 12884905984, 1, 8, '{"into": "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "account": "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU"}', 'GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU', 1);
INSERT INTO history_operations VALUES (8589938689, 8589938688, 1, 0, '{"funder": "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", "account": "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU", "starting_balance": "1000.0000000"}', 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H', 1);
INSERT INTO history_operations VALUES (8589942785, 8589942784, 1, 0, '{"funder": "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", "account": "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "starting_balance": "1000.0000000"}', 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H', 1);
INSERT INTO history_operations VALUES (12884905985, 12884905984, 1, 8, '{"into": "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "account": "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU"}', 'GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU', true);
INSERT INTO history_operations VALUES (8589938689, 8589938688, 1, 0, '{"funder": "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", "account": "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU", "starting_balance": "1000.0000000"}', 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H', true);
INSERT INTO history_operations VALUES (8589942785, 8589942784, 1, 0, '{"funder": "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", "account": "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2", "starting_balance": "1000.0000000"}', 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H', true);


--
Expand Down
3 changes: 2 additions & 1 deletion services/horizon/internal/test/scenarios/base-horizon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -496,7 +497,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
66 changes: 33 additions & 33 deletions services/horizon/internal/test/scenarios/bindata.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -359,7 +360,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -358,10 +359,9 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


--
-- Name: history_trades; Type: TABLE; Schema: public; Owner: -
--
Expand Down
3 changes: 2 additions & 1 deletion services/horizon/internal/test/scenarios/kahuna-horizon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -497,7 +498,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -358,7 +359,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -358,7 +359,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -358,7 +359,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -358,7 +359,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -359,7 +360,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ ALTER SEQUENCE history_operation_participants_id_seq OWNED BY history_operation_
--
-- Name: history_operations; Type: TABLE; Schema: public; Owner: -
--
-- added is_payment=false default to schema, rather than change insert lines

CREATE TABLE history_operations (
id bigint NOT NULL,
Expand All @@ -381,7 +382,7 @@ CREATE TABLE history_operations (
type integer NOT NULL,
details jsonb,
source_account character varying(64) DEFAULT ''::character varying NOT NULL,
is_payment smallint default 0
is_payment boolean default false
);


Expand Down

0 comments on commit f9ea51b

Please sign in to comment.