migrations/Version20231213161951.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 Version20231213161951 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 `point_transfer_type`(
  19.             id INT AUTO_INCREMENT NOT NULL,
  20.             name VARCHAR(255) NOT NULL,
  21.             PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
  22.         );
  23.         $this->addSql('ALTER TABLE point_transfer ADD type_id INT DEFAULT NULL');
  24.         $this->addSql('ALTER TABLE point_transfer ADD CONSTRAINT FK_D251F9A2C54C8C93 FOREIGN KEY (type_id) REFERENCES `point_transfer_type` (id) ON DELETE CASCADE');
  25.         $this->addSql('CREATE INDEX IDX_D251F9A2C54C8C93 ON point_transfer (type_id)');
  26.         //INSERT TYPE DEFAULT
  27.         $this->addSql('INSERT INTO `point_transfer_type` (id, name) VALUES (1, "Don")');
  28.         $this->addSql('INSERT INTO `point_transfer_type` (id, name) VALUES (2, "Rétrocession")');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('ALTER TABLE `point_transfer` DROP FOREIGN KEY FK_D251F9A2C54C8C93');
  34.         $this->addSql('DROP TABLE `point_transfer_type`');
  35.         $this->addSql('DROP INDEX IDX_D251F9A2C54C8C93 ON `point_transfer`');
  36.         $this->addSql('ALTER TABLE `point_transfer` DROP type_id');
  37.     }
  38. }