33 lines
1.3 KiB
PHP
33 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260202224500 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Create absences table';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE absences (id SERIAL NOT NULL, employee_id INT NOT NULL, type_id INT NOT NULL, date DATE NOT NULL, comment TEXT DEFAULT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('CREATE INDEX IDX_ABSENCES_EMPLOYEE ON absences (employee_id)');
|
|
$this->addSql('CREATE INDEX IDX_ABSENCES_TYPE ON absences (type_id)');
|
|
$this->addSql('ALTER TABLE absences ADD CONSTRAINT FK_ABSENCES_EMPLOYEE FOREIGN KEY (employee_id) REFERENCES employees (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('ALTER TABLE absences ADD CONSTRAINT FK_ABSENCES_TYPE FOREIGN KEY (type_id) REFERENCES absence_types (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE absences DROP CONSTRAINT FK_ABSENCES_EMPLOYEE');
|
|
$this->addSql('ALTER TABLE absences DROP CONSTRAINT FK_ABSENCES_TYPE');
|
|
$this->addSql('DROP TABLE absences');
|
|
}
|
|
}
|