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) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/admin/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/billing/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/checks/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/issues/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/meta/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/notif/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/orgs/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/pulls/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/ratelimit/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/repos/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/social/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/users/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/users/sqlc/users.sql.gomodified
@@ -53,7 +53,7 @@ const createUser = `-- name: CreateUser :one
53
 
53
 
54
 INSERT INTO users (username, display_name, password_hash)
54
 INSERT INTO users (username, display_name, password_hash)
55
 VALUES ($1, $2, $3)
55
 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
57
 `
57
 `
58
 
58
 
59
 type CreateUserParams struct {
59
 type CreateUserParams struct {
@@ -91,12 +91,13 @@ func (q *Queries) CreateUser(ctx context.Context, db DBTX, arg CreateUserParams)
91
 		&i.SessionEpoch,
91
 		&i.SessionEpoch,
92
 		&i.IsSiteAdmin,
92
 		&i.IsSiteAdmin,
93
 		&i.IncludePrivateContributions,
93
 		&i.IncludePrivateContributions,
94
+		&i.Plan,
94
 	)
95
 	)
95
 	return i, err
96
 	return i, err
96
 }
97
 }
97
 
98
 
98
 const getUserByID = `-- name: GetUserByID :one
99
 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
100
 FROM users
101
 FROM users
101
 WHERE id = $1 AND deleted_at IS NULL
102
 WHERE id = $1 AND deleted_at IS NULL
102
 `
103
 `
@@ -129,12 +130,13 @@ func (q *Queries) GetUserByID(ctx context.Context, db DBTX, id int64) (User, err
129
 		&i.SessionEpoch,
130
 		&i.SessionEpoch,
130
 		&i.IsSiteAdmin,
131
 		&i.IsSiteAdmin,
131
 		&i.IncludePrivateContributions,
132
 		&i.IncludePrivateContributions,
133
+		&i.Plan,
132
 	)
134
 	)
133
 	return i, err
135
 	return i, err
134
 }
136
 }
135
 
137
 
136
 const getUserByUsername = `-- name: GetUserByUsername :one
138
 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
138
 FROM users
140
 FROM users
139
 WHERE username = $1 AND deleted_at IS NULL
141
 WHERE username = $1 AND deleted_at IS NULL
140
 `
142
 `
@@ -167,12 +169,13 @@ func (q *Queries) GetUserByUsername(ctx context.Context, db DBTX, username strin
167
 		&i.SessionEpoch,
169
 		&i.SessionEpoch,
168
 		&i.IsSiteAdmin,
170
 		&i.IsSiteAdmin,
169
 		&i.IncludePrivateContributions,
171
 		&i.IncludePrivateContributions,
172
+		&i.Plan,
170
 	)
173
 	)
171
 	return i, err
174
 	return i, err
172
 }
175
 }
173
 
176
 
174
 const getUserByUsernameIncludingDeleted = `-- name: GetUserByUsernameIncludingDeleted :one
177
 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
176
 `
179
 `
177
 
180
 
178
 func (q *Queries) GetUserByUsernameIncludingDeleted(ctx context.Context, db DBTX, username string) (User, error) {
181
 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
203
 		&i.SessionEpoch,
206
 		&i.SessionEpoch,
204
 		&i.IsSiteAdmin,
207
 		&i.IsSiteAdmin,
205
 		&i.IncludePrivateContributions,
208
 		&i.IncludePrivateContributions,
209
+		&i.Plan,
206
 	)
210
 	)
207
 	return i, err
211
 	return i, err
208
 }
212
 }
209
 
213
 
210
 const getUserIncludingDeleted = `-- name: GetUserIncludingDeleted :one
214
 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
212
 `
216
 `
213
 
217
 
214
 // Like GetUserByID but returns the row even when deleted_at IS NOT NULL.
218
 // 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
240
 		&i.SessionEpoch,
244
 		&i.SessionEpoch,
241
 		&i.IsSiteAdmin,
245
 		&i.IsSiteAdmin,
242
 		&i.IncludePrivateContributions,
246
 		&i.IncludePrivateContributions,
247
+		&i.Plan,
243
 	)
248
 	)
244
 	return i, err
249
 	return i, err
245
 }
250
 }
internal/webhook/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {
internal/worker/sqlc/models.gomodified
@@ -185,6 +185,48 @@ func (ns NullBillingProvider) Value() (driver.Value, error) {
185
 	return string(ns.BillingProvider), nil
185
 	return string(ns.BillingProvider), nil
186
 }
186
 }
187
 
187
 
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
+
188
 type BillingSubscriptionStatus string
230
 type BillingSubscriptionStatus string
189
 
231
 
190
 const (
232
 const (
@@ -1401,6 +1443,48 @@ func (ns NullTrendingScope) Value() (driver.Value, error) {
1401
 	return string(ns.TrendingScope), nil
1443
 	return string(ns.TrendingScope), nil
1402
 }
1444
 }
1403
 
1445
 
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
+
1404
 type WatchLevel string
1488
 type WatchLevel string
1405
 
1489
 
1406
 const (
1490
 const (
@@ -1863,7 +1947,7 @@ type AuthThrottle struct {
1863
 
1947
 
1864
 type BillingInvoice struct {
1948
 type BillingInvoice struct {
1865
 	ID                   int64
1949
 	ID                   int64
1866
-	OrgID                int64
1950
+	OrgID                pgtype.Int8
1867
 	Provider             BillingProvider
1951
 	Provider             BillingProvider
1868
 	StripeInvoiceID      string
1952
 	StripeInvoiceID      string
1869
 	StripeCustomerID     string
1953
 	StripeCustomerID     string
@@ -1883,6 +1967,8 @@ type BillingInvoice struct {
1883
 	VoidedAt             pgtype.Timestamptz
1967
 	VoidedAt             pgtype.Timestamptz
1884
 	CreatedAt            pgtype.Timestamptz
1968
 	CreatedAt            pgtype.Timestamptz
1885
 	UpdatedAt            pgtype.Timestamptz
1969
 	UpdatedAt            pgtype.Timestamptz
1970
+	SubjectKind          BillingSubjectKind
1971
+	SubjectID            int64
1886
 }
1972
 }
1887
 
1973
 
1888
 type BillingSeatSnapshot struct {
1974
 type BillingSeatSnapshot struct {
@@ -1907,6 +1993,8 @@ type BillingWebhookEvent struct {
1907
 	ProcessedAt        pgtype.Timestamptz
1993
 	ProcessedAt        pgtype.Timestamptz
1908
 	ProcessError       string
1994
 	ProcessError       string
1909
 	ProcessingAttempts int32
1995
 	ProcessingAttempts int32
1996
+	SubjectKind        NullBillingSubjectKind
1997
+	SubjectID          pgtype.Int8
1910
 }
1998
 }
1911
 
1999
 
1912
 type BranchProtectionRule struct {
2000
 type BranchProtectionRule struct {
@@ -2627,6 +2715,29 @@ type User struct {
2627
 	SessionEpoch                int32
2715
 	SessionEpoch                int32
2628
 	IsSiteAdmin                 bool
2716
 	IsSiteAdmin                 bool
2629
 	IncludePrivateContributions bool
2717
 	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
2630
 }
2741
 }
2631
 
2742
 
2632
 type UserEmail struct {
2743
 type UserEmail struct {