tenseleyflow/shithub / b69331f

Browse files

sqlc: regenerate models for user_plan + user_billing_states + polymorphic columns

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
b69331fc56e78fd23573c7d29eabbecba6492ca0
Parents
08109a4
Tree
6ea2c18

16 changed files

StatusFile+-
M internal/actions/sqlc/models.go 112 1
M internal/admin/sqlc/models.go 112 1
M internal/billing/sqlc/models.go 112 1
M internal/checks/sqlc/models.go 112 1
M internal/issues/sqlc/models.go 112 1
M internal/meta/sqlc/models.go 112 1
M internal/notif/sqlc/models.go 112 1
M internal/orgs/sqlc/models.go 112 1
M internal/pulls/sqlc/models.go 112 1
M internal/ratelimit/sqlc/models.go 112 1
M internal/repos/sqlc/models.go 112 1
M internal/social/sqlc/models.go 112 1
M internal/users/sqlc/models.go 112 1
M internal/users/sqlc/users.sql.go 10 5
M internal/webhook/sqlc/models.go 112 1
M internal/worker/sqlc/models.go 112 1
internal/actions/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/admin/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/billing/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/checks/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/issues/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/meta/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/notif/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/orgs/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/pulls/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/ratelimit/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/repos/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/social/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/users/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/users/sqlc/users.sql.gomodified
@@ -53,7 +53,7 @@ const createUser = `-- name: CreateUser :one
5353
 
5454
 INSERT INTO users (username, display_name, password_hash)
5555
 VALUES ($1, $2, $3)
56
-RETURNING id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions
56
+RETURNING id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions, plan
5757
 `
5858
 
5959
 type CreateUserParams struct {
@@ -91,12 +91,13 @@ func (q *Queries) CreateUser(ctx context.Context, db DBTX, arg CreateUserParams)
9191
 		&i.SessionEpoch,
9292
 		&i.IsSiteAdmin,
9393
 		&i.IncludePrivateContributions,
94
+		&i.Plan,
9495
 	)
9596
 	return i, err
9697
 }
9798
 
9899
 const getUserByID = `-- name: GetUserByID :one
99
-SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions
100
+SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions, plan
100101
 FROM users
101102
 WHERE id = $1 AND deleted_at IS NULL
102103
 `
@@ -129,12 +130,13 @@ func (q *Queries) GetUserByID(ctx context.Context, db DBTX, id int64) (User, err
129130
 		&i.SessionEpoch,
130131
 		&i.IsSiteAdmin,
131132
 		&i.IncludePrivateContributions,
133
+		&i.Plan,
132134
 	)
133135
 	return i, err
134136
 }
135137
 
136138
 const getUserByUsername = `-- name: GetUserByUsername :one
137
-SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions
139
+SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions, plan
138140
 FROM users
139141
 WHERE username = $1 AND deleted_at IS NULL
140142
 `
@@ -167,12 +169,13 @@ func (q *Queries) GetUserByUsername(ctx context.Context, db DBTX, username strin
167169
 		&i.SessionEpoch,
168170
 		&i.IsSiteAdmin,
169171
 		&i.IncludePrivateContributions,
172
+		&i.Plan,
170173
 	)
171174
 	return i, err
172175
 }
173176
 
174177
 const getUserByUsernameIncludingDeleted = `-- name: GetUserByUsernameIncludingDeleted :one
175
-SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions FROM users WHERE username = $1
178
+SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions, plan FROM users WHERE username = $1
176179
 `
177180
 
178181
 func (q *Queries) GetUserByUsernameIncludingDeleted(ctx context.Context, db DBTX, username string) (User, error) {
@@ -203,12 +206,13 @@ func (q *Queries) GetUserByUsernameIncludingDeleted(ctx context.Context, db DBTX
203206
 		&i.SessionEpoch,
204207
 		&i.IsSiteAdmin,
205208
 		&i.IncludePrivateContributions,
209
+		&i.Plan,
206210
 	)
207211
 	return i, err
208212
 }
209213
 
210214
 const getUserIncludingDeleted = `-- name: GetUserIncludingDeleted :one
211
-SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions FROM users WHERE id = $1
215
+SELECT id, username, display_name, primary_email_id, password_hash, password_algo, password_updated_at, email_verified, last_login_at, suspended_at, suspended_reason, deleted_at, created_at, updated_at, bio, location, website, company, pronouns, avatar_object_key, theme, session_epoch, is_site_admin, include_private_contributions, plan FROM users WHERE id = $1
212216
 `
213217
 
214218
 // Like GetUserByID but returns the row even when deleted_at IS NOT NULL.
@@ -240,6 +244,7 @@ func (q *Queries) GetUserIncludingDeleted(ctx context.Context, db DBTX, id int64
240244
 		&i.SessionEpoch,
241245
 		&i.IsSiteAdmin,
242246
 		&i.IncludePrivateContributions,
247
+		&i.Plan,
243248
 	)
244249
 	return i, err
245250
 }
internal/webhook/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {
internal/worker/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185185
 	return string(ns.BillingProvider), nil
186186
 }
187187
 
