<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240312130000 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
# repeating part of migration `Version20240304190000`
# making all `user_id` columns of the same type
$this->addSql('ALTER TABLE user_points_history DROP FOREIGN KEY FK_CED765BAA76ED395');
$this->addSql('ALTER TABLE user_vouchers DROP FOREIGN KEY FK_7398E348A76ED395');
# update users.id and user_id columns as INT UNSIGNED NOT NULL
$this->addSql('ALTER TABLE users CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL');
$this->addSql('ALTER TABLE feedbacks CHANGE user_id user_id INT UNSIGNED NOT NULL');
$this->addSql('ALTER TABLE user_points_history CHANGE user_id user_id INT UNSIGNED NOT NULL');
$this->addSql('ALTER TABLE user_vouchers CHANGE user_id user_id INT UNSIGNED NOT NULL');
$this->addSql('ALTER TABLE user_verification_tokens CHANGE user_id user_id INT UNSIGNED NOT NULL');
# re-add fk
$this->addSql('ALTER TABLE user_points_history ADD CONSTRAINT FK_CED765BAA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_vouchers ADD CONSTRAINT FK_7398E348A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
# repeating part of migration `Version20240304190000`
# making all `user_id` columns of the same type
$this->addSql('ALTER TABLE user_points_history DROP FOREIGN KEY FK_CED765BAA76ED395');
$this->addSql('ALTER TABLE user_vouchers DROP FOREIGN KEY FK_7398E348A76ED395');
# update users.id and user_id columns as INT UNSIGNED NOT NULL
$this->addSql('ALTER TABLE users CHANGE id id INT AUTO_INCREMENT NOT NULL');
$this->addSql('ALTER TABLE feedbacks CHANGE user_id user_id INT NOT NULL');
$this->addSql('ALTER TABLE user_points_history CHANGE user_id user_id INT NOT NULL');
$this->addSql('ALTER TABLE user_vouchers CHANGE user_id user_id INT NOT NULL');
$this->addSql('ALTER TABLE user_verification_tokens CHANGE user_id user_id INT NOT NULL');
# re-add fk
$this->addSql('ALTER TABLE user_points_history ADD CONSTRAINT FK_CED765BAA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_vouchers ADD CONSTRAINT FK_7398E348A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
}
}