If you are working on infrastructure with a lot of microservices as a developer you may face difficulties executing SQL queries in terms of keeping database structure clean and safe cause there is a chance to miss or elude something. Essentially, if the microservices are written in Symfony then you should thanks to Doctrine which offers set of PHP libraries to work with DB migrations. So instead of executing SQL queries, you can use migrations which is necessary when your application begins to scale up. Here I will show you some basic doctrine commands.
- Symfony setup
Doctrine Database migrations example
Step 1. If your microservices are dockerized you need to get inside the container and navigate to the project path. So if there are migrations that are not being fetched by the other services, run:
Step 2. To see a list of all the different options that you can do, run:
Step 3. If you need to find Symfony commands that are handling the table creation, delete, insert, migration on a specific entity, run:
bin/console list doctrine
In most cases, you will have the database structure and the most used command will be the first one about the migration. If you have some other questions don’t hesitate to raise them. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.