3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Migrations\AbstractMigration
;
6 use Doctrine\DBAL\Schema\Schema
;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface
;
8 use Symfony\Component\DependencyInjection\ContainerInterface
;
11 * Changed length for username, username_canonical, email and email_canonical fields in wallabag_user table.
13 class Version20170510082609
extends AbstractMigration
implements ContainerAwareInterface
23 * @var ContainerInterface
27 public function setContainer(ContainerInterface
$container = null)
29 $this->container
= $container;
33 * @param Schema $schema
35 public function up(Schema
$schema)
37 $this->skipIf($this->connection
->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
39 foreach ($this->fields
as $field) {
40 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
45 * @param Schema $schema
47 public function down(Schema
$schema)
49 $this->skipIf($this->connection
->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
51 foreach ($this->fields
as $field) {
52 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
56 private function getTable($tableName)
58 return $this->container
->getParameter('database_table_prefix') . $tableName;