From 8c3158eba8654509a8c5e0323d4f37b01488b011 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 10 May 2017 10:46:32 +0200 Subject: [PATCH] Added migration to change length for user fields --- .../Version20170510082609.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 app/DoctrineMigrations/Version20170510082609.php diff --git a/app/DoctrineMigrations/Version20170510082609.php b/app/DoctrineMigrations/Version20170510082609.php new file mode 100644 index 00000000..a99af2d2 --- /dev/null +++ b/app/DoctrineMigrations/Version20170510082609.php @@ -0,0 +1,60 @@ +container = $container; + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix').$tableName; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); + + foreach ($this->fields as $field) { + $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE '.$field.' '.$field.' VARCHAR(180) NOT NULL;'); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); + + foreach ($this->fields as $field) { + $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE '.$field.' '.$field.' VARCHAR(255) NOT NULL;'); + } + } +} -- 2.41.0