<?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 Version20230517133907 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 fournisseur (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE prestation (id INT AUTO_INCREMENT NOT NULL, dossier_id INT DEFAULT NULL, created_at DATE NOT NULL, cout_piece VARCHAR(255) DEFAULT NULL, INDEX IDX_51C88FAD611C0C56 (dossier_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE prestation_prestation_catg (prestation_id INT NOT NULL, prestation_catg_id INT NOT NULL, INDEX IDX_8520A0989E45C554 (prestation_id), INDEX IDX_8520A09814AF33F7 (prestation_catg_id), PRIMARY KEY(prestation_id, prestation_catg_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE prestation_catg (id INT AUTO_INCREMENT NOT NULL, fournisseur_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, reference VARCHAR(255) DEFAULT NULL, INDEX IDX_85F34853670C757F (fournisseur_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE prestation ADD CONSTRAINT FK_51C88FAD611C0C56 FOREIGN KEY (dossier_id) REFERENCES dossier (id)');
$this->addSql('ALTER TABLE prestation_prestation_catg ADD CONSTRAINT FK_8520A0989E45C554 FOREIGN KEY (prestation_id) REFERENCES prestation (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE prestation_prestation_catg ADD CONSTRAINT FK_8520A09814AF33F7 FOREIGN KEY (prestation_catg_id) REFERENCES prestation_catg (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE prestation_catg ADD CONSTRAINT FK_85F34853670C757F FOREIGN KEY (fournisseur_id) REFERENCES fournisseur (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE prestation DROP FOREIGN KEY FK_51C88FAD611C0C56');
$this->addSql('ALTER TABLE prestation_prestation_catg DROP FOREIGN KEY FK_8520A0989E45C554');
$this->addSql('ALTER TABLE prestation_prestation_catg DROP FOREIGN KEY FK_8520A09814AF33F7');
$this->addSql('ALTER TABLE prestation_catg DROP FOREIGN KEY FK_85F34853670C757F');
$this->addSql('DROP TABLE fournisseur');
$this->addSql('DROP TABLE prestation');
$this->addSql('DROP TABLE prestation_prestation_catg');
$this->addSql('DROP TABLE prestation_catg');
}
}