|
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 Version20190511183642 extends AbstractMigration |
|
14
|
|
|
{ |
|
15
|
|
|
public function getDescription(): string |
|
16
|
|
|
{ |
|
17
|
|
|
return 'Add user lessons table with info about lessons progress'; |
|
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 npd_user_lesson ( |
|
26
|
|
|
uuid UUID NOT NULL, |
|
27
|
|
|
user_uuid UUID NOT NULL, |
|
28
|
|
|
lesson_uuid UUID NOT NULL, |
|
29
|
|
|
completed BOOLEAN DEFAULT NULL, |
|
30
|
|
|
created TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, |
|
31
|
|
|
updated TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, |
|
32
|
|
|
PRIMARY KEY(uuid) |
|
33
|
|
|
)'); |
|
34
|
|
|
$this->addSql('CREATE INDEX IDX_E4F546A3ABFE1C6F ON npd_user_lesson (user_uuid)'); |
|
35
|
|
|
$this->addSql('CREATE INDEX IDX_E4F546A3E80E96C2 ON npd_user_lesson (lesson_uuid)'); |
|
36
|
|
|
$this->addSql('COMMENT ON COLUMN npd_user_lesson.uuid IS \'(DC2Type:uuid)\''); |
|
37
|
|
|
$this->addSql('COMMENT ON COLUMN npd_user_lesson.user_uuid IS \'(DC2Type:uuid)\''); |
|
38
|
|
|
$this->addSql('COMMENT ON COLUMN npd_user_lesson.lesson_uuid IS \'(DC2Type:uuid)\''); |
|
39
|
|
|
$this->addSql('ALTER TABLE |
|
40
|
|
|
npd_user_lesson |
|
41
|
|
|
ADD |
|
42
|
|
|
CONSTRAINT FK_E4F546A3ABFE1C6F FOREIGN KEY (user_uuid) REFERENCES npd_user (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
43
|
|
|
$this->addSql('ALTER TABLE |
|
44
|
|
|
npd_user_lesson |
|
45
|
|
|
ADD |
|
46
|
|
|
CONSTRAINT FK_E4F546A3E80E96C2 FOREIGN KEY (lesson_uuid) REFERENCES npd_lesson (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
47
|
|
|
$this->addSql('ALTER TABLE npd_lesson DROP completed'); |
|
48
|
|
|
$this->addSql('ALTER INDEX idx_73cc7484a76ed395 RENAME TO IDX_A1F5DE9A76ED395'); |
|
49
|
|
|
$this->addSql('ALTER INDEX idx_73cc7484591cc992 RENAME TO IDX_A1F5DE9591CC992'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function down(Schema $schema): void |
|
53
|
|
|
{ |
|
54
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
55
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
56
|
|
|
|
|
57
|
|
|
$this->addSql('DROP TABLE npd_user_lesson'); |
|
58
|
|
|
$this->addSql('ALTER INDEX idx_a1f5de9a76ed395 RENAME TO idx_73cc7484a76ed395'); |
|
59
|
|
|
$this->addSql('ALTER INDEX idx_a1f5de9591cc992 RENAME TO idx_73cc7484591cc992'); |
|
60
|
|
|
$this->addSql('ALTER TABLE npd_lesson ADD completed BOOLEAN DEFAULT NULL'); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|