1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace BitBag\SyliusMolliePlugin\Migrations; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
8
|
|
|
use Doctrine\Migrations\AbstractMigration; |
9
|
|
|
|
10
|
|
|
final class Version20210326134353 extends AbstractMigration |
11
|
|
|
{ |
12
|
|
|
public function getDescription(): string |
13
|
|
|
{ |
14
|
|
|
return ''; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function up(Schema $schema): void |
18
|
|
|
{ |
19
|
|
|
$adjustmentTableAltered = $schema->getTable('sylius_adjustment')->hasColumn('shipment_id'); |
20
|
|
|
$channelTableAltered = $schema->getTable('sylius_channel')->hasColumn('contact_phone_number'); |
21
|
|
|
$attributeTableAltered = $schema->getTable('sylius_product_attribute')->hasColumn('translatable'); |
22
|
|
|
$shipmentTableAltered = $schema->getTable('sylius_shipment')->hasColumn('adjustments_total'); |
23
|
|
|
if ($adjustmentTableAltered && $channelTableAltered && $attributeTableAltered && $shipmentTableAltered) { |
24
|
|
|
return; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$this->addSql('ALTER TABLE sylius_adjustment ADD shipment_id INT DEFAULT NULL, ADD details JSON NOT NULL'); |
28
|
|
|
$this->addSql('ALTER TABLE sylius_adjustment ADD CONSTRAINT FK_ACA6E0F27BE036FC FOREIGN KEY (shipment_id) REFERENCES sylius_shipment (id) ON DELETE CASCADE'); |
29
|
|
|
$this->addSql('CREATE INDEX IDX_ACA6E0F27BE036FC ON sylius_adjustment (shipment_id)'); |
30
|
|
|
$this->addSql('ALTER TABLE sylius_channel ADD contact_phone_number VARCHAR(255) DEFAULT NULL'); |
31
|
|
|
$this->addSql('ALTER TABLE sylius_product_attribute ADD translatable TINYINT(1) DEFAULT \'1\' NOT NULL'); |
32
|
|
|
$this->addSql('ALTER TABLE sylius_product_attribute_value CHANGE locale_code locale_code VARCHAR(255) DEFAULT NULL'); |
33
|
|
|
$this->addSql('ALTER TABLE sylius_shipment ADD adjustments_total INT NOT NULL'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function down(Schema $schema): void |
37
|
|
|
{ |
38
|
|
|
$this->addSql('ALTER TABLE sylius_adjustment DROP FOREIGN KEY FK_ACA6E0F27BE036FC'); |
39
|
|
|
$this->addSql('DROP INDEX IDX_ACA6E0F27BE036FC ON sylius_adjustment'); |
40
|
|
|
$this->addSql('ALTER TABLE sylius_adjustment DROP shipment_id, DROP details'); |
41
|
|
|
$this->addSql('ALTER TABLE sylius_channel DROP contact_phone_number'); |
42
|
|
|
$this->addSql('ALTER TABLE sylius_product_attribute DROP translatable'); |
43
|
|
|
$this->addSql('ALTER TABLE sylius_product_attribute_value CHANGE locale_code locale_code VARCHAR(255) CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`'); |
44
|
|
|
$this->addSql('ALTER TABLE sylius_shipment DROP adjustments_total'); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|