1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\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 Version20180726182039 extends AbstractMigration |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param Schema $schema |
15
|
|
|
*/ |
16
|
|
|
public function up(Schema $schema) |
17
|
|
|
{ |
18
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
19
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
20
|
|
|
|
21
|
|
|
$this->addSql('CREATE TABLE mail_eventaudience (mail_id INT NOT NULL, eventaudience_id INT NOT NULL, INDEX IDX_16F0DEC6C8776F01 (mail_id), INDEX IDX_16F0DEC6BF29EF41 (eventaudience_id), PRIMARY KEY(mail_id, eventaudience_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
22
|
|
|
$this->addSql('CREATE TABLE event_audience (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
23
|
|
|
$this->addSql('CREATE TABLE events_audiences (eventaudience_id INT NOT NULL, event_id INT NOT NULL, INDEX IDX_916BFFEBBF29EF41 (eventaudience_id), INDEX IDX_916BFFEB71F7E88B (event_id), PRIMARY KEY(eventaudience_id, event_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
24
|
|
|
$this->addSql('ALTER TABLE mail_eventaudience ADD CONSTRAINT FK_16F0DEC6C8776F01 FOREIGN KEY (mail_id) REFERENCES event__mails (id) ON DELETE CASCADE'); |
25
|
|
|
$this->addSql('ALTER TABLE mail_eventaudience ADD CONSTRAINT FK_16F0DEC6BF29EF41 FOREIGN KEY (eventaudience_id) REFERENCES event_audience (id) ON DELETE CASCADE'); |
26
|
|
|
$this->addSql('ALTER TABLE events_audiences ADD CONSTRAINT FK_916BFFEBBF29EF41 FOREIGN KEY (eventaudience_id) REFERENCES event_audience (id) ON DELETE CASCADE'); |
27
|
|
|
$this->addSql('ALTER TABLE events_audiences ADD CONSTRAINT FK_916BFFEB71F7E88B FOREIGN KEY (event_id) REFERENCES event__events (id) ON DELETE CASCADE'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param Schema $schema |
32
|
|
|
*/ |
33
|
|
|
public function down(Schema $schema) |
34
|
|
|
{ |
35
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
36
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
37
|
|
|
|
38
|
|
|
$this->addSql('ALTER TABLE mail_eventaudience DROP FOREIGN KEY FK_16F0DEC6BF29EF41'); |
39
|
|
|
$this->addSql('ALTER TABLE events_audiences DROP FOREIGN KEY FK_916BFFEBBF29EF41'); |
40
|
|
|
$this->addSql('DROP TABLE mail_eventaudience'); |
41
|
|
|
$this->addSql('DROP TABLE event_audience'); |
42
|
|
|
$this->addSql('DROP TABLE events_audiences'); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|