-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription Internals V2 #1851
Conversation
1df72dc
to
0e7a9ea
Compare
4b22a4e
to
fdcda89
Compare
1267792
to
6575f86
Compare
field.String("key").NotEmpty().Immutable(), | ||
field.String("name").NotEmpty(), | ||
field.String("description").Optional().Nillable(), | ||
field.Time("active_from").Immutable(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need an optional active_to? Or that coming from rate cards somehow? If yes why do we need active_from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the current spec, a subscription cannot have a state where there isn't an active phase, unless the subscription itself is inactive (cancelled etc...) it's just a simple way of guaranteeing it
return []ent.Edge{ | ||
edge.From("subscription", Subscription.Type).Field("subscription_id").Ref("phases").Unique().Immutable().Required(), | ||
edge.To("items", SubscriptionItem.Type), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add a unqiue index for subscription_id + phase key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a unique index for subscription_id + phase_key + deletedAt (taking into account that deletedAt is nillable)
openmeter/ent/schema/subscription.go
Outdated
func (SubscriptionItem) Edges() []ent.Edge { | ||
return []ent.Edge{ | ||
edge.From("phase", SubscriptionPhase.Type).Field("phase_id").Ref("items").Unique().Immutable().Required(), | ||
edge.To("entitlements", SubscriptionEntitlement.Type), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we define db field to be entitlement_id
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, now that SubscriptionItem is materialized we can do away with the linking table
openmeter/ent/schema/subscription.go
Outdated
GoType(datex.ISOString("")).Nillable().Optional(), | ||
field.String("key").NotEmpty().Immutable(), | ||
field.String("rate_card"). | ||
GoType(&subscription.RateCard{}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason it's not materialized? In product catalog rate card is materialized:
https://github.com/openmeterio/openmeter/blob/main/openmeter/ent/schema/productcatalog.go#L119
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now mainly for simplicity and time saving. ProductCatalog models (like RateCard) should be made available for use outside of those packages which is currently not possible, the subscription.RateCard
should disappear once that is resolved. I'd be much happier to reuse the exact code used in Plan for much of this, but you're right that's not a requirement, I'm happy to normalize it if you'd like, it's just a bit of double work, but there's already quite a bit of double work happening so that doesn't have to be an issue.
6575f86
to
212a44a
Compare
feat: subscription creation wireframing refactor: move subscriptions out of productcatalog refactor: fresh start feat(subs): define interfaces and subpackages feat(subs): write individual patches feat: implement patch serialization feat: db structure for patches fix(subs): date use in patches fix: date use in subscription patches chore: uncomment methods fix: fix rebase issues feat(subs): subscription creation and patch saving feat: add entitlement annotations feat: write patch saving feat: subscriptionView feat: write db schema for patches feat(subs): write entity mappings for repository feat(subs): implement and test create and read feat: implement price test: write command and query builders test: subscription creation without customizations test(subs): test creation with customizations refactor(sub): marry command and query feat(subs): write syncing test: test entity syncing feat: test editing and fix rebase errors chore: generate migrations chore: remove dangling execs fix: use patch timestamp instead of operation timestamp for validations chore: remove dead code fix(lint): fix lint errors feat: incorporate new price types chore: undo me test(subs): service create and view tests feat(subs): define workflow service fix(subs): consolidate key and id use when linking things refactor(test): rewrite tests to use ent schema upserts feat(subscription): guard managed entitlements feat(subscription): write first version of workflow service fix(subs): rebase errors feat(subs): add statemation to control transitions feat(subs): cancelation and continuing refactor(subs): calculate item cadence from itemSpec refactor(subs): remove CadencedModel from SubscriptionItem and make its cadence relative to phase feat(subs): implement correct editing of current phase refactor(subs): use custom RateCard type feat(subs): add validations for Spec and View feat(subs): add back CadencedModel to SubscriptionItem chore: generate migrations fix(e2e): fix e2e tests to use non-ulid featureKey refactor(subs): normalize RateCard refactor(subs): regenerate migrations docs(*): rename and document item relative cadence refactor(subs): remove subscription_entitlement table
212a44a
to
4085c33
Compare
Overview
Supersedes #1732
Includes internal APIs for subscription Management
SubscriptionXSpec
&SubscriptionXView
interfacesNotes for reviewer
openmeter/subscriptions
is included in application startup.