for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sylius\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* @author Grzegorz Sadowski <[email protected]>
*/
class Version20161221133514 extends AbstractMigration
{
* @param Schema $schema
public function up(Schema $schema)
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE sylius_product_option ADD position INT NOT NULL');
$this->addSql('SET @row_number = -1');
$this->addSql('UPDATE sylius_product_option SET position = @row_number := @row_number + 1');
}
public function down(Schema $schema)
$this->addSql('ALTER TABLE sylius_product_option DROP position');