Database Configuration
Choosing the engine (Cargo features)
| Feature | What it brings |
|---|---|
orm (default) | SeaORM: entities, queries, migrations, sessions. No driver: the code compiles and makemigrations works, but the app can't connect to any database. |
sqlite, postgres, mysql | The engine's driver. Each one enables orm too. |
mariadb | Alias of mysql. |
all-databases | All three drivers at once, for multi-engine tooling. |
An app enables a single engine: enabling two is a compile error (except through all-databases). orm doesn't need to be written:
runique = { version = "3.0.0", features = ["postgres"] }
SQLite (Development)
1. Modify demo-app/Cargo.toml
[dependencies]
runique = { version = "3.0.0", features = ["sqlite"] }
2. Update .env
DATABASE_URL=sqlite:runique.db?mode=rwc
3. Restart
cargo run -p demo-app
SQLite by default, PostgreSQL recommended for production.
PostgreSQL (Production)
1. Install PostgreSQL
macOS:
brew install postgresql
brew services start postgresql
Linux (Debian/Ubuntu):
sudo apt-get install postgresql postgresql-contrib
sudo systemctl start postgresql
Windows:
- Download the installer
- Follow the installation wizard
2. Create the User and Database
-- Connect as admin
psql -U postgres
-- Create the user
CREATE USER runique_user WITH PASSWORD 'secure_password';
-- Create the database
CREATE DATABASE runique OWNER runique_user;
-- Grant permissions
GRANT ALL PRIVILEGES ON DATABASE runique TO runique_user;
GRANT ALL PRIVILEGES ON SCHEMA public TO runique_user;
3. Configure .env
IP_SERVER=127.0.0.1
PORT=3000
DEBUG=true
SECRET_KEY=your-secret-key-change-in-production
DB_ENGINE=postgres
DB_USER=runique_user
DB_PASSWORD=secure_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=runique
DATABASE_URL=postgres://runique_user:secure_password@localhost:5432/runique
4. Verify the Connection
psql -U runique_user -d runique -h localhost
Create a superuser
After applying migrations, create the first admin account:
runique create-superuser
The CLI guides through an interactive wizard: hash algorithm, username, email, password, then a confirmation step before creation.