Fix migration

This commit is contained in:
Jeremy Benoist 2016-11-17 08:05:15 +01:00
parent e6b133c60c
commit 9e2440fe15
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
2 changed files with 14 additions and 8 deletions

View file

@ -4,8 +4,10 @@ namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Version20161106113822 extends AbstractMigration class Version20161106113822 extends AbstractMigration implements ContainerAwareInterface
{ {
/** /**
* @var ContainerInterface * @var ContainerInterface
@ -27,7 +29,7 @@ class Version20161106113822 extends AbstractMigration
*/ */
public function up(Schema $schema) public function up(Schema $schema)
{ {
$this->addSql('ALTER TABLE "'.$this->getTable('config').'" ADD action_mark_as_read INT DEFAULT 0'); $this->addSql('ALTER TABLE '.$this->getTable('config').' ADD action_mark_as_read INT DEFAULT 0');
} }
/** /**
@ -37,6 +39,6 @@ class Version20161106113822 extends AbstractMigration
{ {
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
$this->addSql('ALTER TABLE "'.$this->getTable('config').'" DROP action_mark_as_read'); $this->addSql('ALTER TABLE '.$this->getTable('config').' DROP action_mark_as_read');
} }
} }

View file

@ -7,34 +7,38 @@ use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
class Version20161031132655 extends AbstractMigration implements ContainerAwareInterface class Version20161117071626 extends AbstractMigration implements ContainerAwareInterface
{ {
/** /**
* @var ContainerInterface * @var ContainerInterface
*/ */
private $container; private $container;
public function setContainer(ContainerInterface $container = null) public function setContainer(ContainerInterface $container = null)
{ {
$this->container = $container; $this->container = $container;
} }
private function getTable($tableName) private function getTable($tableName)
{ {
return $this->container->getParameter('database_table_prefix') . $tableName; return $this->container->getParameter('database_table_prefix') . $tableName;
} }
/** /**
* @param Schema $schema * @param Schema $schema
*/ */
public function up(Schema $schema) public function up(Schema $schema)
{ {
$this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('share_unmark', 0, 'entry')"); $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
$this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')"); $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
} }
/** /**
* @param Schema $schema * @param Schema $schema
*/ */
public function down(Schema $schema) public function down(Schema $schema)
{ {
$this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'share_unmark';"); $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';");
$this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'unmark_url';"); $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';");
} }
} }