Installation & Setup

Migrations (SeaORM)

Two-Step Workflow

1. Generate Migration Files

runique makemigrations reads your entities declared in src/entities and generates the corresponding migration files:

runique makemigrations --entities src/entities --migrations migration/src

What makemigrations does in a single command:

PassSourceOutput
1 — App tablesmodel!{} blocks in src/entitiesCREATE TABLE / ALTER TABLE
2 — Framework extensionsextend!{} blocks in src/entitiesALTER TABLE ADD/DROP COLUMN
3 — Admin positioningRUNIQUE_USER_TABLE in .envGuaranteed order in lib.rs

2. Apply Migrations

sea-orm-cli migrate up --migration-dir migration/src

Framework Tables — Provided Automatically

Runique automatically injects two migrations into your lib.rs without you having to define them:

MigrationCreatesOrder
EihwazUsersMigrationeihwaz_users (id, username, email, password, is_active, is_staff, is_superuser, created_at, updated_at)1st
AdminTableMigrationeihwaz_groupes, eihwaz_groupes_droits, eihwaz_users_groupes, eihwaz_history2nd

You do not need to declare eihwaz_users in your entities.


Extending a Framework Table — `extend!{}`

To add columns to a framework table, use extend!{} in an entity file:

use runique::prelude::*;

extend! {
    table: "eihwaz_users",
    fields: {
        avatar: image [upload_to: "avatars/"],
        bio: textarea,
        website: url [required],
    }
}

makemigrations detects these blocks and generates the corresponding ALTER TABLE ADD COLUMN statements. The extension snapshot is stored in migration/src/snapshots/runique/eihwaz_users.rs.

Extensible tables:

eihwaz_users · eihwaz_groupes · eihwaz_droits
eihwaz_sessions · eihwaz_users_groupes · eihwaz_groupes_droits

Extending an unknown table triggers a compile-time error.


Using a Custom User Table

If you prefer to manage your own user table, declare it in .env:

RUNIQUE_USER_TABLE=my_users_table

makemigrations will then position AdminTableMigration right after the migration for my_users_table. The FK in eihwaz_users_groupes will automatically target my_users_table.

Default (no RUNIQUE_USER_TABLE): eihwaz_users is used.


Other Migration Commands

sea-orm-cli migrate down --migration-dir migration/src   # Revert the last migration
sea-orm-cli migrate status --migration-dir migration/src # Check migration status

Runique Wrapper — Atomic Rollback (advanced)

runique migration down --migrations migration/src <file>
runique migration down --migrations migration/src --batch <timestamp>
runique migration status --migrations migration/src

These commands use the Runique batch system with transactional rollback. Prefer sea-orm-cli for the normal workflow.


runique makemigrations is the only tool to use for generating migration files. Do not use sea-orm-cli migrate generate: Runique maintains its own snapshots and chronological order.