Version20180308222215::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 9
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace App\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 Version20180308222215 extends AbstractMigration
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\DBAL\Migrations\AbstractMigration has been deprecated: Please use Doctrine\Migrations\AbstractMigration ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

11
class Version20180308222215 extends /** @scrutinizer ignore-deprecated */ AbstractMigration
Loading history...
12
{
13
    public function up(Schema $schema)
14
    {
15
        // this up() migration is auto-generated, please modify it to your needs
16
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
17
18
        $this->addSql('CREATE TABLE users__organizations (user_id INT NOT NULL, organization_id INT NOT NULL, INDEX IDX_9394C5E4A76ED395 (user_id), INDEX IDX_9394C5E432C8A3DE (organization_id), PRIMARY KEY(user_id, organization_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
19
        $this->addSql('ALTER TABLE users__organizations ADD CONSTRAINT FK_9394C5E4A76ED395 FOREIGN KEY (user_id) REFERENCES users__user (id) ON DELETE CASCADE');
20
        $this->addSql('ALTER TABLE users__organizations ADD CONSTRAINT FK_9394C5E432C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE');
21
        $this->addSql('ALTER TABLE users__user DROP FOREIGN KEY FK_37C1021B32C8A3DE');
22
        $this->addSql('DROP INDEX IDX_37C1021B32C8A3DE ON users__user');
23
        $this->addSql('ALTER TABLE users__user DROP organization_id');
24
    }
25
26
    public function down(Schema $schema)
27
    {
28
        // this down() migration is auto-generated, please modify it to your needs
29
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
30
31
        $this->addSql('DROP TABLE users__organizations');
32
        $this->addSql('ALTER TABLE users__user ADD organization_id INT DEFAULT NULL');
33
        $this->addSql('ALTER TABLE users__user ADD CONSTRAINT FK_37C1021B32C8A3DE FOREIGN KEY (organization_id) REFERENCES organization (id)');
34
        $this->addSql('CREATE INDEX IDX_37C1021B32C8A3DE ON users__user (organization_id)');
35
    }
36
}
37