Files
webhooker/internal/db/migrations/main/000_migration.sql
T
clawbot f69de8460c
check / check (push) Waiting to run
Build every database's schema from embedded SQL files (closes #56)
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.
The event totals row is inserted by events/001_schema.sql rather than
on every open.

Model: opus-5-5
2026-10-13 02:00:36 +00:00

10 lines
320 B
SQL

-- Migration 000: the table recording which migrations this file has
-- had. Applied before the others; it records itself.
CREATE TABLE IF NOT EXISTS schema_migrations (
version INTEGER PRIMARY KEY,
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
INSERT OR IGNORE INTO schema_migrations (version) VALUES (0);