Skip to content

Schema migrations

Carlo Beltrame edited this page Aug 21, 2025 · 2 revisions

Change the Schema of the Database

If you change the Schema of the Database (add or remove a field of an Entity), you also need to add schema migration.

  1. Make sure the api and the database is running on your local machine. docker compose up -d
  2. Generate the migrations with docker compose exec api bin/console doctrine:migrations:diff
  3. Modify the generated migration:
    1. Describe what your migration does in getDescription()
    2. Modify the up migration if you need to do something manually (like migrating data into the changed schema). If you do something manually, delete the comment that it was auto generated.
    3. Modify the down migration. The down migration should reverse the up migration. At least delete the $this->addSql('CREATE SCHEMA public'); in case that was generated.
  4. Execute your migration with docker compose exec api bin/console doctrine:migrations:migrate
  5. Validate that the schema is up to date with: docker compose exec api bin/console doctrine:schema:validate
Clone this wiki locally