36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260429073108 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Workflow entrée/sortie : ajout entry_completed sur reception et reception_id sur bovine.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// Reception : flag de fermeture d'une entrée bovins.
|
|
$this->addSql('ALTER TABLE reception ADD entry_completed BOOLEAN NOT NULL DEFAULT FALSE');
|
|
|
|
// Bovine : FK nullable vers la réception qui a fait entrer le bovin.
|
|
$this->addSql('ALTER TABLE bovine ADD reception_id INT DEFAULT NULL');
|
|
$this->addSql('CREATE INDEX IDX_BOVINE_RECEPTION ON bovine (reception_id)');
|
|
$this->addSql('ALTER TABLE bovine ADD CONSTRAINT FK_BOVINE_RECEPTION FOREIGN KEY (reception_id) REFERENCES reception (id) ON DELETE SET NULL');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE bovine DROP CONSTRAINT FK_BOVINE_RECEPTION');
|
|
$this->addSql('DROP INDEX IDX_BOVINE_RECEPTION');
|
|
$this->addSql('ALTER TABLE bovine DROP reception_id');
|
|
$this->addSql('ALTER TABLE reception DROP entry_completed');
|
|
}
|
|
}
|