fix(review): harden payment, oauth, and migration paths
This commit is contained in:
@@ -361,7 +361,7 @@ var (
|
||||
Symbol: "auth_identities_users_auth_identities",
|
||||
Columns: []*schema.Column{AuthIdentitiesColumns[9]},
|
||||
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
@@ -405,7 +405,7 @@ var (
|
||||
Symbol: "auth_identity_channels_auth_identities_channels",
|
||||
Columns: []*schema.Column{AuthIdentityChannelsColumns[9]},
|
||||
RefColumns: []*schema.Column{AuthIdentitiesColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
@@ -595,7 +595,7 @@ var (
|
||||
Symbol: "identity_adoption_decisions_pending_auth_sessions_adoption_decision",
|
||||
Columns: []*schema.Column{IdentityAdoptionDecisionsColumns[7]},
|
||||
RefColumns: []*schema.Column{PendingAuthSessionsColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
@@ -692,8 +692,11 @@ var (
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "paymentorder_out_trade_no",
|
||||
Unique: false,
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{PaymentOrdersColumns[8]},
|
||||
Annotation: &entsql.IndexAnnotation{
|
||||
Where: "out_trade_no <> ''",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "paymentorder_user_id",
|
||||
|
||||
@@ -79,7 +79,8 @@ func (AuthIdentity) Edges() []ent.Edge {
|
||||
Field("user_id").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("channels", AuthIdentityChannel.Type),
|
||||
edge.To("channels", AuthIdentityChannel.Type).
|
||||
Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
edge.To("adoption_decisions", IdentityAdoptionDecision.Type),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,9 @@ func (PaymentOrder) Edges() []ent.Edge {
|
||||
|
||||
func (PaymentOrder) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("out_trade_no"),
|
||||
index.Fields("out_trade_no").
|
||||
Unique().
|
||||
Annotations(entsql.IndexWhere("out_trade_no <> ''")),
|
||||
index.Fields("user_id"),
|
||||
index.Fields("status"),
|
||||
index.Fields("expires_at"),
|
||||
|
||||
@@ -119,6 +119,7 @@ func (PendingAuthSession) Edges() []ent.Edge {
|
||||
Field("target_user_id").
|
||||
Unique(),
|
||||
edge.To("adoption_decision", IdentityAdoptionDecision.Type).
|
||||
Annotations(entsql.OnDelete(entsql.Cascade)).
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,8 @@ func (User) Edges() []ent.Edge {
|
||||
edge.To("attribute_values", UserAttributeValue.Type),
|
||||
edge.To("promo_code_usages", PromoCodeUsage.Type),
|
||||
edge.To("payment_orders", PaymentOrder.Type),
|
||||
edge.To("auth_identities", AuthIdentity.Type),
|
||||
edge.To("auth_identities", AuthIdentity.Type).
|
||||
Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
edge.To("pending_auth_sessions", PendingAuthSession.Type),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user