Move the database to Postgres #8
Reference in New Issue
Block a user
Delete Branch "postgres"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #2. First step of #1: the teams work in #4 adds a
team_idto nearly every table, and doing that against two databases is work nobody gets paid for.The commit message carries the full reasoning. The short version:
Schema
001_baseline.sql. They were incremental in a way that has no value on a fresh install — 004 adds columns 008 drops again, and 008's backfill rewrites data a Postgres database never had. The history stays in git.BIGINTunix seconds. Converting totimestamptzis a larger change and deserves its own PR.jsonb, because #4 will want to filter and index on labels.Beyond the mechanical port
170 placeholders moved from
?to$1, but four things needed more than a search and replace:WHEREclauses hand out placeholders through asqlArgshelper, so numbering cannot drift from the values.SUM(resolved_at IS NULL)was SQLite counting a boolean as 0/1. Postgres has nosum(boolean), and this was breaking every dead man's switch — silently, since the sweeper only logs. NowCOUNT(*) FILTER.unixepoch()→FLOOR(EXTRACT(EPOCH FROM now()))::bigint. TheFLOORis load-bearing: a bare cast rounds half up, putting a timestamp a second in the future.Tests
There is no in-memory Postgres, so each test gets its own schema on a shared server.
TERDUT_TEST_DSNsays where;make test-dbstarts one locally andci.yamlruns one as a service container. An unset DSN fails rather than skips.TestMigration_BackfillCarriesAckAndCommentsis deleted with the migrations it replayed. What it protected now belongs toscripts/sqlite-to-postgres.go.Chart
Loses the PVC, the data volume and the python backup sidecar; requires
database.dsnSecret.name, since it provisions no database and a render without it should fail.Verified
make fmt lint test helm-lintgreen, with-race, against Postgres 17.govulncheckandgitleaksclean.Not in here
Ryuvia/charts: thepostgresqlCR, the k8uppg_dumpannotation, the schedule moved off the SQLite dump, the network policy.