Migrations

Database migrations can be brought by plugins and AdditionalBundles.

If you want to know more about migrations you can follow the steps from the Shopware documentation:

All migrations are located in the Migration/-directory of your plugin or AdditionalBundle per default.

Adding a migration to an AdditionalBundle

Shopware provides the database:create-migration console command to easily create a new migration.

To create a new migration in an AdditionalBundle you must call the command with some options:

The following example command adds a migration MyMigration to the Migration/-directory of the FooBundle:

Delete data on plugin uninstallation

If you have some migrations which add new database tables you also want to delete these tables on plugin uninstallation. dustin/shopware-utils automatically takes care about that! The only thing you need to do is to tell which tables need to be deleted on plugin uninstallation.

Overwrite the getTablesToRemove -method of your plugin or AdditionalBundle.

dustin/shopware-utils will execute the following steps to remove your tables from database:

  1. Execute a DELETE-statement for each table in the given order. All statements will be executed in a single transaction. If there is an error and the transaction fails a rollback will be executed and the exception will be thrown. If the transaction is successful all tables should be present but with no data.

  2. Execute a DROP TABLE-statement for each table in the given order.

Last updated