feat : first commit
This commit is contained in:
0
migrations/.gitignore
vendored
Normal file
0
migrations/.gitignore
vendored
Normal file
27
migrations/Version20260202195900.php
Normal file
27
migrations/Version20260202195900.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260202195900 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create users table for authentication';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE users (id SERIAL NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE UNIQUE INDEX uniq_users_username ON users (username)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE users');
|
||||
}
|
||||
}
|
||||
26
migrations/Version20260202213000.php
Normal file
26
migrations/Version20260202213000.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260202213000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create employees table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE employees (id SERIAL NOT NULL, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE employees');
|
||||
}
|
||||
}
|
||||
26
migrations/Version20260202220500.php
Normal file
26
migrations/Version20260202220500.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260202220500 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create absence types table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE absence_types (id SERIAL NOT NULL, code VARCHAR(10) NOT NULL, label VARCHAR(100) NOT NULL, color VARCHAR(20) NOT NULL, PRIMARY KEY(id))');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE absence_types');
|
||||
}
|
||||
}
|
||||
32
migrations/Version20260202224500.php
Normal file
32
migrations/Version20260202224500.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
34
migrations/Version20260203120000.php
Normal file
34
migrations/Version20260203120000.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260203120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add start and end dates to absences';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE absences ADD start_date DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE absences ADD end_date DATE DEFAULT NULL');
|
||||
$this->addSql('UPDATE absences SET start_date = date, end_date = date');
|
||||
$this->addSql('ALTER TABLE absences ALTER COLUMN start_date SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE absences ALTER COLUMN end_date SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE absences DROP COLUMN date');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE absences ADD date DATE NOT NULL');
|
||||
$this->addSql('UPDATE absences SET date = start_date');
|
||||
$this->addSql('ALTER TABLE absences DROP COLUMN start_date');
|
||||
$this->addSql('ALTER TABLE absences DROP COLUMN end_date');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user