Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: use free plan quota for trial (#7604)
ecmadaoa5dbedb0f3c1
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.goindex 224efb5073..5962ac3d39 100644--- a/backend/api/v1/auth_service.go+++ b/backend/api/v1/auth_service.go@@ -909,7 +909,7 @@ func generateRecoveryCodes(n int) ([]string, error) {}func (s *AuthService) userCountGuard(ctx context.Context) error {- userLimit := s.licenseService.GetPlanLimitValue(enterpriseAPI.PlanLimitMaximumUser)+ userLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumUser)count, err := s.store.CountPrincipal(ctx)if err != nil {diff --git a/backend/api/v1/environment_service.go b/backend/api/v1/environment_service.goindex f63a52c351..b7b8780f0b 100644--- a/backend/api/v1/environment_service.go+++ b/backend/api/v1/environment_service.go@@ -71,7 +71,7 @@ func (s *EnvironmentService) CreateEnvironment(ctx context.Context, request *v1pif err != nil {return nil, status.Errorf(codes.Internal, err.Error())}- maximumEnvironmentLimit := s.licenseService.GetPlanLimitValue(enterpriseAPI.PlanLimitMaximumEnvironment)+ maximumEnvironmentLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumEnvironment)if int64(len(environments)) >= maximumEnvironmentLimit {return nil, status.Errorf(codes.ResourceExhausted, "current plan can create up to %d environments.", maximumEnvironmentLimit)}diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex 26c9333be5..33ad9579a2 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -923,7 +923,7 @@ func (s *InstanceService) convertToDataSourceMessage(dataSource *v1pb.DataSource}func (s *InstanceService) instanceCountGuard(ctx context.Context) error {- instanceLimit := s.licenseService.GetPlanLimitValue(enterpriseAPI.PlanLimitMaximumInstance)+ instanceLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumInstance)count, err := s.store.CountInstance(ctx, &store.CountInstanceMessage{})if err != nil {diff --git a/backend/enterprise/api/license.go b/backend/enterprise/api/license.goindex e74991db8e..f0796e545c 100644--- a/backend/enterprise/api/license.go+++ b/backend/enterprise/api/license.go@@ -70,7 +70,7 @@ type LicenseService interface {// GetEffectivePlan gets the effective plan.GetEffectivePlan() api.PlanType// GetPlanLimitValue gets the limit value for the plan.- GetPlanLimitValue(name PlanLimit) int64+ GetPlanLimitValue(ctx context.Context, name PlanLimit) int64// GetInstanceLicenseCount returns the instance count limit for current subscription.GetInstanceLicenseCount(ctx context.Context) int// RefreshCache will invalidate and refresh the subscription cache.diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.goindex 69fde4f507..f7c442c022 100644--- a/backend/enterprise/service/license.go+++ b/backend/enterprise/service/license.go@@ -155,12 +155,19 @@ func (s *LicenseService) GetEffectivePlan() api.PlanType {}// GetPlanLimitValue gets the limit value for the plan.-func (s *LicenseService) GetPlanLimitValue(name enterpriseAPI.PlanLimit) int64 {+func (s *LicenseService) GetPlanLimitValue(ctx context.Context, name enterpriseAPI.PlanLimit) int64 {v, ok := enterpriseAPI.PlanLimitValues[name]if !ok {return 0}- limit := v[s.GetEffectivePlan()]++ subscription := s.LoadSubscription(ctx)++ limit := v[subscription.Plan]+ if subscription.Trialing {+ limit = v[api.FREE]+ }+if limit == -1 {return math.MaxInt64}diff --git a/backend/server/issue.go b/backend/server/issue.goindex e445113f6a..6ea8ff4b8c 100644--- a/backend/server/issue.go+++ b/backend/server/issue.go@@ -973,7 +973,7 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Conreturn nil, echo.NewHTTPError(http.StatusForbidden, err.Error())}}- maximumTaskLimit := s.licenseService.GetPlanLimitValue(enterpriseAPI.PlanLimitMaximumTask)+ maximumTaskLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumTask)if int64(databaseIDCount) > maximumTaskLimit {return nil, echo.NewHTTPError(http.StatusForbidden, fmt.Sprintf("Current plan can update up to %d databases, got %d.", maximumTaskLimit, databaseIDCount))}diff --git a/frontend/src/store/modules/v1/subscription.ts b/frontend/src/store/modules/v1/subscription.tsindex 823b05a1d4..4bd69944ca 100644--- a/frontend/src/store/modules/v1/subscription.ts+++ b/frontend/src/store/modules/v1/subscription.ts@@ -33,10 +33,18 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {}),getters: {instanceCountLimit(state): number {- return instanceCountLimit.get(this.currentPlan) ?? 0;+ let plan = this.currentPlan;+ if (this.isTrialing) {+ plan = PlanType.FREE;+ }+ return instanceCountLimit.get(plan) ?? 0;},userCountLimit(state): number {- return userCountLimit.get(this.currentPlan) ?? 0;+ let plan = this.currentPlan;+ if (this.isTrialing) {+ plan = PlanType.FREE;+ }+ return userCountLimit.get(plan) ?? 0;},instanceLicenseCount(state): number {const count = state.subscription?.instanceCount ?? 0;