|
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 Version20120221094827 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
|
|
|
|
|
18
|
|
|
$this->addSql("CREATE TABLE sponsors (id INT AUTO_INCREMENT NOT NULL, slug VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, site VARCHAR(255) DEFAULT NULL, logo VARCHAR(255) DEFAULT NULL, about LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB"); |
|
19
|
|
|
$this->addSql("CREATE TABLE event__events_sponsors (sponsor_id INT NOT NULL, event_id INT NOT NULL, INDEX IDX_3CCEC92812F7FB51 (sponsor_id), INDEX IDX_3CCEC92871F7E88B (event_id), PRIMARY KEY(sponsor_id, event_id)) ENGINE = InnoDB"); |
|
20
|
|
|
$this->addSql("ALTER TABLE event__events_sponsors ADD CONSTRAINT FK_3CCEC92812F7FB51 FOREIGN KEY (sponsor_id) REFERENCES sponsors(id)"); |
|
21
|
|
|
$this->addSql("ALTER TABLE event__events_sponsors ADD CONSTRAINT FK_3CCEC92871F7E88B FOREIGN KEY (event_id) REFERENCES event__events(id)"); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function down(Schema $schema) |
|
25
|
|
|
{ |
|
26
|
|
|
// this down() migration is autogenerated, please modify it to your needs |
|
27
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); |
|
28
|
|
|
|
|
29
|
|
|
$this->addSql("ALTER TABLE event__events_sponsors DROP FOREIGN KEY FK_3CCEC92812F7FB51"); |
|
30
|
|
|
$this->addSql("DROP TABLE sponsors"); |
|
31
|
|
|
$this->addSql("DROP TABLE event__events_sponsors"); |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|