forked from Leuchtfeuer/mautic-deutschepost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeuchtfeuerPrintmailingBundle.php
48 lines (41 loc) · 1.53 KB
/
LeuchtfeuerPrintmailingBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace MauticPlugin\LeuchtfeuerPrintmailingBundle;
use Doctrine\DBAL\Schema\Schema;
use Mautic\CoreBundle\Factory\MauticFactory;
use Mautic\PluginBundle\Bundle\PluginBundleBase;
use Mautic\PluginBundle\Entity\Plugin;
class LeuchtfeuerPrintmailingBundle extends PluginBundleBase
{
public static function onPluginUpdate(Plugin $plugin, MauticFactory $factory, $metadata = null, Schema $installedSchema = null)
{
$database = $factory->getDatabase();
$platform = $database->getDatabasePlatform()->getName();
$queries = [];
$fromVersion = $plugin->getVersion();
switch ($fromVersion) {
case '1.0.0':
switch ($platform) {
case 'mysql':
$queries[] = sprintf(
'ALTER TABLE %strigger_campaigns CHANGE end_date end_date datetime DEFAULT NULL COMMENT \'(DC2Type:datetime)\'',
MAUTIC_TABLE_PREFIX
);
break;
}
break;
}
if (!empty($queries)) {
$database->beginTransaction();
try {
foreach ($queries as $query) {
$database->query($query);
}
$database->commit();
} catch (\Exception $exception) {
$database->rollBack();
throw $exception;
}
}
parent::updatePluginSchema($metadata, $installedSchema, $factory);
}
}