migrations/Version20240312130000.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. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20240312130000 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         # repeating part of migration `Version20240304190000`
  18.         # making all `user_id` columns of the same type
  19.         $this->addSql('ALTER TABLE user_points_history DROP FOREIGN KEY FK_CED765BAA76ED395');
  20.         $this->addSql('ALTER TABLE user_vouchers DROP FOREIGN KEY FK_7398E348A76ED395');
  21.         # update users.id and user_id columns as INT UNSIGNED NOT NULL
  22.         $this->addSql('ALTER TABLE users CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL');
  23.         $this->addSql('ALTER TABLE feedbacks CHANGE user_id user_id INT UNSIGNED NOT NULL');
  24.         $this->addSql('ALTER TABLE user_points_history CHANGE user_id user_id INT UNSIGNED NOT NULL');
  25.         $this->addSql('ALTER TABLE user_vouchers CHANGE user_id user_id INT UNSIGNED NOT NULL');
  26.         $this->addSql('ALTER TABLE user_verification_tokens CHANGE user_id user_id INT UNSIGNED NOT NULL');
  27.         # re-add fk
  28.         $this->addSql('ALTER TABLE user_points_history ADD CONSTRAINT FK_CED765BAA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
  29.         $this->addSql('ALTER TABLE user_vouchers ADD CONSTRAINT FK_7398E348A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         # repeating part of migration `Version20240304190000`
  34.         # making all `user_id` columns of the same type
  35.         $this->addSql('ALTER TABLE user_points_history DROP FOREIGN KEY FK_CED765BAA76ED395');
  36.         $this->addSql('ALTER TABLE user_vouchers DROP FOREIGN KEY FK_7398E348A76ED395');
  37.         # update users.id and user_id columns as INT UNSIGNED NOT NULL
  38.         $this->addSql('ALTER TABLE users CHANGE id id INT AUTO_INCREMENT NOT NULL');
  39.         $this->addSql('ALTER TABLE feedbacks CHANGE user_id user_id INT NOT NULL');
  40.         $this->addSql('ALTER TABLE user_points_history CHANGE user_id user_id INT NOT NULL');
  41.         $this->addSql('ALTER TABLE user_vouchers CHANGE user_id user_id INT NOT NULL');
  42.         $this->addSql('ALTER TABLE user_verification_tokens CHANGE user_id user_id INT NOT NULL');
  43.         # re-add fk
  44.         $this->addSql('ALTER TABLE user_points_history ADD CONSTRAINT FK_CED765BAA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
  45.         $this->addSql('ALTER TABLE user_vouchers ADD CONSTRAINT FK_7398E348A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
  46.     }
  47. }