Each kind of database file gets its schema from SQL files embedded under internal/db/migrations/: main/ for webhooker.db, events/ for each events-{uuid}.db, archive/ for each archive file. 000_migration.sql creates schema_migrations (version INTEGER PRIMARY KEY, as in sneak/pixa) and records itself. 001_schema.sql is the schema. migrations.Apply runs, in one transaction, every file the database has not had, where AutoMigrate used to run. GORM stays for queries. No AutoMigrate is left, in tests either.
The SQL is the schema AutoMigrate built in fresh files: same columns, defaults, checks and indexes. The event schema leaves out the copies of users, webhooks, entrypoints and targets, and the foreign keys to them, so the sweep that cleaned those copies is deleted. The association guard stays: without it a delivery write now fails on the missing targets table.
Not visible in the diff:
AutoMigrate also made GORM parse every model before a handle was shared. GORM 1.25.5 races when two goroutines first use models that refer to each other, as the engine does at start, so the main and event databases now parse their models on open.
events/001_schema.sql inserts the event totals row; it is no longer created on every open.
The delivery tests' testWebhookDB opens through WebhookDBManager, so it has the guard.
Judgement call: the index test lost its half that expected a reopen to restore dropped indexes; pre-1.0 there is no upgrade path.
Deviation: one handler test renames its subtests. A repeated name gets #01, which SQLiteDSN does not escape, so that test's databases shared one file: #518.
Model: opus-5-5
Closes https://git.eeqj.de/sneak/webhooker/issues/56.
Each kind of database file gets its schema from SQL files embedded under `internal/db/migrations/`: `main/` for `webhooker.db`, `events/` for each `events-{uuid}.db`, `archive/` for each archive file. `000_migration.sql` creates `schema_migrations` (`version INTEGER PRIMARY KEY`, as in sneak/pixa) and records itself. `001_schema.sql` is the schema. `migrations.Apply` runs, in one transaction, every file the database has not had, where `AutoMigrate` used to run. GORM stays for queries. No `AutoMigrate` is left, in tests either.
The SQL is the schema `AutoMigrate` built in fresh files: same columns, defaults, checks and indexes. The event schema leaves out the copies of `users`, `webhooks`, `entrypoints` and `targets`, and the foreign keys to them, so the sweep that cleaned those copies is deleted. The association guard stays: without it a delivery write now fails on the missing `targets` table.
Not visible in the diff:
- `AutoMigrate` also made GORM parse every model before a handle was shared. GORM 1.25.5 races when two goroutines first use models that refer to each other, as the engine does at start, so the main and event databases now parse their models on open.
- `events/001_schema.sql` inserts the event totals row; it is no longer created on every open.
- The delivery tests' `testWebhookDB` opens through `WebhookDBManager`, so it has the guard.
- Judgement call: the index test lost its half that expected a reopen to restore dropped indexes; pre-1.0 there is no upgrade path.
- Deviation: one handler test renames its subtests. A repeated name gets `#01`, which `SQLiteDSN` does not escape, so that test's databases shared one file: https://git.eeqj.de/sneak/webhooker/issues/518.
Model: opus-5-5
The main database, each webhook's event database and each archive file
get their schema from SQL files under internal/db/migrations/, one
directory per kind. Opening a file runs, in one transaction, each file
that schema_migrations does not list. GORM stays for queries.
AutoMigrate is gone, tests included.
An event database holds only its own tables now, so the sweep that
removed target rows copied into it is deleted. The association guard
stays: without it a delivery write fails on the missing targets table.
AutoMigrate also had GORM parse every model before a handle was shared.
That is now done on its own: GORM races when two goroutines first use
models that refer to each other.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #56.
Each kind of database file gets its schema from SQL files embedded under
internal/db/migrations/:main/forwebhooker.db,events/for eachevents-{uuid}.db,archive/for each archive file.000_migration.sqlcreatesschema_migrations(version INTEGER PRIMARY KEY, as in sneak/pixa) and records itself.001_schema.sqlis the schema.migrations.Applyruns, in one transaction, every file the database has not had, whereAutoMigrateused to run. GORM stays for queries. NoAutoMigrateis left, in tests either.The SQL is the schema
AutoMigratebuilt in fresh files: same columns, defaults, checks and indexes. The event schema leaves out the copies ofusers,webhooks,entrypointsandtargets, and the foreign keys to them, so the sweep that cleaned those copies is deleted. The association guard stays: without it a delivery write now fails on the missingtargetstable.Not visible in the diff:
AutoMigratealso made GORM parse every model before a handle was shared. GORM 1.25.5 races when two goroutines first use models that refer to each other, as the engine does at start, so the main and event databases now parse their models on open.events/001_schema.sqlinserts the event totals row; it is no longer created on every open.testWebhookDBopens throughWebhookDBManager, so it has the guard.#01, whichSQLiteDSNdoes not escape, so that test's databases shared one file: #518.Model: opus-5-5
Review passed.
Model: opus-5-5