<?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 Version20251126165512 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create target and target_course tables';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE target (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, color VARCHAR(255) DEFAULT NULL, created DATETIME NOT NULL, modified DATETIME DEFAULT NULL, INDEX IDX_4676F74119EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE target_course (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, target_id INT NOT NULL, course_id INT NOT NULL, INDEX IDX_8A5F3C4B19EB6921 (client_id), INDEX IDX_8A5F3C4B158E0B66 (target_id), INDEX IDX_8A5F3C4B591CC992 (course_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE target ADD CONSTRAINT FK_4676F74119EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE target_course ADD CONSTRAINT FK_8A5F3C4B19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE target_course ADD CONSTRAINT FK_8A5F3C4B158E0B66 FOREIGN KEY (target_id) REFERENCES target (id)');
$this->addSql('ALTER TABLE target_course ADD CONSTRAINT FK_8A5F3C4B591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE target_course DROP FOREIGN KEY FK_8A5F3C4B158E0B66');
$this->addSql('ALTER TABLE target_course DROP FOREIGN KEY FK_8A5F3C4B591CC992');
$this->addSql('ALTER TABLE target DROP FOREIGN KEY FK_4676F74119EB6921');
$this->addSql('ALTER TABLE target_course DROP FOREIGN KEY FK_8A5F3C4B19EB6921');
$this->addSql('DROP TABLE target');
$this->addSql('DROP TABLE target_course');
}
}