zend-blog-3-backend
38 строк · 1.7 Кб
1<?php
2
3declare(strict_types=1);4
5namespace Application\Migrations;6
7use Doctrine\DBAL\Schema\Schema;8use Doctrine\Migrations\AbstractMigration;9
10/**
11* Auto-generated Migration: Please modify to your needs!
12*/
13final class Version20230603111902 extends AbstractMigration14{
15public function up(Schema $schema): void16{17// this up() migration is auto-generated, please modify it to your needs18$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');19
20$this->addSql('ALTER TABLE commentators ADD force_image TINYINT(1) DEFAULT NULL');21$this->addSql('UPDATE commentators SET force_image = 0');22$this->addSql('ALTER TABLE commentators CHANGE force_image force_image TINYINT(1) DEFAULT 0 NOT NULL');23$this->addSql('DROP INDEX UNIQ_6AB0FB33E46417AB ON commentators');24$this->addSql('ALTER TABLE commentators DROP disqus_id, DROP email_hash');25$this->addSql('ALTER TABLE users DROP email_hash');26}27
28public function down(Schema $schema): void29{30// this down() migration is auto-generated, please modify it to your needs31$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');32
33$this->addSql('ALTER TABLE users ADD email_hash VARCHAR(32) DEFAULT NULL');34$this->addSql('ALTER TABLE commentators ADD disqus_id BIGINT DEFAULT NULL, ADD email_hash VARCHAR(32) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');35$this->addSql('CREATE UNIQUE INDEX UNIQ_6AB0FB33E46417AB ON commentators (disqus_id)');36$this->addSql('ALTER TABLE commentators DROP force_image');37}38}
39