|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\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 Version20170710101158 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 developtech_agility__repositories__repository (id INT AUTO_INCREMENT NOT NULL, project_id INT NOT NULL, type VARCHAR(10) NOT NULL, INDEX IDX_351FAE0B166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
22
|
|
|
$this->addSql('CREATE TABLE developtech_agility__repositories__github (id INT NOT NULL, owner VARCHAR(255) NOT NULL, owner_type VARCHAR(15) 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 developtech_agility__beta_testers (id INT AUTO_INCREMENT NOT NULL, account_id INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_D9C191609B6B5FBA (account_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
24
|
|
|
$this->addSql('CREATE TABLE developtech_agility__beta_tests (id INT AUTO_INCREMENT NOT NULL, project_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL, started_at DATETIME NOT NULL, ended_at DATETIME NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_ED350ED2166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
25
|
|
|
$this->addSql('CREATE TABLE beta_test_beta_tester (beta_test_id INT NOT NULL, beta_tester_id INT NOT NULL, INDEX IDX_19F86C6A25B284CA (beta_test_id), INDEX IDX_19F86C6A204E40D7 (beta_tester_id), PRIMARY KEY(beta_test_id, beta_tester_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); |
|
26
|
|
|
$this->addSql('ALTER TABLE developtech_agility__repositories__repository ADD CONSTRAINT FK_351FAE0B166D1F9C FOREIGN KEY (project_id) REFERENCES developtech_agility__projects (id)'); |
|
27
|
|
|
$this->addSql('ALTER TABLE developtech_agility__repositories__github ADD CONSTRAINT FK_7E6C0ED3BF396750 FOREIGN KEY (id) REFERENCES developtech_agility__repositories__repository (id) ON DELETE CASCADE'); |
|
28
|
|
|
$this->addSql('ALTER TABLE developtech_agility__beta_testers ADD CONSTRAINT FK_D9C191609B6B5FBA FOREIGN KEY (account_id) REFERENCES users__user (id)'); |
|
29
|
|
|
$this->addSql('ALTER TABLE developtech_agility__beta_tests ADD CONSTRAINT FK_ED350ED2166D1F9C FOREIGN KEY (project_id) REFERENCES developtech_agility__projects (id) ON DELETE CASCADE'); |
|
30
|
|
|
$this->addSql('ALTER TABLE beta_test_beta_tester ADD CONSTRAINT FK_19F86C6A25B284CA FOREIGN KEY (beta_test_id) REFERENCES developtech_agility__beta_tests (id) ON DELETE CASCADE'); |
|
31
|
|
|
$this->addSql('ALTER TABLE beta_test_beta_tester ADD CONSTRAINT FK_19F86C6A204E40D7 FOREIGN KEY (beta_tester_id) REFERENCES developtech_agility__beta_testers (id) ON DELETE CASCADE'); |
|
32
|
|
|
$this->addSql('ALTER TABLE developtech_agility__projects DROP nbBetaTesters, DROP betaTestStatus'); |
|
33
|
|
|
$this->addSql('ALTER TABLE developtech_agility__jobs DROP FOREIGN KEY FK_1D411D77166D1F9C'); |
|
34
|
|
|
$this->addSql('ALTER TABLE developtech_agility__jobs ADD CONSTRAINT FK_1D411D77166D1F9C FOREIGN KEY (project_id) REFERENCES developtech_agility__projects (id) ON DELETE CASCADE'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param Schema $schema |
|
39
|
|
|
*/ |
|
40
|
|
|
public function down(Schema $schema) |
|
41
|
|
|
{ |
|
42
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
43
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
44
|
|
|
|
|
45
|
|
|
$this->addSql('ALTER TABLE developtech_agility__repositories__github DROP FOREIGN KEY FK_7E6C0ED3BF396750'); |
|
46
|
|
|
$this->addSql('ALTER TABLE beta_test_beta_tester DROP FOREIGN KEY FK_19F86C6A204E40D7'); |
|
47
|
|
|
$this->addSql('ALTER TABLE beta_test_beta_tester DROP FOREIGN KEY FK_19F86C6A25B284CA'); |
|
48
|
|
|
$this->addSql('DROP TABLE developtech_agility__repositories__repository'); |
|
49
|
|
|
$this->addSql('DROP TABLE developtech_agility__repositories__github'); |
|
50
|
|
|
$this->addSql('DROP TABLE developtech_agility__beta_testers'); |
|
51
|
|
|
$this->addSql('DROP TABLE developtech_agility__beta_tests'); |
|
52
|
|
|
$this->addSql('DROP TABLE beta_test_beta_tester'); |
|
53
|
|
|
$this->addSql('ALTER TABLE developtech_agility__jobs DROP FOREIGN KEY FK_1D411D77166D1F9C'); |
|
54
|
|
|
$this->addSql('ALTER TABLE developtech_agility__jobs ADD CONSTRAINT FK_1D411D77166D1F9C FOREIGN KEY (project_id) REFERENCES developtech_agility__projects (id)'); |
|
55
|
|
|
$this->addSql('ALTER TABLE developtech_agility__projects ADD nbBetaTesters INT NOT NULL, ADD betaTestStatus VARCHAR(12) NOT NULL COLLATE utf8_unicode_ci'); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|