From 2cd54d9c4dd4a04c63da27c0a0a3a7fe1bfd7dec Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 25 May 2018 15:18:56 +0200 Subject: [PATCH] Add a missing migration back Signed-off-by: Thomas Citharel --- .../Migrations/Version20180525110000.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 app/classes/Framadate/Migrations/Version20180525110000.php diff --git a/app/classes/Framadate/Migrations/Version20180525110000.php b/app/classes/Framadate/Migrations/Version20180525110000.php new file mode 100644 index 0000000..b2d1e46 --- /dev/null +++ b/app/classes/Framadate/Migrations/Version20180525110000.php @@ -0,0 +1,100 @@ +getTable(Utils::table('poll')); + $poll->addColumn('collect_users_mail_integer', 'smallint', ['default' => 0]); + } + + /** + * @param Schema $schema + */ + public function postUp(Schema $schema) + { + $this->addSql('UPDATE ' . Utils::table('poll') . ' SET collect_users_mail_integer = collect_users_mail'); + $this->addSql('ALTER TABLE ' . Utils::table('poll') . ' DROP COLUMN collect_users_mail'); + if ($this->connection->getDatabasePlatform()->getName() === 'mysql') { + $this->addSql( + 'ALTER TABLE ' . Utils::table('poll') . ' CHANGE collect_users_mail_integer collect_users_mail SMALLINT' + ); + } else { + $this->addSql( + 'ALTER TABLE ' . Utils::table('poll') . ' RENAME COLUMN collect_users_mail_integer to collect_users_mail' + ); + } + } + + /** + * @param Schema $schema + * @throws \Doctrine\DBAL\Schema\SchemaException + */ + public function down(Schema $schema) + { + $poll = $schema->getTable(Utils::table('poll')); + $poll->addColumn('collect_users_mail_boolean', 'boolean', ['default' => false]); + } + + /** + * @param Schema $schema + */ + public function postDown(Schema $schema) + { + $this->addSql('UPDATE ' . Utils::table('poll') . ' SET collect_users_mail_boolean = collect_users_mail > 0'); + $this->addSql('ALTER TABLE ' . Utils::table('poll') . ' DROP COLUMN collect_users_mail'); + + if ($this->connection->getDatabasePlatform()->getName() === 'mysql') { + $this->addSql( + 'ALTER TABLE ' . Utils::table('poll') . ' CHANGE collect_users_mail_boolean collect_users_mail SMALLINT' + ); + } else { + $this->addSql( + 'ALTER TABLE ' . Utils::table('poll') . ' RENAME COLUMN collect_users_mail_boolean to collect_users_mail' + ); + } + } +}