<?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 Version20220511173041 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 client_type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql("INSERT INTO client_type (name, description) VALUES ('PREM0', 'pas de remise'),('PREM20', '20% de remise sur un produit'),('PREM40', '40% de remise sur un produit'),('PREM60', '60% de remise sur un produit et possibilité de gerer des propositions')");
$this->addSql('ALTER TABLE user ADD client_type_id INT NOT NULL DEFAULT 1');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6499771C8EE FOREIGN KEY (client_type_id) REFERENCES client_type (id)');
$this->addSql('CREATE INDEX IDX_8D93D6499771C8EE ON user (client_type_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6499771C8EE');
$this->addSql('DROP TABLE client_type');
$this->addSql('DROP INDEX IDX_8D93D6499771C8EE ON user');
$this->addSql('ALTER TABLE user DROP client_type_id');
}
}