From 6295fc757d0784c8ec676914d45c93270e48bdb8 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 15 Apr 2024 23:42:47 -0400 Subject: [PATCH] add migrations --- migrations/Version20240411223119.php | 48 ++++++++++++++++++++++++++++ migrations/Version20240416003537.php | 37 +++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 migrations/Version20240411223119.php create mode 100644 migrations/Version20240416003537.php diff --git a/migrations/Version20240411223119.php b/migrations/Version20240411223119.php new file mode 100644 index 0000000..23d7ba6 --- /dev/null +++ b/migrations/Version20240411223119.php @@ -0,0 +1,48 @@ +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, 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('CREATE INDEX IDX_11BA68CD04A0F27 ON notes (speaker_id)'); + $this->addSql('CREATE INDEX IDX_11BA68C5278319C ON notes (series_id)'); + $this->addSql('CREATE TABLE series (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, template_id INTEGER DEFAULT NULL, name VARCHAR(64) NOT NULL, CONSTRAINT FK_3A10012D5DA0FB8 FOREIGN KEY (template_id) REFERENCES template (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('CREATE INDEX IDX_3A10012D5DA0FB8 ON series (template_id)'); + $this->addSql('CREATE TABLE speaker (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL)'); + $this->addSql('CREATE TABLE template (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL, value VARCHAR(2049) NOT NULL)'); + $this->addSql('CREATE TABLE messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) + , available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) + , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) + )'); + $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)'); + $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)'); + $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE notes'); + $this->addSql('DROP TABLE series'); + $this->addSql('DROP TABLE speaker'); + $this->addSql('DROP TABLE template'); + $this->addSql('DROP TABLE messenger_messages'); + } +} diff --git a/migrations/Version20240416003537.php b/migrations/Version20240416003537.php new file mode 100644 index 0000000..09d2edf --- /dev/null +++ b/migrations/Version20240416003537.php @@ -0,0 +1,37 @@ +addSql('ALTER TABLE notes ADD COLUMN text CLOB'); + } + + 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 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, 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) SELECT id, speaker_id, series_id, title 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)'); + } +}