diff --git a/migrations/Version20240930131003.php b/migrations/Version20240930131003.php new file mode 100644 index 0000000..68b2308 --- /dev/null +++ b/migrations/Version20240930131003.php @@ -0,0 +1,45 @@ +addSql('CREATE TABLE command_task_client (command_task_id INT NOT NULL, client_id INT NOT NULL, INDEX IDX_F97A827D62DC5265 (command_task_id), INDEX IDX_F97A827D19EB6921 (client_id), PRIMARY KEY(command_task_id, client_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE command_task_client ADD CONSTRAINT FK_F97A827D62DC5265 FOREIGN KEY (command_task_id) REFERENCES command_task (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE command_task_client ADD CONSTRAINT FK_F97A827D19EB6921 FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3'); + $this->addSql('DROP INDEX IDX_C7440455F7E54CF3 ON client'); + $this->addSql('ALTER TABLE client ADD og_live_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)'); + $this->addSql('CREATE INDEX IDX_C7440455F7E54CF3 ON client (og_live_id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE command_task_client DROP FOREIGN KEY FK_F97A827D62DC5265'); + $this->addSql('ALTER TABLE command_task_client DROP FOREIGN KEY FK_F97A827D19EB6921'); + $this->addSql('DROP TABLE command_task_client'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3'); + $this->addSql('DROP INDEX IDX_C7440455F7E54CF3 ON client'); + $this->addSql('ALTER TABLE client DROP og_live_id'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (subnet_id) REFERENCES og_live (id)'); + $this->addSql('CREATE INDEX IDX_C7440455F7E54CF3 ON client (subnet_id)'); + } +}