Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update license (#4677)

ecmadao92384376a238
diff --git a/backend/enterprise/config/config.go b/backend/enterprise/config/config.go
index 4669195b03..52437583f3 100644
--- a/backend/enterprise/config/config.go
+++ b/backend/enterprise/config/config.go
@@ -33,12 +33,10 @@ const (
issuer = "bytebase"
// audience is the license token audience.
audience = "bb.license"
- // MaximumSeat is the maximum seat limit for the FREE and TEAM plan.
- MaximumSeat = 10
+ // MaximumSeatForFreePlan is the maximum seat limit for the FREE plan.
+ MaximumSeatForFreePlan = 10
// MaximumInstanceForFreePlan is the maximum instance limit for the FREE plan.
MaximumInstanceForFreePlan = 10
- // MaximumInstanceForTeamPlan is the maximum instance limit for the TEAM plan.
- MaximumInstanceForTeamPlan = 10
)
// NewConfig will create a new enterprise config instance.
diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.go
index 498cf2c75b..ef3ec5b2a6 100644
--- a/backend/enterprise/service/license.go
+++ b/backend/enterprise/service/license.go
@@ -85,7 +85,7 @@ func (s *LicenseService) LoadSubscription(ctx context.Context) enterpriseAPI.Sub
// -1 means not expire, just for free plan
ExpiresTs: -1,
InstanceCount: config.MaximumInstanceForFreePlan,
- Seat: config.MaximumSeat,
+ Seat: config.MaximumSeatForFreePlan,
}
}
@@ -240,19 +240,8 @@ func (s *LicenseService) parseClaims(claims *Claims) (*enterpriseAPI.License, er
return nil, common.Errorf(common.Invalid, "plan type %q is not valid", planType)
}
- instanceCount := claims.InstanceCount
- seatCount := claims.Seat
- if planType == api.TEAM {
- if instanceCount > config.MaximumInstanceForTeamPlan {
- return nil, common.Errorf(common.Invalid, "license instance count '%v' is not valid, maximum instance is %d", instanceCount, config.MaximumInstanceForTeamPlan)
- }
- if seatCount > config.MaximumSeat {
- return nil, common.Errorf(common.Invalid, "license seat count '%v' is not valid, maximum seat is %d", seatCount, config.MaximumSeat)
- }
- }
-
license := &enterpriseAPI.License{
- InstanceCount: instanceCount,
+ InstanceCount: claims.InstanceCount,
Seat: claims.Seat,
ExpiresTs: claims.ExpiresAt.Unix(),
IssuedTs: claims.IssuedAt.Unix(),
diff --git a/backend/server/subscription.go b/backend/server/subscription.go
index d263400f48..154d143656 100644
--- a/backend/server/subscription.go
+++ b/backend/server/subscription.go
@@ -36,6 +36,13 @@ func (s *Server) registerSubscriptionRoutes(g *echo.Group) {
}
patch.UpdaterID = c.Get(getPrincipalIDContextKey()).(int)
+ // clear the trialing setting for dev test
+ if patch.License == "" && s.profile.Mode == common.ReleaseModeDev {
+ if err := s.store.DeleteSettingV2(ctx, api.SettingEnterpriseTrial); err != nil {
+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to delete the trialing license").SetInternal(err)
+ }
+ }
+
if err := s.licenseService.StoreLicense(ctx, patch); err != nil {
if common.ErrorCode(err) == common.Invalid {
return echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
diff --git a/backend/store/setting.go b/backend/store/setting.go
index 61f2928dd0..b5b298ad27 100644
--- a/backend/store/setting.go
+++ b/backend/store/setting.go
@@ -215,6 +215,24 @@ func (s *Store) CreateSettingIfNotExistV2(ctx context.Context, create *SettingMe
return &setting, true, nil
}
+// DeleteSettingV2 deletes a setting by the name.
+func (s *Store) DeleteSettingV2(ctx context.Context, name api.SettingName) error {
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return errors.Wrap(err, "failed to begin transaction")
+ }
+ defer tx.Rollback()
+
+ if _, err := tx.ExecContext(ctx, `DELETE FROM setting WHERE name = $1`, name); err != nil {
+ return FormatError(err)
+ }
+
+ if err := tx.Commit(); err != nil {
+ return errors.Wrap(err, "failed to commit transaction")
+ }
+ return nil
+}
+
func listSettingV2Impl(ctx context.Context, tx *Tx, find *FindSettingMessage) ([]*SettingMessage, error) {
where, args := []string{"TRUE"}, []interface{}{}
if v := find.Name; v != nil {