Skip to content

Commit ef06a7c

Browse files
authored
chore(db): update workflow_run revision used (#557)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 5bb14e4 commit ef06a7c

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ jobs:
3838
3939
# Generate any possible migration from a schema change that way
4040
# we can detect any migration file that has not been checked in to git
41-
# This could happen if the developer ran make generate but didn't run make migration_new
41+
# This could happen if the developer ran make generate but didn't run make migration_sync
4242
- name: Generate migrations
4343
if: ${{ matrix.app == 'controlplane' }}
4444
run: |
4545
wget -q https://release.ariga.io/atlas/atlas-linux-amd64-latest -O /tmp/atlas
4646
sudo install /tmp/atlas /usr/local/bin/atlas
4747
48-
make -C app/controlplane migration_new
48+
make -C app/controlplane migration_sync
4949
5050
# Check that the generated ent code is up to date
5151
# see https://entgo.io/docs/ci/

app/controlplane/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ migration_apply: check-atlas-tool migration_hash
3333
atlas migrate status --dir ${local_migrations_dir} --url ${local_db}
3434
atlas migrate apply --dir ${local_migrations_dir} --url ${local_db}
3535

36+
.PHONY: migration_sync
37+
# sync migration files with the current ent schema
38+
migration_sync: check-atlas-tool migration_hash
39+
atlas migrate diff --dir ${local_migrations_dir} --to "ent://internal/data/ent/schema" --dev-url "docker://postgres/15/test?search_path=public"
40+
3641
.PHONY: migration_new
37-
# generate new migration if needed from the current ent schema
42+
# generate an empty migration file
3843
migration_new: check-atlas-tool migration_hash
39-
atlas migrate diff --dir ${local_migrations_dir} --to "ent://internal/data/ent/schema" --dev-url "docker://postgres/15/test?search_path=public"
44+
atlas migrate new --dir ${local_migrations_dir}
4045

4146
.PHONY: migration_hash
4247
migration_hash: check-atlas-tool
@@ -61,7 +66,7 @@ lint: check-golangci-lint-tool check-buf-tool
6166

6267
.PHONY: generate
6368
# generate proto bindings, wire injectors, and ent models
64-
generate: check-wire-tool api config migration_new
69+
generate: check-wire-tool api config migration_sync
6570
go generate ./...
6671

6772
.PHONY: all
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Updates the contract_revision_used field in workflow_runs to the revision of the contract version used in the run
2+
-- for existing values in the database if it is not set (0)
3+
UPDATE workflow_runs
4+
SET contract_revision_used = wcv.revision
5+
FROM workflow_contract_versions wcv
6+
WHERE workflow_runs.contract_revision_used = 0
7+
AND workflow_runs.workflow_run_contract_version = wcv.id;

app/controlplane/internal/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:mf+rCMij2DFHC9ogu8h+ktB0OPUSBAanvHQeIAoPfc4=
1+
h1:PTn2PGzCqghqtloTCXyt2mqCL53gJMrZ0h7j77qU2H0=
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=
@@ -23,3 +23,4 @@ h1:mf+rCMij2DFHC9ogu8h+ktB0OPUSBAanvHQeIAoPfc4=
2323
20240226145219.sql h1:m90QJxxZjOC7CjMPijxc3vf5pzX1X6Ac9M8Ms0lJ0gQ=
2424
20240228152445.sql h1:+F9k29PxJCv4CuwoMcnO24y0a+mxqaWsJr2zgI8XDx0=
2525
20240229202352.sql h1:1oSaJh+gNJ8cc+9AGBizFG4uk6GkHph0R3hsjjz9w4g=
26+
20240303145130.sql h1:ejcuI4AeWNCNhEkg3+7ButLe2hpIFqmhuPheFXEr6zY=

0 commit comments

Comments
 (0)