Spaces:
No application file
No application file
File size: 1,484 Bytes
d2897cd |
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 |
<?php
declare(strict_types=1);
namespace Mautic\IntegrationsBundle\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
class Version_0_0_1 extends AbstractMigration
{
private string $table = 'sync_object_mapping';
protected function isApplicable(Schema $schema): bool
{
try {
return !$schema->getTable($this->concatPrefix($this->table))->hasColumn('integration_reference_id');
} catch (SchemaException) {
return false;
}
}
protected function up(): void
{
$this->addSql("
ALTER TABLE `{$this->concatPrefix($this->table)}`
DROP INDEX `{$this->concatPrefix('integration_object')}`
");
$this->addSql("
ALTER TABLE `{$this->concatPrefix($this->table)}`
ADD `integration_reference_id` varchar(191) NULL AFTER `internal_object_name`
");
$this->addSql("
CREATE INDEX {$this->concatPrefix('integration_object')}
ON {$this->concatPrefix($this->table)}(integration, integration_object_name, integration_object_id, integration_reference_id);
");
$this->addSql("
CREATE INDEX {$this->concatPrefix('integration_reference')}
ON {$this->concatPrefix($this->table)}(integration, integration_object_name, integration_reference_id, integration_object_id);
");
}
}
|