|
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 Version20190512152317 extends AbstractMigration |
|
14
|
|
|
{ |
|
15
|
|
|
public function getDescription(): string |
|
16
|
|
|
{ |
|
17
|
|
|
return 'Add attachments table'; |
|
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_attachment ( |
|
26
|
|
|
uuid UUID NOT NULL, |
|
27
|
|
|
lesson_uuid UUID NOT NULL, |
|
28
|
|
|
file_name VARCHAR(255) NOT NULL, |
|
29
|
|
|
file_extension VARCHAR(10) NOT NULL, |
|
30
|
|
|
PRIMARY KEY(uuid) |
|
31
|
|
|
)'); |
|
32
|
|
|
$this->addSql('CREATE INDEX IDX_76CE10B2E80E96C2 ON npd_attachment (lesson_uuid)'); |
|
33
|
|
|
$this->addSql('COMMENT ON COLUMN npd_attachment.uuid IS \'(DC2Type:uuid)\''); |
|
34
|
|
|
$this->addSql('COMMENT ON COLUMN npd_attachment.lesson_uuid IS \'(DC2Type:uuid)\''); |
|
35
|
|
|
$this->addSql('ALTER TABLE |
|
36
|
|
|
npd_attachment |
|
37
|
|
|
ADD |
|
38
|
|
|
CONSTRAINT FK_76CE10B2E80E96C2 FOREIGN KEY (lesson_uuid) REFERENCES npd_lesson (uuid) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
39
|
|
|
$this->addSql('ALTER TABLE npd_lesson ALTER duration_in_minutes DROP DEFAULT'); |
|
40
|
|
|
$this->addSql('ALTER TABLE npd_lesson ALTER duration_in_minutes SET NOT NULL'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function down(Schema $schema): void |
|
44
|
|
|
{ |
|
45
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
46
|
|
|
$this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
47
|
|
|
|
|
48
|
|
|
$this->addSql('DROP TABLE npd_attachment'); |
|
49
|
|
|
$this->addSql('ALTER TABLE npd_lesson ALTER duration_in_minutes SET DEFAULT 0'); |
|
50
|
|
|
$this->addSql('ALTER TABLE npd_lesson ALTER duration_in_minutes DROP NOT NULL'); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|