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 Version20160427100800 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('ALTER TABLE sylius_channel DROP FOREIGN KEY FK_16C8119E59027487'); |
22
|
|
|
$this->addSql('ALTER TABLE sylius_theme_parents DROP FOREIGN KEY FK_48942C67727ACA70'); |
23
|
|
|
$this->addSql('ALTER TABLE sylius_theme_parents DROP FOREIGN KEY FK_48942C67DD62C21B'); |
24
|
|
|
$this->addSql('DROP TABLE sylius_theme'); |
25
|
|
|
$this->addSql('DROP TABLE sylius_theme_parents'); |
26
|
|
|
$this->addSql('DROP INDEX IDX_16C8119E59027487 ON sylius_channel'); |
27
|
|
|
$this->addSql('ALTER TABLE sylius_channel ADD theme_name VARCHAR(255) DEFAULT NULL, DROP theme_id'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param Schema $schema |
32
|
|
|
*/ |
33
|
|
|
public function down(Schema $schema) |
34
|
|
|
{ |
35
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
36
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
37
|
|
|
|
38
|
|
|
$this->addSql('CREATE TABLE sylius_theme (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, title VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, path VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, code VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, description VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, authors LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci COMMENT \'(DC2Type:object)\', screenshots LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci COMMENT \'(DC2Type:array)\', UNIQUE INDEX UNIQ_3CAD5695E237E06 (name), INDEX IDX_3CAD5695E237E06 (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
39
|
|
|
$this->addSql('CREATE TABLE sylius_theme_parents (child_id INT NOT NULL, parent_id INT NOT NULL, INDEX IDX_48942C67DD62C21B (child_id), INDEX IDX_48942C67727ACA70 (parent_id), PRIMARY KEY(child_id, parent_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
40
|
|
|
$this->addSql('ALTER TABLE sylius_theme_parents ADD CONSTRAINT FK_48942C67727ACA70 FOREIGN KEY (parent_id) REFERENCES sylius_theme (id) ON DELETE CASCADE'); |
41
|
|
|
$this->addSql('ALTER TABLE sylius_theme_parents ADD CONSTRAINT FK_48942C67DD62C21B FOREIGN KEY (child_id) REFERENCES sylius_theme (id)'); |
42
|
|
|
$this->addSql('ALTER TABLE sylius_channel ADD theme_id INT DEFAULT NULL, DROP theme_name'); |
43
|
|
|
$this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119E59027487 FOREIGN KEY (theme_id) REFERENCES sylius_theme (id) ON DELETE SET NULL'); |
44
|
|
|
$this->addSql('CREATE INDEX IDX_16C8119E59027487 ON sylius_channel (theme_id)'); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|