Doctrine – how to initialize DB values

I use Doctrine 2.7.0 in a Symfony 5.0 Application.
I define my DB tables within my Entities with ORM Annotations.
I create a migration with Symfony maker like this

php bin/console make:migration

then I create the raw DB (mySql) from that with

php bin/console doctrine:migrations:migrate

This results in a nice fresh DB.

Now – I am wondering if it is possible to define base data for the tables with Annotations.
I don’t mean to set default values for properties but to add entries to tables which the DB allways needs.

So basically I want the migration to insert entries to the DB too.
Is that possible?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *