Skip to content

Commit

Permalink
satellite/satellitedb: Add coupon_codes table and allow optional link…
Browse files Browse the repository at this point in the history
… to coupons table

The coupon_codes table will allow for administrators to create new promo
codes associated with coupon information (amount, duration, etc...).

A user will be able to enter a promo code (aka coupon code) in order to
apply a new coupon to their account. The coupon in the coupons table is
linked to the template defined in the coupon_codes table.

Change-Id: I50e49fa92afbc6aa9d01d8a895c069efb59e472b
  • Loading branch information
mobyvb committed Mar 19, 2021
1 parent c3ae122 commit 78e132c
Show file tree
Hide file tree
Showing 8 changed files with 1,160 additions and 44 deletions.
1 change: 1 addition & 0 deletions satellite/satellitedb/coupons.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (coupons *coupons) Insert(ctx context.Context, coupon payments.Coupon) (_ p
dbx.Coupon_Type(int(coupon.Type)),
dbx.Coupon_Status(int(coupon.Status)),
dbx.Coupon_Duration(int64(coupon.Duration)),
dbx.Coupon_Create_Fields{},
)
if err != nil {
return payments.Coupon{}, err
Expand Down
24 changes: 24 additions & 0 deletions satellite/satellitedb/dbx/satellitedb.dbx
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,29 @@ read one (
where stripecoinpayments_tx_conversion_rate.tx_id = ?
)

model coupon_code (
key id
unique name

field id blob
field name text
field amount int64
field description text
field type int
field duration int64

field created_at timestamp ( autoinsert )
)

create coupon_code ()
delete coupon_code (
where coupon_code.name = ?
)
read one (
select coupon_code
where coupon_code.name = ?
)

model coupon (
key id

Expand All @@ -1101,6 +1124,7 @@ model coupon (
field type int
field status int ( updatable )
field duration int64
field coupon_code_name text ( nullable )

field created_at timestamp ( autoinsert )
)
Expand Down

0 comments on commit 78e132c

Please sign in to comment.