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 Version20170409213410 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 performanceevent_rowsforsale (performanceevent_id INT NOT NULL, rowsforsale_id INT NOT NULL, INDEX IDX_4B0B0CD3A663E1AC (performanceevent_id), INDEX IDX_4B0B0CD3A26F6674 (rowsforsale_id), PRIMARY KEY(performanceevent_id, rowsforsale_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
22
|
|
|
$this->addSql('CREATE TABLE rows_for_sale (id INT AUTO_INCREMENT NOT NULL, row INT NOT NULL, venueSector_id INT DEFAULT NULL, INDEX IDX_BB4AF581137F3880 (venueSector_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
23
|
|
|
$this->addSql('CREATE TABLE rows_for_sale_translation (id INT AUTO_INCREMENT NOT NULL, object_id INT DEFAULT NULL, locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_AA8BD619232D562B (object_id), UNIQUE INDEX lookup_unique_rows_for_sale_translation_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
24
|
|
|
$this->addSql('ALTER TABLE performanceevent_rowsforsale ADD CONSTRAINT FK_4B0B0CD3A663E1AC FOREIGN KEY (performanceevent_id) REFERENCES performance_schedule (id) ON DELETE CASCADE'); |
25
|
|
|
$this->addSql('ALTER TABLE performanceevent_rowsforsale ADD CONSTRAINT FK_4B0B0CD3A26F6674 FOREIGN KEY (rowsforsale_id) REFERENCES rows_for_sale (id) ON DELETE CASCADE'); |
26
|
|
|
$this->addSql('ALTER TABLE rows_for_sale ADD CONSTRAINT FK_BB4AF581137F3880 FOREIGN KEY (venueSector_id) REFERENCES venue_sector (id)'); |
27
|
|
|
$this->addSql('ALTER TABLE rows_for_sale_translation ADD CONSTRAINT FK_AA8BD619232D562B FOREIGN KEY (object_id) REFERENCES rows_for_sale (id) ON DELETE CASCADE'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param Schema $schema |
32
|
|
|
*/ |
33
|
|
View Code Duplication |
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 performanceevent_rowsforsale DROP FOREIGN KEY FK_4B0B0CD3A26F6674'); |
39
|
|
|
$this->addSql('ALTER TABLE rows_for_sale_translation DROP FOREIGN KEY FK_AA8BD619232D562B'); |
40
|
|
|
$this->addSql('DROP TABLE performanceevent_rowsforsale'); |
41
|
|
|
$this->addSql('DROP TABLE rows_for_sale'); |
42
|
|
|
$this->addSql('DROP TABLE rows_for_sale_translation'); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.