Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 1.47 KB

File metadata and controls

61 lines (42 loc) · 1.47 KB

Database

Default connection

PostgreSQL is the default. The connection string is set in .env:

DATABASE_URL="postgresql://symfony:secret@localhost:5432/symfony?serverVersion=18&charset=utf8"

Override locally by creating .env.local (gitignored):

DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_dev.db"

Switch database backends

mise run db:use postgres   # PostgreSQL (default)
mise run db:use mysql      # MySQL / MariaDB
mise run db:use sqlite     # SQLite (no server required)

This rewrites DATABASE_URL in .env.local, adjusts Doctrine's identity_generation_preferences, wipes existing migrations, regenerates them for the new platform, and runs them.

Pass --no-migrate to switch the URL only without touching migrations:

mise run db:use sqlite --no-migrate

Migrations

mise run db:migrate   # run pending migrations
mise run db:fresh     # drop schema, re-run all migrations, reload fixtures (destructive)

Fixtures

Seed the database with demo data:

mise run db:seed

This loads:

Account Email Password Role
Admin admin@example.com password ROLE_ADMIN
Users (×10) user.{n}@example.com password ROLE_USER

Test database

The test environment appends a _test suffix to the database name (dbname_suffix in config/packages/doctrine.yaml), so tests never touch your development data. See Testing & Code Quality.