|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the feedback project. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Florian Moser <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace DoctrineMigrations; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
17
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
21
|
|
|
*/ |
|
22
|
|
|
final class Version20180920132250 extends AbstractMigration |
|
23
|
|
|
{ |
|
24
|
|
|
public function up(Schema $schema): void |
|
25
|
|
|
{ |
|
26
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
27
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'sqlite', 'Migration can only be executed safely on \'sqlite\'.'); |
|
28
|
|
|
|
|
29
|
|
|
$this->addSql('DROP INDEX IDX_D79F6B1171F7E88B'); |
|
30
|
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__participant AS SELECT id, event_id, identifier, time_needed_in_minutes FROM participant'); |
|
31
|
|
|
$this->addSql('DROP TABLE participant'); |
|
32
|
|
|
$this->addSql('CREATE TABLE participant (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, event_id INTEGER DEFAULT NULL, identifier CLOB NOT NULL COLLATE BINARY, time_needed_in_minutes INTEGER DEFAULT NULL, CONSTRAINT FK_D79F6B1171F7E88B FOREIGN KEY (event_id) REFERENCES event (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); |
|
33
|
|
|
$this->addSql('INSERT INTO participant (id, event_id, identifier, time_needed_in_minutes) SELECT id, event_id, identifier, time_needed_in_minutes FROM __temp__participant'); |
|
34
|
|
|
$this->addSql('DROP TABLE __temp__participant'); |
|
35
|
|
|
$this->addSql('CREATE INDEX IDX_D79F6B1171F7E88B ON participant (event_id)'); |
|
36
|
|
|
$this->addSql('DROP INDEX IDX_DADD4A259D1C3019'); |
|
37
|
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__answer AS SELECT id, participant_id, question_number, value, private FROM answer'); |
|
38
|
|
|
$this->addSql('DROP TABLE answer'); |
|
39
|
|
|
$this->addSql('CREATE TABLE answer (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, participant_id INTEGER DEFAULT NULL, value CLOB NOT NULL COLLATE BINARY, private BOOLEAN NOT NULL, question_index INTEGER NOT NULL, CONSTRAINT FK_DADD4A259D1C3019 FOREIGN KEY (participant_id) REFERENCES participant (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); |
|
40
|
|
|
$this->addSql('INSERT INTO answer (id, participant_id, question_index, value, private) SELECT id, participant_id, question_number, value, private FROM __temp__answer'); |
|
41
|
|
|
$this->addSql('DROP TABLE __temp__answer'); |
|
42
|
|
|
$this->addSql('CREATE INDEX IDX_DADD4A259D1C3019 ON answer (participant_id)'); |
|
43
|
|
|
$this->addSql('DROP INDEX IDX_3BAE0AA74A798B6F'); |
|
44
|
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__event AS SELECT id, semester_id, name, date, feedback_start_time, feedback_end_time, template, template_name, has_lecture, has_exercise, final_template_version_loaded FROM event'); |
|
45
|
|
|
$this->addSql('DROP TABLE event'); |
|
46
|
|
|
$this->addSql('CREATE TABLE event (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, semester_id INTEGER DEFAULT NULL, name CLOB NOT NULL COLLATE BINARY, date CLOB NOT NULL COLLATE BINARY, feedback_start_time CLOB NOT NULL COLLATE BINARY, feedback_end_time CLOB NOT NULL COLLATE BINARY, template CLOB NOT NULL COLLATE BINARY, template_name CLOB NOT NULL COLLATE BINARY, has_lecture BOOLEAN NOT NULL, has_exercise BOOLEAN NOT NULL, final_template_version_loaded BOOLEAN NOT NULL, CONSTRAINT FK_3BAE0AA74A798B6F FOREIGN KEY (semester_id) REFERENCES semester (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); |
|
47
|
|
|
$this->addSql('INSERT INTO event (id, semester_id, name, date, feedback_start_time, feedback_end_time, template, template_name, has_lecture, has_exercise, final_template_version_loaded) SELECT id, semester_id, name, date, feedback_start_time, feedback_end_time, template, template_name, has_lecture, has_exercise, final_template_version_loaded FROM __temp__event'); |
|
48
|
|
|
$this->addSql('DROP TABLE __temp__event'); |
|
49
|
|
|
$this->addSql('CREATE INDEX IDX_3BAE0AA74A798B6F ON event (semester_id)'); |
|
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($this->connection->getDatabasePlatform()->getName() !== 'sqlite', 'Migration can only be executed safely on \'sqlite\'.'); |
|
56
|
|
|
|
|
57
|
|
|
$this->addSql('DROP INDEX IDX_DADD4A259D1C3019'); |
|
58
|
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__answer AS SELECT id, participant_id, question_index, value, private FROM answer'); |
|
59
|
|
|
$this->addSql('DROP TABLE answer'); |
|
60
|
|
|
$this->addSql('CREATE TABLE answer (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, participant_id INTEGER DEFAULT NULL, value CLOB NOT NULL, private BOOLEAN NOT NULL, question_number INTEGER NOT NULL)'); |
|
61
|
|
|
$this->addSql('INSERT INTO answer (id, participant_id, question_number, value, private) SELECT id, participant_id, question_index, value, private FROM __temp__answer'); |
|
62
|
|
|
$this->addSql('DROP TABLE __temp__answer'); |
|
63
|
|
|
$this->addSql('CREATE INDEX IDX_DADD4A259D1C3019 ON answer (participant_id)'); |
|
64
|
|
|
$this->addSql('DROP INDEX IDX_3BAE0AA74A798B6F'); |
|
65
|
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__event AS SELECT id, semester_id, name, date, feedback_start_time, feedback_end_time, template, template_name, has_lecture, has_exercise, final_template_version_loaded FROM event'); |
|
66
|
|
|
$this->addSql('DROP TABLE event'); |
|
67
|
|
|
$this->addSql('CREATE TABLE event (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, semester_id INTEGER DEFAULT NULL, name CLOB NOT NULL, date CLOB NOT NULL, feedback_start_time CLOB NOT NULL, feedback_end_time CLOB NOT NULL, template CLOB NOT NULL, template_name CLOB NOT NULL, has_lecture BOOLEAN NOT NULL, has_exercise BOOLEAN NOT NULL, final_template_version_loaded BOOLEAN NOT NULL)'); |
|
68
|
|
|
$this->addSql('INSERT INTO event (id, semester_id, name, date, feedback_start_time, feedback_end_time, template, template_name, has_lecture, has_exercise, final_template_version_loaded) SELECT id, semester_id, name, date, feedback_start_time, feedback_end_time, template, template_name, has_lecture, has_exercise, final_template_version_loaded FROM __temp__event'); |
|
69
|
|
|
$this->addSql('DROP TABLE __temp__event'); |
|
70
|
|
|
$this->addSql('CREATE INDEX IDX_3BAE0AA74A798B6F ON event (semester_id)'); |
|
71
|
|
|
$this->addSql('DROP INDEX IDX_D79F6B1171F7E88B'); |
|
72
|
|
|
$this->addSql('CREATE TEMPORARY TABLE __temp__participant AS SELECT id, event_id, identifier, time_needed_in_minutes FROM participant'); |
|
73
|
|
|
$this->addSql('DROP TABLE participant'); |
|
74
|
|
|
$this->addSql('CREATE TABLE participant (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, event_id INTEGER DEFAULT NULL, identifier CLOB NOT NULL, time_needed_in_minutes INTEGER DEFAULT NULL)'); |
|
75
|
|
|
$this->addSql('INSERT INTO participant (id, event_id, identifier, time_needed_in_minutes) SELECT id, event_id, identifier, time_needed_in_minutes FROM __temp__participant'); |
|
76
|
|
|
$this->addSql('DROP TABLE __temp__participant'); |
|
77
|
|
|
$this->addSql('CREATE INDEX IDX_D79F6B1171F7E88B ON participant (event_id)'); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|