@@ -19,6 +19,7 @@ type monitorSubRow struct {
1919 AutoOrder int `db:"auto_order"`
2020 Quantity int `db:"quantity"`
2121 AutoOrderAccountID string `db:"auto_order_account_id"`
22+ AutoPay int `db:"auto_pay"`
2223}
2324
2425func rowToMonitorSub (r monitorSubRow ) types.Subscription {
@@ -43,6 +44,7 @@ func rowToMonitorSub(r monitorSubRow) types.Subscription {
4344 AutoOrder : r .AutoOrder == 1 ,
4445 Quantity : r .Quantity ,
4546 AutoOrderAccountID : r .AutoOrderAccountID ,
47+ AutoPay : r .AutoPay == 1 ,
4648 }
4749}
4850
@@ -86,6 +88,7 @@ func monitorSubToRow(s types.Subscription) (monitorSubRow, error) {
8688 AutoOrder : bi (s .AutoOrder ),
8789 Quantity : s .Quantity ,
8890 AutoOrderAccountID : s .AutoOrderAccountID ,
91+ AutoPay : bi (s .AutoPay ),
8992 }, nil
9093}
9194
@@ -114,10 +117,10 @@ func (db *DB) UpsertMonitorSubscription(s types.Subscription) error {
114117 _ , err = db .NamedExec (`
115118 INSERT INTO monitor_subscriptions
116119 (plan_code, datacenters, notify_available, notify_unavailable, last_status,
117- created_at, history, server_name, auto_order, quantity, auto_order_account_id)
120+ created_at, history, server_name, auto_order, quantity, auto_order_account_id, auto_pay )
118121 VALUES
119122 (:plan_code, :datacenters, :notify_available, :notify_unavailable, :last_status,
120- :created_at, :history, :server_name, :auto_order, :quantity, :auto_order_account_id)
123+ :created_at, :history, :server_name, :auto_order, :quantity, :auto_order_account_id, :auto_pay )
121124 ON CONFLICT(plan_code) DO UPDATE SET
122125 datacenters = excluded.datacenters,
123126 notify_available = excluded.notify_available,
@@ -127,7 +130,8 @@ func (db *DB) UpsertMonitorSubscription(s types.Subscription) error {
127130 server_name = excluded.server_name,
128131 auto_order = excluded.auto_order,
129132 quantity = excluded.quantity,
130- auto_order_account_id = excluded.auto_order_account_id
133+ auto_order_account_id = excluded.auto_order_account_id,
134+ auto_pay = excluded.auto_pay
131135 ` , r )
132136 if err != nil {
133137 return fmt .Errorf ("upsert monitor sub %s: %w" , s .PlanCode , err )
@@ -153,10 +157,10 @@ func (db *DB) ReplaceMonitorSubscriptions(subs []types.Subscription) error {
153157 _ , err = tx .NamedExec (`
154158 INSERT INTO monitor_subscriptions
155159 (plan_code, datacenters, notify_available, notify_unavailable, last_status,
156- created_at, history, server_name, auto_order, quantity, auto_order_account_id)
160+ created_at, history, server_name, auto_order, quantity, auto_order_account_id, auto_pay )
157161 VALUES
158162 (:plan_code, :datacenters, :notify_available, :notify_unavailable, :last_status,
159- :created_at, :history, :server_name, :auto_order, :quantity, :auto_order_account_id)
163+ :created_at, :history, :server_name, :auto_order, :quantity, :auto_order_account_id, :auto_pay )
160164 ` , r )
161165 if err != nil {
162166 return fmt .Errorf ("insert monitor sub %s: %w" , s .PlanCode , err )
0 commit comments