|
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 Version20180312135229 extends AbstractMigration |
|
|
|
|
|
|
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 pictures (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
19
|
|
|
$this->addSql('CREATE TABLE communities__community (id INT AUTO_INCREMENT NOT NULL, picture_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_72B43A2B5E237E06 (name), UNIQUE INDEX UNIQ_72B43A2B989D9B62 (slug), UNIQUE INDEX UNIQ_72B43A2BEE45BDBF (picture_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
20
|
|
|
$this->addSql('ALTER TABLE communities__community ADD CONSTRAINT FK_72B43A2BEE45BDBF FOREIGN KEY (picture_id) REFERENCES pictures (id)'); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function down(Schema $schema) |
|
24
|
|
|
{ |
|
25
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
26
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
27
|
|
|
|
|
28
|
|
|
$this->addSql('ALTER TABLE communities__community DROP FOREIGN KEY FK_72B43A2BEE45BDBF'); |
|
29
|
|
|
$this->addSql('DROP TABLE pictures'); |
|
30
|
|
|
$this->addSql('DROP TABLE communities__community'); |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|