Shopware plugin to apply project-specific DB-Updates
- Checkout Plugin in
/custom/plugins/VioDbMigration
- Change to Directory and run
composer install
to install the dependencies - Install the Plugin with the Plugin Manager
- Change to your root Installation of shopware
- Run command
composer require viosys/vio-db-migration
and install and active plugin with Plugin Manager
- to install the plugin via build process, we have added an installation script
- which you could run in your ant-build or the composer post-update script
- Composer
- modify your repository version of
app/post-update.sh
- add the following line before the migration console command
/usr/bin/env php $(dirname "$0")/../custom/project/VioDbMigration/deploy.php --dbhost ${DB_HOST} --dbname ${DB_DATABASE} --dbuser ${DB_USERNAME} --dbpassword ${DB_PASSWORD} --migrationpath ${VIO_MIGRATIONPATH} --migrationnamespace ${VIO_MIGRATIONNAMESPACE}
- modify your repository version of
- Ant
- when you want to run and add VioDbMigration in your ant-build definition send a message
- create empty directory
vio_sql/migrations
- create Migration-Class with a consecutive number in the class name and in the file name
100-migration.php
<?php
class Migrations_Migration100 extends \VioDbMigration\Components\Migrations\VioAbstractMigration
{
public function up($modus)
{
$sql = "INSERT INTO ...";
$this->addsql($sql);
}
}
To define a depending shopware migration you could overwride the getDependendSwMigrationStep
method.
This will ensure, that the migration is executed directly after the defined migration,
public function getDependendSwMigrationStep()
{
return \Migrations_Migration920::class;
}
Within a VioDbMigration you could use the di-container. In example to install a plugin.
public function up($modus)
{
$pm = $this->container->get('shopware_plugininstaller.plugin_manager');
$pm->refreshPluginList();
$VioVariantFilter = $pm->getPluginByName('FroshProfiler');
if($VioVariantFilter){
if($VioVariantFilter->getInstalled()){
$pm->uninstallPlugin($VioVariantFilter);
}
}
}
There is a list of predefined method to executed common migrations:
addThemeConfigElementSql
-> insert or update a theme config valuesetConfigValue
-> insert or update a shop/plugin config valueaddCoreSnippets
-> replace a snippetinstallPlugin
-> shorthand to install a pluginremovePlugin
-> shorthand to clean delete a plugininsertPage
-> create shop pageinsertPageGroup
-> create a shop page group