Skip to content

Commit

Permalink
chore(rename): rename controller table to controllers (#2700)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Sep 16, 2024
1 parent 4ab53cc commit b8c4d4f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions backend/controller/dal/internal/sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ INSERT INTO requests (origin, "key", source_addr)
VALUES ($1, $2, $3);

-- name: UpsertController :one
INSERT INTO controller (key, endpoint)
INSERT INTO controllers (key, endpoint)
VALUES ($1, $2)
ON CONFLICT (key) DO UPDATE SET state = 'live',
endpoint = $2,
Expand All @@ -206,7 +206,7 @@ RETURNING id;
-- name: KillStaleControllers :one
-- Mark any controller entries that haven't been updated recently as dead.
WITH matches AS (
UPDATE controller
UPDATE controllers
SET state = 'dead'
WHERE state <> 'dead' AND last_seen < (NOW() AT TIME ZONE 'utc') - sqlc.arg('timeout')::INTERVAL
RETURNING 1)
Expand All @@ -215,7 +215,7 @@ FROM matches;

-- name: GetActiveControllers :many
SELECT *
FROM controller c
FROM controllers c
WHERE c.state <> 'dead'
ORDER BY c.key;

Expand Down
6 changes: 3 additions & 3 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.

2 changes: 1 addition & 1 deletion backend/controller/sql/databasetesting/devel.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func CreateForDevel(ctx context.Context, dsn string, recreate bool) (*stdsql.DB,
DELETE FROM leases
RETURNING 1
), deleted_controllers AS (
DELETE FROM controller
DELETE FROM controllers
RETURNING 1
), deleted_runners AS (
DELETE FROM runners
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- migrate:up

ALTER TABLE controller RENAME TO controllers;

-- migrate:down

0 comments on commit b8c4d4f

Please sign in to comment.