church-notes/migrations/Version20240418015109.php

44 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240418015109 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() 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 FROM notes');
$this->addSql('DROP TABLE notes');
$this->addSql('CREATE TABLE notes (id INTEGER 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, 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)');
$this->addSql('INSERT INTO notes (id, speaker_id, series_id, title, text) SELECT id, speaker_id, series_id, title, text FROM __temp__notes');
$this->addSql('DROP TABLE __temp__notes');
$this->addSql('CREATE INDEX IDX_11BA68C5278319C ON notes (series_id)');
$this->addSql('CREATE INDEX IDX_11BA68CD04A0F27 ON notes (speaker_id)');
}
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 FROM notes');
$this->addSql('DROP TABLE notes');
$this->addSql('CREATE TABLE notes (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, speaker_id INTEGER NOT NULL, series_id INTEGER DEFAULT NULL, title VARCHAR(255) NOT NULL, text CLOB NOT NULL, 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) SELECT id, speaker_id, series_id, title, text 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)');
}
}