Database Management
The aw db CLI commands manage the supported Allowealth database targets:
sqlitefor local development
Supported Targets
Section titled “Supported Targets”| Target | Use Case | Configuration |
|---|---|---|
sqlite | Local development | db/.dev.db |
Migrations
Section titled “Migrations”Generate a migration
Section titled “Generate a migration”Create a migration from schema changes:
bun run aw db generateApply migrations
Section titled “Apply migrations”Apply pending migrations to the selected target:
bun run aw db migrateSchema changes
Section titled “Schema changes”Quick development workflow
Section titled “Quick development workflow”Push schema changes directly to SQLite:
bun run aw db pushUse this only in development. It bypasses migration tracking.
Reset local SQLite
Section titled “Reset local SQLite”Delete the local SQLite database, recreate the schema, and seed demo data:
bun run aw db resetThis command works only with the sqlite target.
Backup
Section titled “Backup”Create timestamped backups for any supported target:
bun run aw db backup --target sqliteBy default, backups save to backups/sqlite-<timestamp>.db.
Use a custom path when needed:
bun run aw db backup --target sqlite --output /path/to/backup.dbRestore
Section titled “Restore”Restore validates backups before applying changes and creates a safety backup unless you opt out.
Dry run
Section titled “Dry run”Validate a backup without restoring it:
bun run aw db restore --dry-runRestore from local backup
Section titled “Restore from local backup”# Interactive (requires confirmation)bun run aw db restore --target sqlite
# Non-interactivebun run aw db restore --target sqlite --force
# Skip pre-restore backupbun run aw db restore --target sqlite --force --no-backup
# Restore a specific filebun run aw db restore --target sqlite --file backups/sqlite-2026-03-04.sqlRestore from cloud backup
Section titled “Restore from cloud backup”bun run aw db restore --source cloudCloud backups read from backups/cloud/ by default. Override the location if needed:
bun run aw db restore --source cloud --cloud-dir /path/to/cloud/backupsData seeding
Section titled “Data seeding”Seed demo data
Section titled “Seed demo data”bun run aw db seed --target sqliteControl data volume
Section titled “Control data volume”# Seed 6 months of historybun run aw db seed --target sqlite --months=6
# Seed 12 months + 5,000 extra transactionsbun run aw db seed --target sqlite --months=12 --transactions=5000Add benchmark data
Section titled “Add benchmark data”bun run aw db seed --target sqlite --benchmarkAdd stress-test data
Section titled “Add stress-test data”bun run aw db seed --target sqlite --stressDangerous operations
Section titled “Dangerous operations”Drop all tables
Section titled “Drop all tables”Delete all tables and reset the selected database:
bun run aw db dropThis command requires typed confirmation.
Empty data but keep schema
Section titled “Empty data but keep schema”bun run aw db emptyQuality checks
Section titled “Quality checks”Before committing database changes, run:
bun run lint:fixbun run stylelint:fixbun run format:fixbun run typecheckSee also
Section titled “See also”- COMMANDS.md - Complete CLI reference
- Database Migrations - Migration workflow and patterns
- Feature Workflow - Implementation sequence for new features