To a web system already in production, I am adding new functionalities that include modifications to the database schema. As I develop, I upload the changes to our organization's GitLab and the node administrator pushes them to the production server. Previously on the production server it was done doctrine:schema:update
to deal with changes to the database, but now I've started using the DoctrineMigrationsBundle ; My question is whether the migration files are generated by me in my development environment and I must upload them to version control to be executed, or if I leave them outside of version control and the server administrator in production has to take care of generating and executing them. ??
The answer is yes .
Could it also be done without adding the folder in version control? Yes, but sometimes you would have to work 2 times (at least), and if there was a problem it would take longer to find where it came from. That is, greater probability of errors and problems.
Explanation
When creating a new file with the changes in your entities (
php bin/console make:migration
) at the beginning of the file that generates you, you find this:In other words, it is making your job easier by creating a version, but since it is possible that the fields are not in the order you want (this happens to me frequently), or you want to add/remove records, or you want to leave a description, etc, tells you to modify the file to your needs.
If you make any changes to your file and do not put it in the repository, when you want to put the new functionality into production and generate the file again, you would have to remember the changes that had to be made (work 2 times). And if you work with more developers, everyone would have to remember the modifications to make. If you put it in the repository, in all cases it will be as easy as running
php bin/console doctrine:migrations:migrate
Another issue is that, having tested it in the test environment, you ensure that the migration that is going to be put into production is already validated in another environment. It always gives more confidence and peace of mind.
It also happens that if the development team is large, and modifications are uploaded to the DB in different tasks, when putting into production and making all the changes in a single version, if a problem related to the DB occurs, it would be more laborious to find which task the error comes from.
And, although this last point may not be so important (or it is), if in your development you create several versions and in production the changes are made in only one, the table records
doctrine_migration_versions
will be different.I hope it helps.