Issues (324)

src/Migrations/Version20180513163829.php (1 issue)

Severity
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 Version20180513163829 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 Version20180513163829 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 news (id INT AUTO_INCREMENT NOT NULL, category VARCHAR(30) NOT NULL, title VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, type VARCHAR(2) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
19
        $this->addSql('CREATE TABLE projects__news (id INT NOT NULL, project_id INT DEFAULT NULL, INDEX IDX_D577BD75166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
20
        $this->addSql('CREATE TABLE communities__news (id INT NOT NULL, community_id INT DEFAULT NULL, INDEX IDX_A7E8D52BFDA7B0BF (community_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
21
        $this->addSql('ALTER TABLE projects__news ADD CONSTRAINT FK_D577BD75166D1F9C FOREIGN KEY (project_id) REFERENCES developtech_agility__projects (id)');
22
        $this->addSql('ALTER TABLE projects__news ADD CONSTRAINT FK_D577BD75BF396750 FOREIGN KEY (id) REFERENCES news (id) ON DELETE CASCADE');
23
        $this->addSql('ALTER TABLE communities__news ADD CONSTRAINT FK_A7E8D52BFDA7B0BF FOREIGN KEY (community_id) REFERENCES communities__community (id)');
24
        $this->addSql('ALTER TABLE communities__news ADD CONSTRAINT FK_A7E8D52BBF396750 FOREIGN KEY (id) REFERENCES news (id) ON DELETE CASCADE');
25
    }
26
27
    public function down(Schema $schema)
28
    {
29
        // this down() migration is auto-generated, please modify it to your needs
30
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
31
32
        $this->addSql('ALTER TABLE projects__news DROP FOREIGN KEY FK_D577BD75BF396750');
33
        $this->addSql('ALTER TABLE communities__news DROP FOREIGN KEY FK_A7E8D52BBF396750');
34
        $this->addSql('DROP TABLE news');
35
        $this->addSql('DROP TABLE projects__news');
36
        $this->addSql('DROP TABLE communities__news');
37
    }
38
}
39