41 lines
1.8 KiB
PHP
41 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
*/
|
|
final class Version20260129122052 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// this up() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE TABLE etat_lieux (id SERIAL NOT NULL, contrat_id INT DEFAULT NULL, prestataire_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_D8D384171823061F ON etat_lieux (contrat_id)');
|
|
$this->addSql('CREATE INDEX IDX_D8D38417BE3DB2B7 ON etat_lieux (prestataire_id)');
|
|
$this->addSql('CREATE TABLE prestaire (id SERIAL NOT NULL, email VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, surname VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('ALTER TABLE etat_lieux ADD CONSTRAINT FK_D8D384171823061F FOREIGN KEY (contrat_id) REFERENCES contrats (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('ALTER TABLE etat_lieux ADD CONSTRAINT FK_D8D38417BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestaire (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE SCHEMA public');
|
|
$this->addSql('ALTER TABLE etat_lieux DROP CONSTRAINT FK_D8D384171823061F');
|
|
$this->addSql('ALTER TABLE etat_lieux DROP CONSTRAINT FK_D8D38417BE3DB2B7');
|
|
$this->addSql('DROP TABLE etat_lieux');
|
|
$this->addSql('DROP TABLE prestaire');
|
|
}
|
|
}
|