migrations/Version20230602091757.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230602091757 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add likes for wiki post';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE wiki_post_like (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, post_id INT DEFAULT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_6E063E9CA76ED395 (user_id), INDEX IDX_6E063E9C4B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE wiki_post_like ADD CONSTRAINT FK_6E063E9CA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE wiki_post_like ADD CONSTRAINT FK_6E063E9C4B89032C FOREIGN KEY (post_id) REFERENCES wiki_post (id)');
$this->addSql('ALTER TABLE wiki_post CHANGE created_at created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE wiki_post_like DROP FOREIGN KEY FK_6E063E9CA76ED395');
$this->addSql('ALTER TABLE wiki_post_like DROP FOREIGN KEY FK_6E063E9C4B89032C');
$this->addSql('DROP TABLE wiki_post_like');
$this->addSql('ALTER TABLE wiki_post CHANGE created_at created_at DATETIME NOT NULL');
}
}