<?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 Version20231213161951 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 `point_transfer_type`(
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('ALTER TABLE point_transfer ADD type_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE point_transfer ADD CONSTRAINT FK_D251F9A2C54C8C93 FOREIGN KEY (type_id) REFERENCES `point_transfer_type` (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_D251F9A2C54C8C93 ON point_transfer (type_id)');
//INSERT TYPE DEFAULT
$this->addSql('INSERT INTO `point_transfer_type` (id, name) VALUES (1, "Don")');
$this->addSql('INSERT INTO `point_transfer_type` (id, name) VALUES (2, "Rétrocession")');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `point_transfer` DROP FOREIGN KEY FK_D251F9A2C54C8C93');
$this->addSql('DROP TABLE `point_transfer_type`');
$this->addSql('DROP INDEX IDX_D251F9A2C54C8C93 ON `point_transfer`');
$this->addSql('ALTER TABLE `point_transfer` DROP type_id');
}
}