<?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 Version20211207185248 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add new fields in auction_bid, create unique index to prevent duplicated bids';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE auction_bid ADD object_id INT NOT NULL, CHANGE product_id auction_id INT NOT NULL');
$this->addSql('CREATE UNIQUE INDEX bid_object_user_value_unique ON auction_bid (auction_id, object_id, value)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX bid_object_user_value_unique ON auction_bid');
$this->addSql('ALTER TABLE auction_bid ADD product_id INT NOT NULL, DROP auction_id, DROP object_id');
}
}