1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Migrations; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration, |
6
|
|
|
Doctrine\DBAL\Schema\Schema; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Auto-generated Migration: Please modify to your needs! |
10
|
|
|
*/ |
11
|
|
|
class Version20130829114417 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 mail_event (mail_id INT NOT NULL, event_id INT NOT NULL, INDEX IDX_F6DA8C8C8776F01 (mail_id), INDEX IDX_F6DA8C871F7E88B (event_id), PRIMARY KEY(mail_id, event_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"); |
19
|
|
|
$this->addSql("ALTER TABLE mail_event ADD CONSTRAINT FK_F6DA8C8C8776F01 FOREIGN KEY (mail_id) REFERENCES event__mails (id) ON DELETE CASCADE"); |
20
|
|
|
$this->addSql("ALTER TABLE mail_event ADD CONSTRAINT FK_F6DA8C871F7E88B FOREIGN KEY (event_id) REFERENCES event__events (id) ON DELETE CASCADE"); |
21
|
|
|
$this->addSql("ALTER TABLE event__mails DROP FOREIGN KEY FK_DBF9BBCB71F7E88B"); |
22
|
|
|
$this->addSql("DROP INDEX IDX_DBF9BBCB71F7E88B ON event__mails"); |
23
|
|
|
$this->addSql("ALTER TABLE event__mails DROP event_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 mail_event"); |
32
|
|
|
$this->addSql("ALTER TABLE event__mails ADD event_id INT DEFAULT NULL"); |
33
|
|
|
$this->addSql("ALTER TABLE event__mails ADD CONSTRAINT FK_DBF9BBCB71F7E88B FOREIGN KEY (event_id) REFERENCES event__events (id) ON DELETE CASCADE"); |
34
|
|
|
$this->addSql("CREATE INDEX IDX_DBF9BBCB71F7E88B ON event__mails (event_id)"); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|