1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Migrations; |
13
|
|
|
|
14
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
15
|
|
|
use Doctrine\DBAL\Schema\Schema; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Auto-generated Migration: Please modify to your needs! |
19
|
|
|
*/ |
20
|
|
|
class Version20160211130526 extends AbstractMigration |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @param Schema $schema |
24
|
|
|
*/ |
25
|
|
|
public function up(Schema $schema) |
26
|
|
|
{ |
27
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
28
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
29
|
|
|
|
30
|
|
|
$this->addSql('DROP TABLE sylius_promotion_coupon_order'); |
31
|
|
|
$this->addSql('DROP INDEX fulltext_search_idx ON sylius_search_index'); |
32
|
|
|
$this->addSql('CREATE INDEX fulltext_search_idx ON sylius_search_index (item_id)'); |
33
|
|
|
$this->addSql('ALTER TABLE sylius_order ADD promotion_coupon_id INT DEFAULT NULL'); |
34
|
|
|
$this->addSql('ALTER TABLE sylius_order ADD CONSTRAINT FK_6196A1F917B24436 FOREIGN KEY (promotion_coupon_id) REFERENCES sylius_promotion_coupon (id) ON DELETE SET NULL'); |
35
|
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_6196A1F917B24436 ON sylius_order (promotion_coupon_id)'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param Schema $schema |
40
|
|
|
*/ |
41
|
|
|
public function down(Schema $schema) |
42
|
|
|
{ |
43
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
44
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
45
|
|
|
|
46
|
|
|
$this->addSql('CREATE TABLE sylius_promotion_coupon_order (order_id INT NOT NULL, promotion_coupon_id INT NOT NULL, INDEX IDX_D58E3BC48D9F6D38 (order_id), INDEX IDX_D58E3BC417B24436 (promotion_coupon_id), PRIMARY KEY(order_id, promotion_coupon_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
47
|
|
|
$this->addSql('ALTER TABLE sylius_promotion_coupon_order ADD CONSTRAINT FK_D58E3BC417B24436 FOREIGN KEY (promotion_coupon_id) REFERENCES sylius_promotion_coupon (id)'); |
48
|
|
|
$this->addSql('ALTER TABLE sylius_promotion_coupon_order ADD CONSTRAINT FK_D58E3BC48D9F6D38 FOREIGN KEY (order_id) REFERENCES sylius_order (id)'); |
49
|
|
|
$this->addSql('ALTER TABLE sylius_order DROP FOREIGN KEY FK_6196A1F917B24436'); |
50
|
|
|
$this->addSql('DROP INDEX UNIQ_6196A1F917B24436 ON sylius_order'); |
51
|
|
|
$this->addSql('ALTER TABLE sylius_order DROP promotion_coupon_id'); |
52
|
|
|
$this->addSql('DROP INDEX fulltext_search_idx ON sylius_search_index'); |
53
|
|
|
$this->addSql('CREATE FULLTEXT INDEX fulltext_search_idx ON sylius_search_index (value)'); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|