Leicmin uses PostgreSQL. There is no intent in adding more databases at this point. We also believe that the logic should be easy to understand, so there are no intentions of adding triggers or stored procedures into the database tier, only Rust code to manage complex processes.
Database layers
Database work has four related components:
- The domain module under
src/leicmin/src/data/<category>/<entity>/mod.rscontains application-facing types and operations - The SeaORM entity
src/leicmin/src/data/<category>/<entity>/db.rscontainsModel,ActiveModel, columns, and relations - A migration under
src/leicmin/src/data/migrations/changes databases that already exist src/leicmin/src/data/migrations/mod.rsregisters migrations in execution order
Migration workflow
Persistent schema changes are made only with SeaORM migrations; do not add schema-changing SQL to handlers, startup code, tests, or seed scripts.
- Inspect a nearby entity and its migration before choosing names, types, relations, defaults, and timestamp conventions
- Create a migration with
just add-migration NAME - Update the domain module and SeaORM entity as required
- Implement
upanddownin the generated migration - Check that the migration is registered in
migrations/mod.rs - Run
just format,just build, andjust testthe verify the code is correct and the migration works against a temporary PostgreSQL database
Create a migration with:
just add-migration add_widget
This generates a file such as
src/leicmin/src/data/migrations/m20261011_033343_add_widget.rs and updates
src/leicmin/src/data/migrations/mod.rs.
Migration tracking normally runs each migration once. Use guards such as
if_not_exists or conflict-safe inserts only when they are appropriate; do not
hide an existing object with the wrong definition.
Topics
Migration history
Leicmin previously used SQLx migrations. The legacy _sqlx_migrations history is checked separately from the current SeaORM seaql_migrations history. Do not reorder or remove entries from the legacy compatibility list in src/leicmin/src/data/mod.rs.
src/leicmin/src/data/schema.rs is legacy holdover code from the original Diesel/Rust implementation. It is not part of the active database migration path and must not be modified for new schema changes. All known instllations of Leicmin have already been updated and no changes should be made to this file.