Passed
Push — master ( 5a4fe7...aa8564 )
by Stepan
04:27
created

Version20121024115954   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 11
dl 0
loc 21
rs 10
c 0
b 0
f 0
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 need!
10
 */
11
class Version20121024115954 extends AbstractMigration
12
{
13
    public function up(Schema $schema)
14
    {
15
        // this up() migration is autogenerated, please modify it to your needs
16
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
17
        $this->addSql("ALTER TABLE event__events_sponsors DROP PRIMARY KEY");
18
        $this->addSql("ALTER TABLE event__events_sponsors ADD id INT NOT NULL AUTO_INCREMENT FIRST, ADD category_id INT DEFAULT NULL, CHANGE sponsor_id sponsor_id INT DEFAULT NULL, CHANGE event_id event_id INT DEFAULT NULL, ADD PRIMARY KEY (id)");
19
        $this->addSql("ALTER TABLE event__events_sponsors ADD CONSTRAINT FK_3CCEC92812469DE2 FOREIGN KEY (category_id) REFERENCES sponsors_category (id)");
20
        $this->addSql("CREATE INDEX IDX_3CCEC92812469DE2 ON event__events_sponsors (category_id)");
21
    }
22
23
    public function down(Schema $schema)
24
    {
25
        // this down() migration is autogenerated, please modify it to your needs
26
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
27
        
28
        $this->addSql("ALTER TABLE event__events_sponsors DROP FOREIGN KEY FK_3CCEC92812469DE2");
29
        $this->addSql("DROP INDEX IDX_3CCEC92812469DE2 ON event__events_sponsors");
30
        $this->addSql("ALTER TABLE event__events_sponsors DROP id, DROP category_id, CHANGE sponsor_id sponsor_id INT NOT NULL, CHANGE event_id event_id INT NOT NULL");
31
        $this->addSql("ALTER TABLE event__events_sponsors ADD PRIMARY KEY (sponsor_id, event_id)");
32
    }
33
}
34