188
+type BillingSubjectKind string
189
+
190
+const (
191
+	BillingSubjectKindUser BillingSubjectKind = "user"
192
+	BillingSubjectKindOrg  BillingSubjectKind = "org"
193
+)
194
+
195
+func (e *BillingSubjectKind) Scan(src interface{}) error {
196
+	switch s := src.(type) {
197
+	case []byte:
198
+		*e = BillingSubjectKind(s)
199
+	case string:
200
+		*e = BillingSubjectKind(s)
201
+	default:
202
+		return fmt.Errorf("unsupported scan type for BillingSubjectKind: %T", src)
203
+	}
204
+	return nil
205
+}
206
+
207
+type NullBillingSubjectKind struct {
208
+	BillingSubjectKind BillingSubjectKind
209
+	Valid              bool // Valid is true if BillingSubjectKind is not NULL
210
+}
211
+
212
+// Scan implements the Scanner interface.
213
+func (ns *NullBillingSubjectKind) Scan(value interface{}) error {
214
+	if value == nil {
215
+		ns.BillingSubjectKind, ns.Valid = "", false
216
+		return nil
217
+	}
218
+	ns.Valid = true
219
+	return ns.BillingSubjectKind.Scan(value)
220
+}
221
+
222
+// Value implements the driver Valuer interface.
223
+func (ns NullBillingSubjectKind) Value() (driver.Value, error) {
224
+	if !ns.Valid {
225
+		return nil, nil
226
+	}
227
+	return string(ns.BillingSubjectKind), nil
228
+}
229
+
188230
 type BillingSubscriptionStatus string
189231
 
190232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
14011443
 	return string(ns.TrendingScope), nil
14021444
 }
14031445
 
1446
+type UserPlan string
1447
+
1448
+const (
1449
+	UserPlanFree UserPlan = "free"
1450
+	UserPlanPro  UserPlan = "pro"
1451
+)
1452
+
1453
+func (e *UserPlan) Scan(src interface{}) error {
1454
+	switch s := src.(type) {
1455
+	case []byte:
1456
+		*e = UserPlan(s)
1457
+	case string:
1458
+		*e = UserPlan(s)
1459
+	default:
1460
+		return fmt.Errorf("unsupported scan type for UserPlan: %T", src)
1461
+	}
1462
+	return nil
1463
+}
1464
+
1465
+type NullUserPlan struct {
1466
+	UserPlan UserPlan
1467
+	Valid    bool // Valid is true if UserPlan is not NULL
1468
+}
1469
+
1470
+// Scan implements the Scanner interface.
1471
+func (ns *NullUserPlan) Scan(value interface{}) error {
1472
+	if value == nil {
1473
+		ns.UserPlan, ns.Valid = "", false
1474
+		return nil
1475
+	}
1476
+	ns.Valid = true
1477
+	return ns.UserPlan.Scan(value)
1478
+}
1479
+
1480
+// Value implements the driver Valuer interface.
1481
+func (ns NullUserPlan) Value() (driver.Value, error) {
1482
+	if !ns.Valid {
1483
+		return nil, nil
1484
+	}
1485
+	return string(ns.UserPlan), nil
1486
+}
1487
+
14041488
 type WatchLevel string
14051489
 
14061490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
18631947
 
18641948
 type BillingInvoice struct {
18651949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
18671951
 	Provider             BillingProvider
18681952
 	StripeInvoiceID      string
18691953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
18831967
 	VoidedAt             pgtype.Timestamptz
18841968
 	CreatedAt            pgtype.Timestamptz
18851969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
18861972
 }
18871973
 
18881974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
19071993
 	ProcessedAt        pgtype.Timestamptz
19081994
 	ProcessError       string
19091995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
19101998
 }
19111999
 
19122000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
26272715
 	SessionEpoch                int32
26282716
 	IsSiteAdmin                 bool
26292717
 	IncludePrivateContributions bool
2718
+	Plan                        UserPlan
2719
+}
2720
+
2721
+type UserBillingState struct {
2722
+	UserID                   int64
2723
+	Provider                 BillingProvider
2724
+	StripeCustomerID         pgtype.Text
2725
+	StripeSubscriptionID     pgtype.Text
2726
+	StripeSubscriptionItemID pgtype.Text
2727
+	Plan                     UserPlan
2728
+	SubscriptionStatus       BillingSubscriptionStatus
2729
+	CurrentPeriodStart       pgtype.Timestamptz
2730
+	CurrentPeriodEnd         pgtype.Timestamptz
2731
+	CancelAtPeriodEnd        bool
2732
+	TrialEnd                 pgtype.Timestamptz
2733
+	PastDueAt                pgtype.Timestamptz
2734
+	CanceledAt               pgtype.Timestamptz
2735
+	LockedAt                 pgtype.Timestamptz
2736
+	LockReason               NullBillingLockReason
2737
+	GraceUntil               pgtype.Timestamptz
2738
+	LastWebhookEventID       string
2739
+	CreatedAt                pgtype.Timestamptz
2740
+	UpdatedAt                pgtype.Timestamptz
26302741
 }
26312742
 
26322743
 type UserEmail struct {