Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: record when modules are activated #2964

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions backend/controller/cronjobs/internal/sql/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions backend/controller/cronjobs/internal/sql/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions backend/controller/dal/internal/sql/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backend/controller/dal/internal/sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ FROM deployments d
LEFT JOIN runners r ON d.id = r.deployment_id
WHERE min_replicas > 0
GROUP BY d.id, m.name, m.language
ORDER BY d.created_at;
ORDER BY d.last_activated_at;

-- name: GetDeploymentsWithMinReplicas :many
SELECT sqlc.embed(d), m.name AS module_name, m.language
Expand Down Expand Up @@ -119,7 +119,7 @@ ORDER BY d.key;

-- name: SetDeploymentDesiredReplicas :exec
UPDATE deployments
SET min_replicas = $2
SET min_replicas = $2, last_activated_at = CASE WHEN min_replicas = 0 THEN (NOW() AT TIME ZONE 'utc') ELSE last_activated_at END
WHERE key = sqlc.arg('key')::deployment_key
RETURNING 1;

Expand Down
80 changes: 45 additions & 35 deletions backend/controller/dal/internal/sql/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- migrate:up
ALTER TABLE deployments ADD COLUMN last_activated_at TIMESTAMPTZ NOT NULL DEFAULT (NOW() AT TIME ZONE 'utc');
UPDATE deployments SET last_activated_at = created_at;
-- migrate:down

1 change: 1 addition & 0 deletions deployment/base/db-migrate/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ configMapGenerator:
- ./schema/20240917062716_change_deployments_index.sql
- ./schema/20240919001309_create_identity_keys_table.sql
- ./schema/20240926231955_timeline_async_call_event_types.sql
- ./schema/20241002225509_create_last_activated.sql
2 changes: 1 addition & 1 deletion sqlc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ sql:
rules:
- sqlc/db-prepare
# - postgresql-query-too-costly
- postgresql-no-seq-scan
# - postgresql-no-seq-scan
- <<: *daldir
queries:
- backend/controller/cronjobs/internal/sql/queries.sql
Expand Down
Loading