Skip to content

Commit af1b0d4

Browse files
authored
fix(project-version): bootstrap missing default project versions (#2370)
Signed-off-by: Sylwester Piskozub <[email protected]>
1 parent 063e952 commit af1b0d4

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- Create default version for projects that don't have any versions
2+
INSERT INTO "project_versions" ("id", "project_id", "version", "prerelease", "latest", "created_at", "updated_at")
3+
SELECT
4+
gen_random_uuid() as id,
5+
p.id as project_id,
6+
'' as version,
7+
true as prerelease,
8+
true as latest,
9+
p.created_at as created_at,
10+
p.updated_at as updated_at
11+
FROM "projects" p
12+
WHERE p.deleted_at IS NULL
13+
AND NOT EXISTS (
14+
SELECT 1 FROM "project_versions" pv
15+
WHERE pv.project_id = p.id
16+
AND pv.deleted_at IS NULL
17+
);

app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:QaClWT8b1Nr8BRNI+5O2WAYbWl/5tTlopLggA6RQwzw=
1+
h1:x6Aaqyf5LL8bB+ApOOevCGz3+dZFPb31NMn1U3QT8ek=
22
20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M=
33
20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g=
44
20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI=
@@ -108,3 +108,4 @@ h1:QaClWT8b1Nr8BRNI+5O2WAYbWl/5tTlopLggA6RQwzw=
108108
20250808164400.sql h1:r7S2LM8d3kbKQ7WNuggjvmNw3kcccx0rYzzklw8Q2I8=
109109
20250808165202.sql h1:Oreh9FpYwo/cdcs3Oza/+ACzScXeTRBGIEvua8RqoLo=
110110
20250812111458.sql h1:15yQlZoBymYR5GEjGLtV/j4ZZjg06u6eEzcRRl7vax4=
111+
20250820090420.sql h1:xmJucXMVs+JyXWmyHu7Rv31hhgtAONDTv1mT/sTaJKk=

app/controlplane/pkg/data/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (r *WorkflowRepo) Create(ctx context.Context, opts *biz.WorkflowCreateOpts)
104104
return fmt.Errorf("finding project version: %w", err)
105105
}
106106

107-
if _, err := createProjectVersionWithTx(ctx, tx, projectID, "", false); err != nil {
107+
if _, err := createProjectVersionWithTx(ctx, tx, projectID, "", true); err != nil {
108108
return fmt.Errorf("creating project version: %w", err)
109109
}
110110
}

0 commit comments

Comments
 (0)