Skip to content

Commit 2803c43

Browse files
committed
backend
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
2 parents f900be4 + b4a9cd0 commit 2803c43

13 files changed

Lines changed: 251 additions & 159 deletions

File tree

‎.chainloop.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This can indicate the next version and by default it will be marked as pre-release
2-
projectVersion: v1.46.0
2+
projectVersion: v1.47.0
33

44
# Experimental feature used by Chainloop labs shared workflow https://github.com/chainloop-dev/labs
55
# It maps the material names with location in disk so they get automatically attested

‎app/controlplane/Makefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ migration_apply: check-atlas-tool migration_hash
3737
atlas migrate status --dir ${local_migrations_dir} --url ${local_db}
3838
atlas migrate apply --dir ${local_migrations_dir} --url ${local_db}
3939

40+
.PHONY: migration_apply_non_linear
41+
# see https://atlasgo.io/versioned/apply#non-linear-error
42+
migration_apply_non_linear: check-atlas-tool migration_hash
43+
atlas migrate status --dir ${local_migrations_dir} --url ${local_db}
44+
atlas migrate apply --dir ${local_migrations_dir} --url ${local_db} --exec-order non-linear
45+
4046
.PHONY: migration_sync
4147
# sync migration files with the current ent schema
4248
migration_sync: check-atlas-tool migration_hash

‎app/controlplane/api/gen/frontend/workflowcontract/v1/crafting_schema.ts‎

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/controlplane/api/gen/jsonschema/workflowcontract.v1.Metadata.jsonschema.json‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/controlplane/api/gen/jsonschema/workflowcontract.v1.Metadata.schema.json‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/controlplane/api/workflowcontract/v1/crafting_schema.pb.go‎

Lines changed: 158 additions & 145 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎app/controlplane/api/workflowcontract/v1/crafting_schema.proto‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ message Metadata {
217217

218218
string description = 4;
219219
map<string, string> annotations = 5;
220+
optional string organization = 6;
220221
}
221222

222223
message PolicySpec {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Backfill released_at field for released project versions
2+
-- This migration populates the released_at timestamp for project versions
3+
-- that are marked as released (prerelease = false) but don't have a released_at timestamp
4+
5+
DO $$
6+
DECLARE
7+
batch_size INTEGER := 100;
8+
total_remaining INTEGER := 0;
9+
total_updated INTEGER := 0;
10+
BEGIN
11+
-- Get initial count of project versions that need updating
12+
-- (those that are released but don't have released_at set)
13+
SELECT COUNT(*)
14+
INTO total_remaining
15+
FROM project_versions
16+
WHERE prerelease = false
17+
AND released_at IS NULL
18+
AND deleted_at IS NULL;
19+
20+
-- Loop until no more rows remain
21+
WHILE total_remaining > 0 LOOP
22+
-- Update a batch of project versions
23+
-- Set released_at to created_at as a reasonable default
24+
WITH updated AS (
25+
UPDATE project_versions
26+
SET released_at = created_at
27+
WHERE id IN (
28+
SELECT id
29+
FROM project_versions
30+
WHERE prerelease = false
31+
AND released_at IS NULL
32+
AND deleted_at IS NULL
33+
LIMIT batch_size
34+
)
35+
RETURNING id
36+
)
37+
SELECT COUNT(*) INTO batch_size FROM updated;
38+
39+
total_updated := total_updated + batch_size;
40+
41+
-- Update the remaining count
42+
SELECT COUNT(*)
43+
INTO total_remaining
44+
FROM project_versions
45+
WHERE prerelease = false
46+
AND released_at IS NULL
47+
AND deleted_at IS NULL;
48+
49+
END LOOP;
50+
51+
END $$;

app/controlplane/pkg/data/ent/migrate/migrations/20251009210727.sql renamed to app/controlplane/pkg/data/ent/migrate/migrations/20251010104841.sql

File renamed without changes.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:vgPVCZCn7DpCxS0XxUE5uFlFBsBHCtsp3iPZwZLULrQ=
1+
h1:hspm2aeA53aPFKPqWqM6NdNeGc9R9kMrodA/EOV5Gyw=
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=
@@ -115,4 +115,5 @@ h1:vgPVCZCn7DpCxS0XxUE5uFlFBsBHCtsp3iPZwZLULrQ=
115115
20250908160222.sql h1:bNjptbt2xPpSXqa4eVuWkMnovHt9LMkiakoGrFGZJ0g=
116116
20251001215533.sql h1:+IdTm9OSW1r5nDH1fX2hpia/q0UzklPrDy3SDN3S0dg=
117117
20251001215625.sql h1:adcp5r8CoL/JCfNgNZxBvY5pczlEHFH/IX64g/ji/4s=
118-
20251009210727.sql h1:DvQIl29i9oE2WN61LFfeOX74kV9I7MS8h7juiXCiXkE=
118+
20251007154203.sql h1:gRPipCNWs439gStSXVDxoSLqTw4SUPMiOe5fK1Y5V1Q=
119+
20251010104841.sql h1:CRElEYC76B0I/Hg1wwYV2SpUX2CLAJyxN82sGCEBM7Y=

0 commit comments

Comments
 (0)