mirror of
https://github.com/coder/coder.git
synced 2026-06-03 21:18:24 +00:00
39bf3ba628
- Removes GetManagedAgentCount query - Adds new table `usage_events_daily` which stores aggregated usage events by the type and UTC day - Adds trigger to update the values in this table when a new row is inserted into `usage_events` - Adds a migration that adds `usage_events_daily` rows for existing data in `usage_events` - Adds tests for the trigger - Adds tests for the backfill query in the migration Since the `usage_events` table is unreleased currently, this migration will do nothing on real deployments and will only affect preview deployments such as dogfood. Closes https://github.com/coder/internal/issues/943
38 lines
441 B
SQL
38 lines
441 B
SQL
-- name: InsertLicense :one
|
|
INSERT INTO
|
|
licenses (
|
|
uploaded_at,
|
|
jwt,
|
|
exp,
|
|
uuid
|
|
)
|
|
VALUES
|
|
($1, $2, $3, $4) RETURNING *;
|
|
|
|
-- name: GetLicenses :many
|
|
SELECT *
|
|
FROM licenses
|
|
ORDER BY (id);
|
|
|
|
-- name: GetLicenseByID :one
|
|
SELECT
|
|
*
|
|
FROM
|
|
licenses
|
|
WHERE
|
|
id = $1
|
|
LIMIT
|
|
1;
|
|
|
|
-- name: GetUnexpiredLicenses :many
|
|
SELECT *
|
|
FROM licenses
|
|
WHERE exp > NOW()
|
|
ORDER BY (id);
|
|
|
|
-- name: DeleteLicense :one
|
|
DELETE
|
|
FROM licenses
|
|
WHERE id = $1
|
|
RETURNING id;
|