Version20190206084706::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 Version20190206084706 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 department (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
26
        $this->addSql('CREATE TABLE application (id INT AUTO_INCREMENT NOT NULL, advert_id INT DEFAULT NULL, author_id INT NOT NULL, content LONGTEXT NOT NULL, INDEX IDX_A45BDDC1D07ECCB6 (advert_id), INDEX IDX_A45BDDC1F675F31B (author_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
27
        $this->addSql('ALTER TABLE application ADD CONSTRAINT FK_A45BDDC1D07ECCB6 FOREIGN KEY (advert_id) REFERENCES advert (id)');
28
        $this->addSql('ALTER TABLE application ADD CONSTRAINT FK_A45BDDC1F675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
29
        $this->addSql('ALTER TABLE advert ADD department_id INT DEFAULT NULL');
30
        $this->addSql('ALTER TABLE advert ADD CONSTRAINT FK_54F1F40BAE80F5DF FOREIGN KEY (department_id) REFERENCES department (id)');
31
        $this->addSql('CREATE INDEX IDX_54F1F40BAE80F5DF ON advert (department_id)');
32
    }
33
34
    public function down(Schema $schema) : void
35
    {
36
        // this down() migration is auto-generated, please modify it to your needs
37
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
38
39
        $this->addSql('ALTER TABLE advert DROP FOREIGN KEY FK_54F1F40BAE80F5DF');
40
        $this->addSql('DROP TABLE department');
41
        $this->addSql('DROP TABLE application');
42
        $this->addSql('DROP INDEX IDX_54F1F40BAE80F5DF ON advert');
43
        $this->addSql('ALTER TABLE advert DROP department_id');
44
    }
45
}
46