migrations/Version20230311114529.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20230311114529 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Fix table schemas';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('ALTER TABLE campaign CHANGE hide_audio hide_audio TINYINT(1) DEFAULT 0 NOT NULL');
  15.         $this->addSql('DROP INDEX code ON country_phone_code');
  16.         $this->addSql('ALTER TABLE creator CHANGE last_notifications last_notifications JSON DEFAULT (JSON_ARRAY()) NOT NULL, CHANGE birthday birthday DATE NOT NULL, CHANGE vip vip TINYINT(1) NOT NULL, CHANGE dark_theme dark_theme TINYINT(1) NOT NULL, CHANGE updates updates JSON DEFAULT (JSON_OBJECT()) NOT NULL');
  17.         $this->addSql('ALTER TABLE notification RENAME INDEX uniq_88ebe88ea76ed395 TO UNIQ_BF5476CAA76ED395');
  18.         $this->addSql('ALTER TABLE payment_method DROP FOREIGN KEY FK_7B61A1F6A76ED395');
  19.         $this->addSql('ALTER TABLE payment_method ADD CONSTRAINT FK_7B61A1F6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
  20.         $this->addSql('ALTER TABLE settings CHANGE max_video_check_retries max_video_check_retries SMALLINT NOT NULL');
  21.         $this->addSql('ALTER TABLE tik_tok_auth CHANGE refreshed_at refreshed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL');
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         $this->addSql('ALTER TABLE campaign CHANGE hide_audio hide_audio TINYINT(1) DEFAULT 1 NOT NULL');
  26.         $this->addSql('CREATE INDEX code ON country_phone_code (code)');
  27.         $this->addSql('ALTER TABLE creator CHANGE birthday birthday DATE DEFAULT NULL, CHANGE vip vip TINYINT(1) DEFAULT 0 NOT NULL, CHANGE dark_theme dark_theme TINYINT(1) DEFAULT 0 NOT NULL, CHANGE last_notifications last_notifications JSON DEFAULT \'json_array()\' NOT NULL, CHANGE updates updates JSON DEFAULT \'json_object()\' NOT NULL');
  28.         $this->addSql('ALTER TABLE notification RENAME INDEX uniq_bf5476caa76ed395 TO UNIQ_88EBE88EA76ED395');
  29.         $this->addSql('ALTER TABLE payment_method DROP FOREIGN KEY FK_7B61A1F6A76ED395');
  30.         $this->addSql('ALTER TABLE payment_method ADD CONSTRAINT FK_7B61A1F6A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
  31.         $this->addSql('ALTER TABLE settings CHANGE max_video_check_retries max_video_check_retries SMALLINT DEFAULT 3 NOT NULL');
  32.         $this->addSql('ALTER TABLE tik_tok_auth CHANGE refreshed_at refreshed_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL');
  33.     }
  34.     public function isTransactional(): bool
  35.     {
  36.         return false;
  37.     }
  38. }