migrations/Version20230517133907.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20230517133907 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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');
  19.         $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');
  20.         $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');
  21.         $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');
  22.         $this->addSql('ALTER TABLE prestation ADD CONSTRAINT FK_51C88FAD611C0C56 FOREIGN KEY (dossier_id) REFERENCES dossier (id)');
  23.         $this->addSql('ALTER TABLE prestation_prestation_catg ADD CONSTRAINT FK_8520A0989E45C554 FOREIGN KEY (prestation_id) REFERENCES prestation (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE prestation_prestation_catg ADD CONSTRAINT FK_8520A09814AF33F7 FOREIGN KEY (prestation_catg_id) REFERENCES prestation_catg (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE prestation_catg ADD CONSTRAINT FK_85F34853670C757F FOREIGN KEY (fournisseur_id) REFERENCES fournisseur (id)');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE prestation DROP FOREIGN KEY FK_51C88FAD611C0C56');
  31.         $this->addSql('ALTER TABLE prestation_prestation_catg DROP FOREIGN KEY FK_8520A0989E45C554');
  32.         $this->addSql('ALTER TABLE prestation_prestation_catg DROP FOREIGN KEY FK_8520A09814AF33F7');
  33.         $this->addSql('ALTER TABLE prestation_catg DROP FOREIGN KEY FK_85F34853670C757F');
  34.         $this->addSql('DROP TABLE fournisseur');
  35.         $this->addSql('DROP TABLE prestation');
  36.         $this->addSql('DROP TABLE prestation_prestation_catg');
  37.         $this->addSql('DROP TABLE prestation_catg');
  38.     }
  39. }