From 4437d7e8e87820d6839cd002a722a8e30c6e74eb Mon Sep 17 00:00:00 2001 From: Radoslav Dimitrov Date: Fri, 26 Jan 2024 14:52:07 +0200 Subject: [PATCH] Drop the artifact_versions table The artifact versions are no longer used and the code is also pushed to the prod SaaS. Let's just remove the table and the associated API. Signed-off-by: Radoslav Dimitrov --- .../000018_artifact_versions.down.sql | 27 ++ .../000018_artifact_versions.up.sql | 15 + database/mock/store.go | 118 -------- database/query/artifact_versions.sql | 63 ---- internal/db/artifact_versions.sql.go | 276 ------------------ internal/db/models.go | 12 - internal/db/querier.go | 8 - 7 files changed, 42 insertions(+), 477 deletions(-) create mode 100644 database/migrations/000018_artifact_versions.down.sql create mode 100644 database/migrations/000018_artifact_versions.up.sql delete mode 100644 database/query/artifact_versions.sql delete mode 100644 internal/db/artifact_versions.sql.go diff --git a/database/migrations/000018_artifact_versions.down.sql b/database/migrations/000018_artifact_versions.down.sql new file mode 100644 index 0000000000..b6ad218e8e --- /dev/null +++ b/database/migrations/000018_artifact_versions.down.sql @@ -0,0 +1,27 @@ +-- Copyright 2024 Stacklok, Inc +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +-- artifact versions table +CREATE TABLE artifact_versions ( + id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY, + artifact_id UUID NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE, + version BIGINT NOT NULL, + tags TEXT, + sha TEXT NOT NULL, + signature_verification JSONB, -- see /proto/minder/v1/minder.proto#L82 + github_workflow JSONB, -- see /proto/minder/v1/minder.proto#L75 + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE UNIQUE INDEX artifact_versions_idx ON artifact_versions (artifact_id, sha); diff --git a/database/migrations/000018_artifact_versions.up.sql b/database/migrations/000018_artifact_versions.up.sql new file mode 100644 index 0000000000..9226341b0b --- /dev/null +++ b/database/migrations/000018_artifact_versions.up.sql @@ -0,0 +1,15 @@ +-- Copyright 2024 Stacklok, Inc +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +DROP TABLE IF EXISTS artifact_versions CASCADE; diff --git a/database/mock/store.go b/database/mock/store.go index b4f60969d7..8a29efd8a4 100644 --- a/database/mock/store.go +++ b/database/mock/store.go @@ -171,21 +171,6 @@ func (mr *MockStoreMockRecorder) CreateArtifact(arg0, arg1 interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateArtifact", reflect.TypeOf((*MockStore)(nil).CreateArtifact), arg0, arg1) } -// CreateArtifactVersion mocks base method. -func (m *MockStore) CreateArtifactVersion(arg0 context.Context, arg1 db.CreateArtifactVersionParams) (db.ArtifactVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateArtifactVersion", arg0, arg1) - ret0, _ := ret[0].(db.ArtifactVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateArtifactVersion indicates an expected call of CreateArtifactVersion. -func (mr *MockStoreMockRecorder) CreateArtifactVersion(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateArtifactVersion", reflect.TypeOf((*MockStore)(nil).CreateArtifactVersion), arg0, arg1) -} - // CreateOrganization mocks base method. func (m *MockStore) CreateOrganization(arg0 context.Context, arg1 db.CreateOrganizationParams) (db.Project, error) { m.ctrl.T.Helper() @@ -379,20 +364,6 @@ func (mr *MockStoreMockRecorder) DeleteArtifact(arg0, arg1 interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteArtifact", reflect.TypeOf((*MockStore)(nil).DeleteArtifact), arg0, arg1) } -// DeleteArtifactVersion mocks base method. -func (m *MockStore) DeleteArtifactVersion(arg0 context.Context, arg1 uuid.UUID) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteArtifactVersion", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// DeleteArtifactVersion indicates an expected call of DeleteArtifactVersion. -func (mr *MockStoreMockRecorder) DeleteArtifactVersion(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteArtifactVersion", reflect.TypeOf((*MockStore)(nil).DeleteArtifactVersion), arg0, arg1) -} - // DeleteExpiredSessionStates mocks base method. func (m *MockStore) DeleteExpiredSessionStates(arg0 context.Context) error { m.ctrl.T.Helper() @@ -407,20 +378,6 @@ func (mr *MockStoreMockRecorder) DeleteExpiredSessionStates(arg0 interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteExpiredSessionStates", reflect.TypeOf((*MockStore)(nil).DeleteExpiredSessionStates), arg0) } -// DeleteOldArtifactVersions mocks base method. -func (m *MockStore) DeleteOldArtifactVersions(arg0 context.Context, arg1 db.DeleteOldArtifactVersionsParams) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteOldArtifactVersions", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// DeleteOldArtifactVersions indicates an expected call of DeleteOldArtifactVersions. -func (mr *MockStoreMockRecorder) DeleteOldArtifactVersions(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOldArtifactVersions", reflect.TypeOf((*MockStore)(nil).DeleteOldArtifactVersions), arg0, arg1) -} - // DeleteOrganization mocks base method. func (m *MockStore) DeleteOrganization(arg0 context.Context, arg1 uuid.UUID) error { m.ctrl.T.Helper() @@ -709,36 +666,6 @@ func (mr *MockStoreMockRecorder) GetArtifactByName(arg0, arg1 interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetArtifactByName", reflect.TypeOf((*MockStore)(nil).GetArtifactByName), arg0, arg1) } -// GetArtifactVersionByID mocks base method. -func (m *MockStore) GetArtifactVersionByID(arg0 context.Context, arg1 uuid.UUID) (db.ArtifactVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetArtifactVersionByID", arg0, arg1) - ret0, _ := ret[0].(db.ArtifactVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetArtifactVersionByID indicates an expected call of GetArtifactVersionByID. -func (mr *MockStoreMockRecorder) GetArtifactVersionByID(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetArtifactVersionByID", reflect.TypeOf((*MockStore)(nil).GetArtifactVersionByID), arg0, arg1) -} - -// GetArtifactVersionBySha mocks base method. -func (m *MockStore) GetArtifactVersionBySha(arg0 context.Context, arg1 string) (db.ArtifactVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetArtifactVersionBySha", arg0, arg1) - ret0, _ := ret[0].(db.ArtifactVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetArtifactVersionBySha indicates an expected call of GetArtifactVersionBySha. -func (mr *MockStoreMockRecorder) GetArtifactVersionBySha(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetArtifactVersionBySha", reflect.TypeOf((*MockStore)(nil).GetArtifactVersionBySha), arg0, arg1) -} - // GetChildrenProjects mocks base method. func (m *MockStore) GetChildrenProjects(arg0 context.Context, arg1 uuid.UUID) ([]db.GetChildrenProjectsRow, error) { m.ctrl.T.Helper() @@ -1308,36 +1235,6 @@ func (mr *MockStoreMockRecorder) ListAllRepositories(arg0, arg1 interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAllRepositories", reflect.TypeOf((*MockStore)(nil).ListAllRepositories), arg0, arg1) } -// ListArtifactVersionsByArtifactID mocks base method. -func (m *MockStore) ListArtifactVersionsByArtifactID(arg0 context.Context, arg1 db.ListArtifactVersionsByArtifactIDParams) ([]db.ArtifactVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListArtifactVersionsByArtifactID", arg0, arg1) - ret0, _ := ret[0].([]db.ArtifactVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListArtifactVersionsByArtifactID indicates an expected call of ListArtifactVersionsByArtifactID. -func (mr *MockStoreMockRecorder) ListArtifactVersionsByArtifactID(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListArtifactVersionsByArtifactID", reflect.TypeOf((*MockStore)(nil).ListArtifactVersionsByArtifactID), arg0, arg1) -} - -// ListArtifactVersionsByArtifactIDAndTag mocks base method. -func (m *MockStore) ListArtifactVersionsByArtifactIDAndTag(arg0 context.Context, arg1 db.ListArtifactVersionsByArtifactIDAndTagParams) ([]db.ArtifactVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListArtifactVersionsByArtifactIDAndTag", arg0, arg1) - ret0, _ := ret[0].([]db.ArtifactVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListArtifactVersionsByArtifactIDAndTag indicates an expected call of ListArtifactVersionsByArtifactIDAndTag. -func (mr *MockStoreMockRecorder) ListArtifactVersionsByArtifactIDAndTag(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListArtifactVersionsByArtifactIDAndTag", reflect.TypeOf((*MockStore)(nil).ListArtifactVersionsByArtifactIDAndTag), arg0, arg1) -} - // ListArtifactsByRepoID mocks base method. func (m *MockStore) ListArtifactsByRepoID(arg0 context.Context, arg1 uuid.UUID) ([]db.Artifact, error) { m.ctrl.T.Helper() @@ -1709,21 +1606,6 @@ func (mr *MockStoreMockRecorder) UpsertArtifact(arg0, arg1 interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertArtifact", reflect.TypeOf((*MockStore)(nil).UpsertArtifact), arg0, arg1) } -// UpsertArtifactVersion mocks base method. -func (m *MockStore) UpsertArtifactVersion(arg0 context.Context, arg1 db.UpsertArtifactVersionParams) (db.ArtifactVersion, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpsertArtifactVersion", arg0, arg1) - ret0, _ := ret[0].(db.ArtifactVersion) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UpsertArtifactVersion indicates an expected call of UpsertArtifactVersion. -func (mr *MockStoreMockRecorder) UpsertArtifactVersion(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpsertArtifactVersion", reflect.TypeOf((*MockStore)(nil).UpsertArtifactVersion), arg0, arg1) -} - // UpsertProfileForEntity mocks base method. func (m *MockStore) UpsertProfileForEntity(arg0 context.Context, arg1 db.UpsertProfileForEntityParams) (db.EntityProfile, error) { m.ctrl.T.Helper() diff --git a/database/query/artifact_versions.sql b/database/query/artifact_versions.sql deleted file mode 100644 index 5c4047917c..0000000000 --- a/database/query/artifact_versions.sql +++ /dev/null @@ -1,63 +0,0 @@ --- name: CreateArtifactVersion :one -INSERT INTO artifact_versions ( - artifact_id, - version, - tags, - sha, - signature_verification, - github_workflow, created_at) VALUES ($1, $2, $3, $4, - sqlc.arg(signature_verification)::jsonb, - sqlc.arg(github_workflow)::jsonb, - $5) RETURNING *; - --- name: UpsertArtifactVersion :one -INSERT INTO artifact_versions ( - artifact_id, - version, - tags, - sha, - signature_verification, - github_workflow, - created_at -) VALUES ($1, $2, $3, $4, - sqlc.arg(signature_verification)::jsonb, - sqlc.arg(github_workflow)::jsonb, - $5) -ON CONFLICT (artifact_id, sha) -DO UPDATE SET - version = $2, - tags = $3, - signature_verification = sqlc.arg(signature_verification)::jsonb, - github_workflow = sqlc.arg(github_workflow)::jsonb, - created_at = $5 -WHERE artifact_versions.artifact_id = $1 AND artifact_versions.sha = $4 -RETURNING *; - - --- name: GetArtifactVersionByID :one -SELECT * FROM artifact_versions WHERE id = $1; - --- name: GetArtifactVersionBySha :one -SELECT * FROM artifact_versions WHERE sha = $1; - --- name: ListArtifactVersionsByArtifactID :many -SELECT * FROM artifact_versions -WHERE artifact_id = $1 -ORDER BY created_at DESC -LIMIT COALESCE(sqlc.narg('limit')::int, 2147483647); - --- name: ListArtifactVersionsByArtifactIDAndTag :many -SELECT * FROM artifact_versions -WHERE artifact_id = $1 -AND $2=ANY(STRING_TO_ARRAY(tags, ',')) -ORDER BY created_at DESC -LIMIT COALESCE(sqlc.narg('limit')::int, 2147483647); - --- name: DeleteArtifactVersion :exec -DELETE FROM artifact_versions -WHERE id = $1; - --- name: DeleteOldArtifactVersions :exec -DELETE FROM artifact_versions -WHERE artifact_id = $1 - AND (created_at <= $2 OR tags IS NULL OR tags = ''); \ No newline at end of file diff --git a/internal/db/artifact_versions.sql.go b/internal/db/artifact_versions.sql.go deleted file mode 100644 index 2e14d6911d..0000000000 --- a/internal/db/artifact_versions.sql.go +++ /dev/null @@ -1,276 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.25.0 -// source: artifact_versions.sql - -package db - -import ( - "context" - "database/sql" - "encoding/json" - "time" - - "github.com/google/uuid" -) - -const createArtifactVersion = `-- name: CreateArtifactVersion :one -INSERT INTO artifact_versions ( - artifact_id, - version, - tags, - sha, - signature_verification, - github_workflow, created_at) VALUES ($1, $2, $3, $4, - $6::jsonb, - $7::jsonb, - $5) RETURNING id, artifact_id, version, tags, sha, signature_verification, github_workflow, created_at -` - -type CreateArtifactVersionParams struct { - ArtifactID uuid.UUID `json:"artifact_id"` - Version int64 `json:"version"` - Tags sql.NullString `json:"tags"` - Sha string `json:"sha"` - CreatedAt time.Time `json:"created_at"` - SignatureVerification json.RawMessage `json:"signature_verification"` - GithubWorkflow json.RawMessage `json:"github_workflow"` -} - -func (q *Queries) CreateArtifactVersion(ctx context.Context, arg CreateArtifactVersionParams) (ArtifactVersion, error) { - row := q.db.QueryRowContext(ctx, createArtifactVersion, - arg.ArtifactID, - arg.Version, - arg.Tags, - arg.Sha, - arg.CreatedAt, - arg.SignatureVerification, - arg.GithubWorkflow, - ) - var i ArtifactVersion - err := row.Scan( - &i.ID, - &i.ArtifactID, - &i.Version, - &i.Tags, - &i.Sha, - &i.SignatureVerification, - &i.GithubWorkflow, - &i.CreatedAt, - ) - return i, err -} - -const deleteArtifactVersion = `-- name: DeleteArtifactVersion :exec -DELETE FROM artifact_versions -WHERE id = $1 -` - -func (q *Queries) DeleteArtifactVersion(ctx context.Context, id uuid.UUID) error { - _, err := q.db.ExecContext(ctx, deleteArtifactVersion, id) - return err -} - -const deleteOldArtifactVersions = `-- name: DeleteOldArtifactVersions :exec -DELETE FROM artifact_versions -WHERE artifact_id = $1 - AND (created_at <= $2 OR tags IS NULL OR tags = '') -` - -type DeleteOldArtifactVersionsParams struct { - ArtifactID uuid.UUID `json:"artifact_id"` - CreatedAt time.Time `json:"created_at"` -} - -func (q *Queries) DeleteOldArtifactVersions(ctx context.Context, arg DeleteOldArtifactVersionsParams) error { - _, err := q.db.ExecContext(ctx, deleteOldArtifactVersions, arg.ArtifactID, arg.CreatedAt) - return err -} - -const getArtifactVersionByID = `-- name: GetArtifactVersionByID :one -SELECT id, artifact_id, version, tags, sha, signature_verification, github_workflow, created_at FROM artifact_versions WHERE id = $1 -` - -func (q *Queries) GetArtifactVersionByID(ctx context.Context, id uuid.UUID) (ArtifactVersion, error) { - row := q.db.QueryRowContext(ctx, getArtifactVersionByID, id) - var i ArtifactVersion - err := row.Scan( - &i.ID, - &i.ArtifactID, - &i.Version, - &i.Tags, - &i.Sha, - &i.SignatureVerification, - &i.GithubWorkflow, - &i.CreatedAt, - ) - return i, err -} - -const getArtifactVersionBySha = `-- name: GetArtifactVersionBySha :one -SELECT id, artifact_id, version, tags, sha, signature_verification, github_workflow, created_at FROM artifact_versions WHERE sha = $1 -` - -func (q *Queries) GetArtifactVersionBySha(ctx context.Context, sha string) (ArtifactVersion, error) { - row := q.db.QueryRowContext(ctx, getArtifactVersionBySha, sha) - var i ArtifactVersion - err := row.Scan( - &i.ID, - &i.ArtifactID, - &i.Version, - &i.Tags, - &i.Sha, - &i.SignatureVerification, - &i.GithubWorkflow, - &i.CreatedAt, - ) - return i, err -} - -const listArtifactVersionsByArtifactID = `-- name: ListArtifactVersionsByArtifactID :many -SELECT id, artifact_id, version, tags, sha, signature_verification, github_workflow, created_at FROM artifact_versions -WHERE artifact_id = $1 -ORDER BY created_at DESC -LIMIT COALESCE($2::int, 2147483647) -` - -type ListArtifactVersionsByArtifactIDParams struct { - ArtifactID uuid.UUID `json:"artifact_id"` - Limit sql.NullInt32 `json:"limit"` -} - -func (q *Queries) ListArtifactVersionsByArtifactID(ctx context.Context, arg ListArtifactVersionsByArtifactIDParams) ([]ArtifactVersion, error) { - rows, err := q.db.QueryContext(ctx, listArtifactVersionsByArtifactID, arg.ArtifactID, arg.Limit) - if err != nil { - return nil, err - } - defer rows.Close() - items := []ArtifactVersion{} - for rows.Next() { - var i ArtifactVersion - if err := rows.Scan( - &i.ID, - &i.ArtifactID, - &i.Version, - &i.Tags, - &i.Sha, - &i.SignatureVerification, - &i.GithubWorkflow, - &i.CreatedAt, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const listArtifactVersionsByArtifactIDAndTag = `-- name: ListArtifactVersionsByArtifactIDAndTag :many -SELECT id, artifact_id, version, tags, sha, signature_verification, github_workflow, created_at FROM artifact_versions -WHERE artifact_id = $1 -AND $2=ANY(STRING_TO_ARRAY(tags, ',')) -ORDER BY created_at DESC -LIMIT COALESCE($3::int, 2147483647) -` - -type ListArtifactVersionsByArtifactIDAndTagParams struct { - ArtifactID uuid.UUID `json:"artifact_id"` - Tags sql.NullString `json:"tags"` - Limit sql.NullInt32 `json:"limit"` -} - -func (q *Queries) ListArtifactVersionsByArtifactIDAndTag(ctx context.Context, arg ListArtifactVersionsByArtifactIDAndTagParams) ([]ArtifactVersion, error) { - rows, err := q.db.QueryContext(ctx, listArtifactVersionsByArtifactIDAndTag, arg.ArtifactID, arg.Tags, arg.Limit) - if err != nil { - return nil, err - } - defer rows.Close() - items := []ArtifactVersion{} - for rows.Next() { - var i ArtifactVersion - if err := rows.Scan( - &i.ID, - &i.ArtifactID, - &i.Version, - &i.Tags, - &i.Sha, - &i.SignatureVerification, - &i.GithubWorkflow, - &i.CreatedAt, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const upsertArtifactVersion = `-- name: UpsertArtifactVersion :one -INSERT INTO artifact_versions ( - artifact_id, - version, - tags, - sha, - signature_verification, - github_workflow, - created_at -) VALUES ($1, $2, $3, $4, - $6::jsonb, - $7::jsonb, - $5) -ON CONFLICT (artifact_id, sha) -DO UPDATE SET - version = $2, - tags = $3, - signature_verification = $6::jsonb, - github_workflow = $7::jsonb, - created_at = $5 -WHERE artifact_versions.artifact_id = $1 AND artifact_versions.sha = $4 -RETURNING id, artifact_id, version, tags, sha, signature_verification, github_workflow, created_at -` - -type UpsertArtifactVersionParams struct { - ArtifactID uuid.UUID `json:"artifact_id"` - Version int64 `json:"version"` - Tags sql.NullString `json:"tags"` - Sha string `json:"sha"` - CreatedAt time.Time `json:"created_at"` - SignatureVerification json.RawMessage `json:"signature_verification"` - GithubWorkflow json.RawMessage `json:"github_workflow"` -} - -func (q *Queries) UpsertArtifactVersion(ctx context.Context, arg UpsertArtifactVersionParams) (ArtifactVersion, error) { - row := q.db.QueryRowContext(ctx, upsertArtifactVersion, - arg.ArtifactID, - arg.Version, - arg.Tags, - arg.Sha, - arg.CreatedAt, - arg.SignatureVerification, - arg.GithubWorkflow, - ) - var i ArtifactVersion - err := row.Scan( - &i.ID, - &i.ArtifactID, - &i.Version, - &i.Tags, - &i.Sha, - &i.SignatureVerification, - &i.GithubWorkflow, - &i.CreatedAt, - ) - return i, err -} diff --git a/internal/db/models.go b/internal/db/models.go index 1ab10234f6..f9b4d4aa02 100644 --- a/internal/db/models.go +++ b/internal/db/models.go @@ -12,7 +12,6 @@ import ( "time" "github.com/google/uuid" - "github.com/sqlc-dev/pqtype" ) type ActionType string @@ -292,17 +291,6 @@ type Artifact struct { UpdatedAt time.Time `json:"updated_at"` } -type ArtifactVersion struct { - ID uuid.UUID `json:"id"` - ArtifactID uuid.UUID `json:"artifact_id"` - Version int64 `json:"version"` - Tags sql.NullString `json:"tags"` - Sha string `json:"sha"` - SignatureVerification pqtype.NullRawMessage `json:"signature_verification"` - GithubWorkflow pqtype.NullRawMessage `json:"github_workflow"` - CreatedAt time.Time `json:"created_at"` -} - type Entitlement struct { ID uuid.UUID `json:"id"` Feature string `json:"feature"` diff --git a/internal/db/querier.go b/internal/db/querier.go index 12dfc665c5..86b46baf06 100644 --- a/internal/db/querier.go +++ b/internal/db/querier.go @@ -18,7 +18,6 @@ type Querier interface { CountUsers(ctx context.Context) (int64, error) CreateAccessToken(ctx context.Context, arg CreateAccessTokenParams) (ProviderAccessToken, error) CreateArtifact(ctx context.Context, arg CreateArtifactParams) (Artifact, error) - CreateArtifactVersion(ctx context.Context, arg CreateArtifactVersionParams) (ArtifactVersion, error) CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Project, error) CreateProfile(ctx context.Context, arg CreateProfileParams) (Profile, error) CreateProfileForEntity(ctx context.Context, arg CreateProfileForEntityParams) (EntityProfile, error) @@ -32,9 +31,7 @@ type Querier interface { CreateUser(ctx context.Context, arg CreateUserParams) (User, error) DeleteAccessToken(ctx context.Context, arg DeleteAccessTokenParams) error DeleteArtifact(ctx context.Context, id uuid.UUID) error - DeleteArtifactVersion(ctx context.Context, id uuid.UUID) error DeleteExpiredSessionStates(ctx context.Context) error - DeleteOldArtifactVersions(ctx context.Context, arg DeleteOldArtifactVersionsParams) error DeleteOrganization(ctx context.Context, id uuid.UUID) error DeleteProfile(ctx context.Context, id uuid.UUID) error DeleteProfileForEntity(ctx context.Context, arg DeleteProfileForEntityParams) error @@ -57,8 +54,6 @@ type Querier interface { GetAccessTokenSinceDate(ctx context.Context, arg GetAccessTokenSinceDateParams) (ProviderAccessToken, error) GetArtifactByID(ctx context.Context, id uuid.UUID) (GetArtifactByIDRow, error) GetArtifactByName(ctx context.Context, arg GetArtifactByNameParams) (GetArtifactByNameRow, error) - GetArtifactVersionByID(ctx context.Context, id uuid.UUID) (ArtifactVersion, error) - GetArtifactVersionBySha(ctx context.Context, sha string) (ArtifactVersion, error) GetChildrenProjects(ctx context.Context, id uuid.UUID) ([]GetChildrenProjectsRow, error) GetEntityProfileByProjectAndName(ctx context.Context, arg GetEntityProfileByProjectAndNameParams) ([]GetEntityProfileByProjectAndNameRow, error) // GetFeatureInProject verifies if a feature is available for a specific project. @@ -97,8 +92,6 @@ type Querier interface { GetUserBySubject(ctx context.Context, identitySubject string) (User, error) GlobalListProviders(ctx context.Context) ([]Provider, error) ListAllRepositories(ctx context.Context, provider string) ([]Repository, error) - ListArtifactVersionsByArtifactID(ctx context.Context, arg ListArtifactVersionsByArtifactIDParams) ([]ArtifactVersion, error) - ListArtifactVersionsByArtifactIDAndTag(ctx context.Context, arg ListArtifactVersionsByArtifactIDAndTagParams) ([]ArtifactVersion, error) ListArtifactsByRepoID(ctx context.Context, repositoryID uuid.UUID) ([]Artifact, error) ListFlushCache(ctx context.Context) ([]FlushCache, error) ListOrganizations(ctx context.Context, arg ListOrganizationsParams) ([]Project, error) @@ -138,7 +131,6 @@ type Querier interface { UpdateRepositoryByID(ctx context.Context, arg UpdateRepositoryByIDParams) (Repository, error) UpdateRuleType(ctx context.Context, arg UpdateRuleTypeParams) error UpsertArtifact(ctx context.Context, arg UpsertArtifactParams) (Artifact, error) - UpsertArtifactVersion(ctx context.Context, arg UpsertArtifactVersionParams) (ArtifactVersion, error) UpsertProfileForEntity(ctx context.Context, arg UpsertProfileForEntityParams) (EntityProfile, error) UpsertPullRequest(ctx context.Context, arg UpsertPullRequestParams) (PullRequest, error) UpsertRuleDetailsAlert(ctx context.Context, arg UpsertRuleDetailsAlertParams) (uuid.UUID, error)