<?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 Version20210805143105 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("
ALTER TABLE `std_attributes_values`
ADD COLUMN `attribute_id` INT(10) UNSIGNED NOT NULL COMMENT 'Attribute unique identifier' AFTER `attribute_machine_name`;
");
$this->addSql("
UPDATE std_attributes_values av SET av.attribute_id=(SELECT id FROM std_attributes WHERE machine_name =av.attribute_machine_name);
");
$this->addSql("
ALTER TABLE `std_attributes_values`
ADD CONSTRAINT `FK_std_attributes_values_std_attributes` FOREIGN KEY (`attribute_id`) REFERENCES `std_attributes` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION;
");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("
ALTER TABLE `std_attributes_values`
DROP FOREIGN KEY `FK_std_attributes_values_std_attributes`;
");
$this->addSql("
ALTER TABLE `std_attributes_values`
DROP INDEX `FK_std_attributes_values_std_attributes`;
");
$this->addSql("
ALTER TABLE `std_attributes_values`
DROP COLUMN `attribute_id`;
");
}
}