<?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 Version20230815122404 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 TABLE lnk_tbl_mouvement_parcelle (mouvement_id INT NOT NULL, parcelle_id INT NOT NULL, INDEX IDX_7C806F9ECD1C222 (mouvement_id), INDEX IDX_7C806F94433ED66 (parcelle_id), PRIMARY KEY(mouvement_id, parcelle_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE lnk_tbl_mouvement_parcelle ADD CONSTRAINT FK_7C806F9ECD1C222 FOREIGN KEY (mouvement_id) REFERENCES tbl_mouvement (id)');
$this->addSql('ALTER TABLE lnk_tbl_mouvement_parcelle ADD CONSTRAINT FK_7C806F94433ED66 FOREIGN KEY (parcelle_id) REFERENCES tbl_parcelle (id)');
$this->addSql("INSERT INTO lnk_tbl_mouvement_parcelle (mouvement_id , parcelle_id)
SELECT id ,parcelle_id FROM tbl_mouvement WHERE parcelle_id IS NOT NULL");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE lnk_tbl_mouvement_parcelle DROP FOREIGN KEY FK_7C806F9ECD1C222');
$this->addSql('ALTER TABLE lnk_tbl_mouvement_parcelle DROP FOREIGN KEY FK_7C806F94433ED66');
$this->addSql('DROP TABLE lnk_tbl_mouvement_parcelle');
}
}