feat : finalisation de l'étape 1 "Réception" (formulaire)

This commit is contained in:
2026-01-27 16:59:36 +01:00
parent 9ae073e69e
commit f901d52324
46 changed files with 1977 additions and 88 deletions

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000100 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add reception types and link receptions to them';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE reception_type (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(120) NOT NULL, code VARCHAR(50) NOT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE reception ADD reception_type_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E37BD5B5D FOREIGN KEY (reception_type_id) REFERENCES reception_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_83DC02E37BD5B5D ON reception (reception_type_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E37BD5B5D');
$this->addSql('DROP INDEX IDX_83DC02E37BD5B5D');
$this->addSql('ALTER TABLE reception DROP reception_type_id');
$this->addSql('DROP TABLE reception_type');
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000200 extends AbstractMigration
{
public function getDescription(): string
{
return 'Link receptions to a responsible user';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE reception ADD user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3A76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_83DC02E3A76ED395 ON reception (user_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3A76ED395');
$this->addSql('DROP INDEX IDX_83DC02E3A76ED395');
$this->addSql('ALTER TABLE reception DROP user_id');
}
}

View File

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000300 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add suppliers and addresses, link receptions to suppliers';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE address (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(120) NOT NULL, street VARCHAR(180) NOT NULL, postal_code VARCHAR(20) NOT NULL, city VARCHAR(120) NOT NULL, country_code VARCHAR(2) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE supplier (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(180) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE supplier_address (supplier_id INT NOT NULL, address_id INT NOT NULL, PRIMARY KEY(supplier_id, address_id))');
$this->addSql('CREATE INDEX IDX_3DCE3C74F2C1D6A8 ON supplier_address (supplier_id)');
$this->addSql('CREATE INDEX IDX_3DCE3C746F9B8A0 ON supplier_address (address_id)');
$this->addSql('ALTER TABLE supplier_address ADD CONSTRAINT FK_3DCE3C74F2C1D6A8 FOREIGN KEY (supplier_id) REFERENCES supplier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE supplier_address ADD CONSTRAINT FK_3DCE3C746F9B8A0 FOREIGN KEY (address_id) REFERENCES address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE reception ADD supplier_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E32ADD6E01 FOREIGN KEY (supplier_id) REFERENCES supplier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_83DC02E32ADD6E01 ON reception (supplier_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E32ADD6E01');
$this->addSql('DROP INDEX IDX_83DC02E32ADD6E01');
$this->addSql('ALTER TABLE reception DROP supplier_id');
$this->addSql('ALTER TABLE supplier_address DROP CONSTRAINT FK_3DCE3C74F2C1D6A8');
$this->addSql('ALTER TABLE supplier_address DROP CONSTRAINT FK_3DCE3C746F9B8A0');
$this->addSql('DROP TABLE supplier_address');
$this->addSql('DROP TABLE supplier');
$this->addSql('DROP TABLE address');
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000400 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add address_id on reception';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE reception ADD address_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3F5B7AF75 FOREIGN KEY (address_id) REFERENCES address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_83DC02E3F5B7AF75 ON reception (address_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3F5B7AF75');
$this->addSql('DROP INDEX IDX_83DC02E3F5B7AF75');
$this->addSql('ALTER TABLE reception DROP address_id');
}
}

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000500 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add trucks and link receptions to trucks';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE truck (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(180) NOT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE reception ADD truck_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3F7D15B1A FOREIGN KEY (truck_id) REFERENCES truck (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_83DC02E3F7D15B1A ON reception (truck_id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3F7D15B1A');
$this->addSql('DROP INDEX IDX_83DC02E3F7D15B1A');
$this->addSql('ALTER TABLE reception DROP truck_id');
$this->addSql('DROP TABLE truck');
}
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000600 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add carriers, drivers, vehicles and link receptions to carriers/drivers';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE carrier (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(180) NOT NULL, code VARCHAR(30) DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE driver (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, carrier_id INT NOT NULL, name VARCHAR(180) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_14B3BC5F4C3C5E0A ON driver (carrier_id)');
$this->addSql('ALTER TABLE driver ADD CONSTRAINT FK_14B3BC5F4C3C5E0A FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE TABLE vehicle (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, carrier_id INT NOT NULL, truck_id INT NOT NULL, plate VARCHAR(20) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_1B80E4864C3C5E0A ON vehicle (carrier_id)');
$this->addSql('CREATE INDEX IDX_1B80E4868BEBB4B ON vehicle (truck_id)');
$this->addSql('ALTER TABLE vehicle ADD CONSTRAINT FK_1B80E4864C3C5E0A FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE vehicle ADD CONSTRAINT FK_1B80E4868BEBB4B FOREIGN KEY (truck_id) REFERENCES truck (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE reception ADD carrier_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE reception ADD driver_id INT DEFAULT NULL');
$this->addSql('CREATE INDEX IDX_83DC02E34C3C5E0A ON reception (carrier_id)');
$this->addSql('CREATE INDEX IDX_83DC02E3F24C741B ON reception (driver_id)');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E34C3C5E0A FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3F24C741B FOREIGN KEY (driver_id) REFERENCES driver (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E34C3C5E0A');
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3F24C741B');
$this->addSql('DROP INDEX IDX_83DC02E34C3C5E0A');
$this->addSql('DROP INDEX IDX_83DC02E3F24C741B');
$this->addSql('ALTER TABLE reception DROP carrier_id');
$this->addSql('ALTER TABLE reception DROP driver_id');
$this->addSql('ALTER TABLE vehicle DROP CONSTRAINT FK_1B80E4864C3C5E0A');
$this->addSql('ALTER TABLE vehicle DROP CONSTRAINT FK_1B80E4868BEBB4B');
$this->addSql('DROP TABLE vehicle');
$this->addSql('ALTER TABLE driver DROP CONSTRAINT FK_14B3BC5F4C3C5E0A');
$this->addSql('DROP TABLE driver');
$this->addSql('DROP TABLE carrier');
}
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260127000700 extends AbstractMigration
{
public function getDescription(): string
{
return 'Allow null carrier code';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE carrier ALTER code DROP NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE carrier ALTER code SET NOT NULL');
}
}