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' ); } } }