Documentation
¶
Overview ¶
Package database provides SQLite database setup for the ent ORM client. Uses modernc.org/sqlite (CGo-free) with WAL mode and FK constraints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open creates an ent client connected to the SQLite database at dbPath. The database is configured with WAL journal mode, foreign key enforcement, a 5-second busy timeout, and bulk-write-tuned pragmas. It returns both the ent client and the underlying *sql.DB for raw SQL operations (e.g., sync_status table).
DSN pragma rationale (260428-eda CHANGE 4):
- synchronous(NORMAL): safe under LiteFS-replicated WAL — LiteFS provides durability via streaming replication so per-commit local fsync is redundant overhead. Halves the per-commit syscall cost on the bulk- upsert tx; the Fly primary's local WAL is replayed on replicas regardless of the local fsync mode.
- cache_size(-32000): 32 MB page cache (negative value = KiB). Default is ~2 MB. The bulk-upsert workload reuses recently-read pages heavily during the ~60s upsert burst; 32 MB fits comfortably under the Fly 512 MB primary VM cap (sync peak heap ~37 MB, peak RSS ~232 MB observed in production).
- temp_store(MEMORY): keeps sorter and temp tables in RAM. modernc.org/ sqlite's default is FILE which on Fly hits the rootfs overlay (NOT tmpfs — verified via /proc/mounts).
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.