How to Generate an Installer for a Bundle¶
When you have implemented new entities, you want to be sure that upon installing the application, the entities are added to the database. For this, you need to create an installer. You can do it manually, however, it is more convenient to use a dump of the database as a template.
To create an installer for AcmeBundle:
Clear the application cache:
1
app/console cache:clear
Apply the changes that you defined in your code to the database:
1
bin/console doctrine:schema:update
Generate an installer and save it to the AcmeBundleInstaller.php:
1
app/console oro:migration:dump --bundle=AcmeBundle > AcmeBundleInstaller.php
Hint
The generated installer may contain a lot of excessive information as the same database table might contain options related to different bundles and entities while the generator has no option to distinguish which entity ‘has added’ particular options. Delete the information unrelated to your entities from the output file.
Move AcmeBundleInstall.php to the AcmeBundle/Migrations/Schema directory.
Reinstall your application instance.
Check that the database is synced with your code:
1
app/console doctrine:schema:update --dump-sql
If the database is successfully synchronized, you will see the following message:
1
Nothing to update - your database is already in sync with the current entity metadata.