Files
e-ticket/migrations/Version20260321190000.php

34 lines
1.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260321190000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create billet_order table for individual tickets';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE billet_order (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, billet_buyer_id INT NOT NULL, billet_id INT NOT NULL, reference VARCHAR(23) NOT NULL, billet_name VARCHAR(255) NOT NULL, unit_price_ht INT NOT NULL, is_scanned BOOLEAN NOT NULL, scanned_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_BILLET_ORDER_REF ON billet_order (reference)');
$this->addSql('CREATE INDEX IDX_BO_BUYER ON billet_order (billet_buyer_id)');
$this->addSql('CREATE INDEX IDX_BO_BILLET ON billet_order (billet_id)');
$this->addSql('ALTER TABLE billet_order ADD CONSTRAINT FK_BO_BUYER FOREIGN KEY (billet_buyer_id) REFERENCES billet_buyer (id) ON DELETE CASCADE NOT DEFERRABLE');
$this->addSql('ALTER TABLE billet_order ADD CONSTRAINT FK_BO_BILLET FOREIGN KEY (billet_id) REFERENCES billet (id) NOT DEFERRABLE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE billet_order DROP CONSTRAINT FK_BO_BUYER');
$this->addSql('ALTER TABLE billet_order DROP CONSTRAINT FK_BO_BILLET');
$this->addSql('DROP TABLE billet_order');
}
}