atrg-db
Database layer for at-rust-go: SQLite connection pooling and migrations.
Part of at-rust-go (atrg) — a batteries-included AT Protocol backend framework for Rust.
What this crate provides
DbConn— type alias forsqlx::SqlitePool, the primary database handle used throughout atrgconnect(url)— create a connection pool with sensible defaults (WAL journal mode, foreign keys enabled, auto-create database file)run_internal_migrations(pool)— apply atrg's own embedded migrations (sessions table, etc.), idempotent on every startuprun_user_migrations(pool, dir)— discover and apply application-specific.sqlmigrations from a directory, silently skipping if the directory is missing or empty
The crate does not provide an ORM. Write SQL with sqlx::query!() for compile-time checked queries.
Usage
[]
= "0.1"
use DbConn;
async
Connection defaults
| Setting | Value |
|---|---|
| Journal mode | WAL |
| Foreign keys | ON |
| Create if missing | Yes |
| Max connections | 8 |
Migration conventions
atrg's internal migrations run first (prefixed atrg_). User migrations live in your project's migrations/ directory and are applied in filename order:
migrations/
├── 0001_create_posts.sql
└── 0002_create_follows.sql
License
LGPL-3.0-only — see LICENSE.