|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Sylius\Migrations; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
|
6
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
10
|
|
|
*/ |
|
11
|
|
|
class Version20161116115138 extends AbstractMigration |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param Schema $schema |
|
15
|
|
|
*/ |
|
16
|
|
|
public function up(Schema $schema) |
|
17
|
|
|
{ |
|
18
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
19
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
20
|
|
|
|
|
21
|
|
|
$this->addSql('DROP TABLE sylius_product_taxon'); |
|
22
|
|
|
$this->addSql('CREATE TABLE sylius_product_taxon (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, taxon_id INT NOT NULL, position INT NOT NULL, INDEX IDX_1539E9AF4584665A (product_id), INDEX IDX_1539E9AFDE13F470 (taxon_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
23
|
|
|
$this->addSql('ALTER TABLE sylius_product_taxon ADD CONSTRAINT FK_1539E9AF4584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); |
|
24
|
|
|
$this->addSql('ALTER TABLE sylius_product_taxon ADD CONSTRAINT FK_1539E9AFDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); |
|
25
|
|
|
|
|
26
|
|
|
$this->addSql(' |
|
27
|
|
|
ALTER TABLE sylius_product_taxon DROP FOREIGN KEY FK_1539E9AF4584665A; |
|
28
|
|
|
ALTER TABLE sylius_product_taxon DROP FOREIGN KEY FK_1539E9AFDE13F470; |
|
29
|
|
|
DROP INDEX idx_1539e9af4584665a ON sylius_product_taxon; |
|
30
|
|
|
CREATE INDEX IDX_169C6CD94584665A ON sylius_product_taxon (product_id); |
|
31
|
|
|
DROP INDEX idx_1539e9afde13f470 ON sylius_product_taxon; |
|
32
|
|
|
CREATE INDEX IDX_169C6CD9DE13F470 ON sylius_product_taxon (taxon_id); |
|
33
|
|
|
ALTER TABLE sylius_product_taxon ADD CONSTRAINT FK_1539E9AF4584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE; |
|
34
|
|
|
ALTER TABLE sylius_product_taxon ADD CONSTRAINT FK_1539E9AFDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE; |
|
35
|
|
|
'); |
|
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('DROP TABLE sylius_product_taxon'); |
|
47
|
|
|
$this->addSql('CREATE TABLE sylius_product_taxon (product_id INT NOT NULL, taxon_id INT NOT NULL, INDEX IDX_169C6CD94584665A (product_id), INDEX IDX_169C6CD9DE13F470 (taxon_id), PRIMARY KEY(product_id, taxon_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
48
|
|
|
$this->addSql('ALTER TABLE sylius_product_taxon ADD CONSTRAINT FK_169C6CD94584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); |
|
49
|
|
|
$this->addSql('ALTER TABLE sylius_product_taxon ADD CONSTRAINT FK_169C6CD9DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|