From: Nicolas LÅ“uillet Date: Wed, 10 May 2017 08:46:32 +0000 (+0200) Subject: Added migration to change length for user fields X-Git-Tag: 2.3.0~31^2~98^2 X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=8c3158eba8654509a8c5e0323d4f37b01488b011 Added migration to change length for user fields --- 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;'); + } + } +}