Completed
Push — Recipes ( c0466a...7632b6 )
by Laurent
04:22
created

Version20190330102342   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A up() 0 10 1
A down() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineMigrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190330102342 extends AbstractMigration
14
{
15
    public function getDescription() : string
16
    {
17
        return '';
18
    }
19
20
    public function up(Schema $schema) : void
21
    {
22
        // this up() migration is auto-generated, please modify it to your needs
23
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
24
25
        $this->addSql('CREATE TABLE gs_material (id INT AUTO_INCREMENT NOT NULL, unit_working_id INT DEFAULT NULL, name VARCHAR(180) NOT NULL, active TINYINT(1) NOT NULL, multiple TINYINT(1) NOT NULL, slug VARCHAR(128) NOT NULL, UNIQUE INDEX UNIQ_BB6128975E237E06 (name), UNIQUE INDEX UNIQ_BB612897989D9B62 (slug), INDEX IDX_BB61289726A1E4F6 (unit_working_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
26
        $this->addSql('CREATE TABLE gs_material_article (material_id INT NOT NULL, article_id INT NOT NULL, INDEX IDX_BDAC0F2E308AC6F (material_id), INDEX IDX_BDAC0F27294869C (article_id), PRIMARY KEY(material_id, article_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
27
        $this->addSql('ALTER TABLE gs_material ADD CONSTRAINT FK_BB61289726A1E4F6 FOREIGN KEY (unit_working_id) REFERENCES app_unit (id)');
28
        $this->addSql('ALTER TABLE gs_material_article ADD CONSTRAINT FK_BDAC0F2E308AC6F FOREIGN KEY (material_id) REFERENCES gs_material (id) ON DELETE CASCADE');
29
        $this->addSql('ALTER TABLE gs_material_article ADD CONSTRAINT FK_BDAC0F27294869C FOREIGN KEY (article_id) REFERENCES app_article (id) ON DELETE CASCADE');
30
    }
31
32
    public function down(Schema $schema) : void
33
    {
34
        // this down() migration is auto-generated, please modify it to your needs
35
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
36
37
        $this->addSql('ALTER TABLE gs_material_article DROP FOREIGN KEY FK_BDAC0F2E308AC6F');
38
        $this->addSql('DROP TABLE gs_material');
39
        $this->addSql('DROP TABLE gs_material_article');
40
    }
41
}
42