[AttributeValue] Add migration file

This commit is contained in:
Grzegorz Sadowski 2017-01-16 08:12:41 +01:00
parent 5d29860b3d
commit fa48b590a1

View file

@ -0,0 +1,50 @@
<?php
namespace Sylius\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com>
*/
class Version20170109143010 extends AbstractMigration implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$defaultLocale = $this->container->getParameter('locale');
$this->addSql('ALTER TABLE sylius_product_attribute_value ADD locale_code VARCHAR(255) NOT NULL');
$this->addSql('UPDATE sylius_product_attribute_value SET locale_code = "'.$defaultLocale.'"');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE sylius_product_attribute_value DROP locale_code');
}
}