diff --git a/database/mock/store.go b/database/mock/store.go index 994ccc9ae6..9052bdd859 100644 --- a/database/mock/store.go +++ b/database/mock/store.go @@ -2122,18 +2122,18 @@ func (mr *MockStoreMockRecorder) Rollback(tx any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockStore)(nil).Rollback), tx) } -// SetCurrentVersion mocks base method. -func (m *MockStore) SetCurrentVersion(ctx context.Context, arg db.SetCurrentVersionParams) error { +// SetSubscriptionBundleVersion mocks base method. +func (m *MockStore) SetSubscriptionBundleVersion(ctx context.Context, arg db.SetSubscriptionBundleVersionParams) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetCurrentVersion", ctx, arg) + ret := m.ctrl.Call(m, "SetSubscriptionBundleVersion", ctx, arg) ret0, _ := ret[0].(error) return ret0 } -// SetCurrentVersion indicates an expected call of SetCurrentVersion. -func (mr *MockStoreMockRecorder) SetCurrentVersion(ctx, arg any) *gomock.Call { +// SetSubscriptionBundleVersion indicates an expected call of SetSubscriptionBundleVersion. +func (mr *MockStoreMockRecorder) SetSubscriptionBundleVersion(ctx, arg any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCurrentVersion", reflect.TypeOf((*MockStore)(nil).SetCurrentVersion), ctx, arg) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSubscriptionBundleVersion", reflect.TypeOf((*MockStore)(nil).SetSubscriptionBundleVersion), ctx, arg) } // UpdateEncryptedSecret mocks base method. diff --git a/database/query/subscriptions.sql b/database/query/subscriptions.sql index 7f81c9cab0..09a9db1852 100644 --- a/database/query/subscriptions.sql +++ b/database/query/subscriptions.sql @@ -22,9 +22,6 @@ SELECT su.* FROM subscriptions AS su JOIN bundles AS bu ON bu.id = su.bundle_id WHERE bu.namespace = $1 AND bu.name = $2 AND su.project_id = $3; --- name: SetCurrentVersion :exec -UPDATE subscriptions -SET current_version = $1 -FROM subscriptions AS su -JOIN bundles as bu ON su.bundle_id = bu.id -WHERE su.project_id = $2 AND bu.namespace = $1 AND bu.name = $2; +-- name: SetSubscriptionBundleVersion :exec +UPDATE subscriptions SET current_version = $2 WHERE project_id = $1; + diff --git a/internal/db/querier.go b/internal/db/querier.go index d4a4ba7472..3d1a971173 100644 --- a/internal/db/querier.go +++ b/internal/db/querier.go @@ -220,7 +220,7 @@ type Querier interface { // value. ReleaseLock(ctx context.Context, arg ReleaseLockParams) error RepositoryExistsAfterID(ctx context.Context, id uuid.UUID) (bool, error) - SetCurrentVersion(ctx context.Context, arg SetCurrentVersionParams) error + SetSubscriptionBundleVersion(ctx context.Context, arg SetSubscriptionBundleVersionParams) error UpdateEncryptedSecret(ctx context.Context, arg UpdateEncryptedSecretParams) error // UpdateInvitationRole updates an invitation by its code. This is intended to be // called by a user who has issued an invitation and then decided to change the diff --git a/internal/db/subscriptions.sql.go b/internal/db/subscriptions.sql.go index 3b71d23290..456e498c3d 100644 --- a/internal/db/subscriptions.sql.go +++ b/internal/db/subscriptions.sql.go @@ -77,21 +77,17 @@ func (q *Queries) GetSubscriptionByProjectBundle(ctx context.Context, arg GetSub return i, err } -const setCurrentVersion = `-- name: SetCurrentVersion :exec -UPDATE subscriptions -SET current_version = $1 -FROM subscriptions AS su -JOIN bundles as bu ON su.bundle_id = bu.id -WHERE su.project_id = $2 AND bu.namespace = $1 AND bu.name = $2 +const setSubscriptionBundleVersion = `-- name: SetSubscriptionBundleVersion :exec +UPDATE subscriptions SET current_version = $2 WHERE project_id = $1 ` -type SetCurrentVersionParams struct { - CurrentVersion string `json:"current_version"` +type SetSubscriptionBundleVersionParams struct { ProjectID uuid.UUID `json:"project_id"` + CurrentVersion string `json:"current_version"` } -func (q *Queries) SetCurrentVersion(ctx context.Context, arg SetCurrentVersionParams) error { - _, err := q.db.ExecContext(ctx, setCurrentVersion, arg.CurrentVersion, arg.ProjectID) +func (q *Queries) SetSubscriptionBundleVersion(ctx context.Context, arg SetSubscriptionBundleVersionParams) error { + _, err := q.db.ExecContext(ctx, setSubscriptionBundleVersion, arg.ProjectID, arg.CurrentVersion) return err }