31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260225123000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create bovine table and relation to building_case.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE bovine (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, building_case_id INT DEFAULT NULL, national_number VARCHAR(50) NOT NULL, received_weight INT DEFAULT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('CREATE INDEX IDX_EA9E2A42F8D859DF ON bovine (building_case_id)');
|
|
$this->addSql('CREATE UNIQUE INDEX uniq_bovine_national_number ON bovine (national_number)');
|
|
$this->addSql('ALTER TABLE bovine ADD CONSTRAINT FK_EA9E2A42F8D859DF FOREIGN KEY (building_case_id) REFERENCES building_case (id) NOT DEFERRABLE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE bovine DROP CONSTRAINT FK_EA9E2A42F8D859DF');
|
|
$this->addSql('DROP TABLE bovine');
|
|
}
|
|
}
|