diff --git a/migrations/Version20240501000553.php b/migrations/Version20240501000553.php new file mode 100644 index 0000000..5e7e42d --- /dev/null +++ b/migrations/Version20240501000553.php @@ -0,0 +1,53 @@ +addSql('CREATE TEMPORARY TABLE __temp__notes AS SELECT id, speaker_id, series_id, title, text, date, passage, refs FROM notes'); + $this->addSql('DROP TABLE notes'); + $this->addSql('CREATE TABLE notes (id VARCHAR(64) NOT NULL, speaker_id INTEGER NOT NULL, series_id INTEGER DEFAULT NULL, user_id INTEGER DEFAULT NULL, title VARCHAR(255) NOT NULL, text CLOB NOT NULL, date DATE NOT NULL, passage VARCHAR(255) DEFAULT NULL, refs CLOB DEFAULT NULL --(DC2Type:json) + , PRIMARY KEY(id), CONSTRAINT FK_11BA68CD04A0F27 FOREIGN KEY (speaker_id) REFERENCES speaker (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_11BA68C5278319C FOREIGN KEY (series_id) REFERENCES series (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_11BA68CA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO notes (id, speaker_id, series_id, title, text, date, passage, refs) SELECT id, speaker_id, series_id, title, text, date, passage, refs FROM __temp__notes'); + $this->addSql('DROP TABLE __temp__notes'); + $this->addSql('CREATE INDEX IDX_11BA68CD04A0F27 ON notes (speaker_id)'); + $this->addSql('CREATE INDEX IDX_11BA68C5278319C ON notes (series_id)'); + $this->addSql('CREATE INDEX IDX_11BA68CA76ED395 ON notes (user_id)'); + $this->addSql('CREATE TEMPORARY TABLE __temp__reference AS SELECT id, type, name, label, ndx, content FROM reference'); + $this->addSql('DROP TABLE reference'); + $this->addSql('CREATE TABLE reference (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, type VARCHAR(64) NOT NULL, name VARCHAR(255) NOT NULL, label VARCHAR(10) NOT NULL, ndx INTEGER DEFAULT NULL, content CLOB NOT NULL)'); + $this->addSql('INSERT INTO reference (id, type, name, label, ndx, content) SELECT id, type, name, label, ndx, content FROM __temp__reference'); + $this->addSql('DROP TABLE __temp__reference'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_AEA34913EA750E8 ON reference (label)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TEMPORARY TABLE __temp__notes AS SELECT id, speaker_id, series_id, title, text, date, passage, refs FROM notes'); + $this->addSql('DROP TABLE notes'); + $this->addSql('CREATE TABLE notes (id VARCHAR(64) NOT NULL, speaker_id INTEGER NOT NULL, series_id INTEGER DEFAULT NULL, title VARCHAR(255) NOT NULL, text CLOB NOT NULL, date DATE NOT NULL, passage VARCHAR(255) DEFAULT NULL, refs CLOB DEFAULT NULL --(DC2Type:json) + , PRIMARY KEY(id), CONSTRAINT FK_11BA68CD04A0F27 FOREIGN KEY (speaker_id) REFERENCES speaker (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_11BA68C5278319C FOREIGN KEY (series_id) REFERENCES series (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('INSERT INTO notes (id, speaker_id, series_id, title, text, date, passage, refs) SELECT id, speaker_id, series_id, title, text, date, passage, refs FROM __temp__notes'); + $this->addSql('DROP TABLE __temp__notes'); + $this->addSql('CREATE INDEX IDX_11BA68CD04A0F27 ON notes (speaker_id)'); + $this->addSql('CREATE INDEX IDX_11BA68C5278319C ON notes (series_id)'); + $this->addSql('ALTER TABLE reference ADD COLUMN id_list CLOB DEFAULT NULL'); + } +}