|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Migrations; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
8
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
12
|
|
|
*/ |
|
13
|
|
|
final class Version20190223101249 extends AbstractMigration |
|
14
|
|
|
{ |
|
15
|
|
|
public function getDescription(): string |
|
16
|
|
|
{ |
|
17
|
|
|
return ''; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function up(Schema $schema): void |
|
21
|
|
|
{ |
|
22
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
23
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
24
|
|
|
|
|
25
|
|
|
$this->addSql('CREATE TABLE user_course ( |
|
26
|
|
|
user_id UUID NOT NULL, |
|
27
|
|
|
course_id INT NOT NULL, |
|
28
|
|
|
PRIMARY KEY(user_id, course_id) |
|
29
|
|
|
)'); |
|
30
|
|
|
$this->addSql('CREATE INDEX IDX_73CC7484A76ED395 ON user_course (user_id)'); |
|
31
|
|
|
$this->addSql('CREATE INDEX IDX_73CC7484591CC992 ON user_course (course_id)'); |
|
32
|
|
|
$this->addSql('COMMENT ON COLUMN user_course.user_id IS \'(DC2Type:uuid)\''); |
|
33
|
|
|
$this->addSql('ALTER TABLE |
|
34
|
|
|
user_course |
|
35
|
|
|
ADD |
|
36
|
|
|
CONSTRAINT FK_73CC7484A76ED395 FOREIGN KEY (user_id) REFERENCES npd_user (uuid) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
37
|
|
|
$this->addSql('ALTER TABLE |
|
38
|
|
|
user_course |
|
39
|
|
|
ADD |
|
40
|
|
|
CONSTRAINT FK_73CC7484591CC992 FOREIGN KEY (course_id) REFERENCES course (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
41
|
|
|
$this->addSql('ALTER TABLE npd_user ADD first_name VARCHAR(255) NOT NULL'); |
|
42
|
|
|
$this->addSql('ALTER TABLE npd_user ADD last_name VARCHAR(255) NOT NULL'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function down(Schema $schema): void |
|
46
|
|
|
{ |
|
47
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
48
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
49
|
|
|
|
|
50
|
|
|
$this->addSql('DROP TABLE user_course'); |
|
51
|
|
|
$this->addSql('ALTER TABLE npd_user DROP first_name'); |
|
52
|
|
|
$this->addSql('ALTER TABLE npd_user DROP last_name'); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|