-
Notifications
You must be signed in to change notification settings - Fork 1
Database & Seeding
fulleni edited this page Jan 18, 2026
·
1 revision
The API Server includes a robust system for managing database schema evolution and initial data population. This ensures that any developer (or production environment) can spin up a fully functional database from scratch.
We do not manually edit the database. Schema changes are code.
-
Service:
DatabaseMigrationService(lib/src/services/database_migration_service.dart) -
Mechanism:
- On startup, the service checks the
migrationscollection. - It compares applied migrations against the list of available migration scripts in
lib/src/database/migrations/. - It executes any new
up()methods in order.
- On startup, the service checks the
-
Traceability: Each migration is linked to a specific Pull Request (e.g.,
Migration20240101_AddUserTier), providing an audit trail.
After migrations are applied, the seeding process ensures essential data exists.
-
Service:
DatabaseSeedingService(lib/src/services/database_seeding_service.dart) -
Idempotency: The seeder is designed to be run on every startup. It uses
upsertoperations (specificallyupdateOnewith$setOnInsert) to ensure it never overwrites existing data or creates duplicates.
-
Indexes: Critical performance indexes (e.g., Text Search on Headlines, TTL on Verification Codes) are ensured via
_ensureIndexes(). -
Static Data:
-
Countries: From
packages/core/lib/src/fixtures/countries.dart. -
Languages: From
packages/core/lib/src/fixtures/languages.dart.
-
Countries: From
-
Configuration:
-
Remote Config: A default
RemoteConfigdocument is created if none exists. -
Admin User: If
OVERRIDE_ADMIN_EMAILis set in.env, the system ensures a user with that email exists and has theadminrole.
-
Remote Config: A default
For comprehensive details regarding licensing, including trial and commercial options for the entire toolkit, please refer to the toolkit organization page.