mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
Ajout du lien d'héritage dans la bdd
This commit is contained in:
parent
3e9cae5270
commit
54fa272910
50
migrations/Version20221116143546.php
Normal file
50
migrations/Version20221116143546.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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 Version20221116143546 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 place_place (place_source INT NOT NULL, place_target INT NOT NULL, PRIMARY KEY(place_source, place_target))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_DD6B48EEFD44781A ON place_place (place_source)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_DD6B48EEE4A12895 ON place_place (place_target)');
|
||||||
|
$this->addSql('ALTER TABLE place_place ADD CONSTRAINT FK_DD6B48EEFD44781A FOREIGN KEY (place_source) REFERENCES place (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE place_place ADD CONSTRAINT FK_DD6B48EEE4A12895 FOREIGN KEY (place_target) REFERENCES place (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE corridor ADD floor_id INT NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE corridor ADD CONSTRAINT FK_D6DEE755854679E2 FOREIGN KEY (floor_id) REFERENCES floor (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('CREATE INDEX IDX_D6DEE755854679E2 ON corridor (floor_id)');
|
||||||
|
$this->addSql('ALTER TABLE floor ADD building_id INT NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE floor ADD CONSTRAINT FK_BE45D62E4D2A7E12 FOREIGN KEY (building_id) REFERENCES building (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('CREATE INDEX IDX_BE45D62E4D2A7E12 ON floor (building_id)');
|
||||||
|
}
|
||||||
|
|
||||||
|
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 place_place DROP CONSTRAINT FK_DD6B48EEFD44781A');
|
||||||
|
$this->addSql('ALTER TABLE place_place DROP CONSTRAINT FK_DD6B48EEE4A12895');
|
||||||
|
$this->addSql('DROP TABLE place_place');
|
||||||
|
$this->addSql('ALTER TABLE floor DROP CONSTRAINT FK_BE45D62E4D2A7E12');
|
||||||
|
$this->addSql('DROP INDEX IDX_BE45D62E4D2A7E12');
|
||||||
|
$this->addSql('ALTER TABLE floor DROP building_id');
|
||||||
|
$this->addSql('ALTER TABLE corridor DROP CONSTRAINT FK_D6DEE755854679E2');
|
||||||
|
$this->addSql('DROP INDEX IDX_D6DEE755854679E2');
|
||||||
|
$this->addSql('ALTER TABLE corridor DROP floor_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
40
migrations/Version20230110162444.php
Normal file
40
migrations/Version20230110162444.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?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 Version20230110162444 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('DROP SEQUENCE corridor_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE room_id_seq CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE corridor ADD CONSTRAINT FK_D6DEE755BF396750 FOREIGN KEY (id) REFERENCES place (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE place ADD type VARCHAR(255) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE room ADD CONSTRAINT FK_729F519BBF396750 FOREIGN KEY (id) REFERENCES place (id) ON DELETE CASCADE 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('CREATE SEQUENCE corridor_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE room_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('ALTER TABLE room DROP CONSTRAINT FK_729F519BBF396750');
|
||||||
|
$this->addSql('ALTER TABLE place DROP type');
|
||||||
|
$this->addSql('ALTER TABLE corridor DROP CONSTRAINT FK_D6DEE755BF396750');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
/**
|
/**
|
||||||
* @ORM\Entity(repositoryClass=CorridorRepository::class)
|
* @ORM\Entity(repositoryClass=CorridorRepository::class)
|
||||||
*/
|
*/
|
||||||
class Corridor
|
class Corridor extends Place
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
|||||||
@ -9,6 +9,9 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity(repositoryClass=PlaceRepository::class)
|
* @ORM\Entity(repositoryClass=PlaceRepository::class)
|
||||||
|
* @ORM\InheritanceType("JOINED")
|
||||||
|
* @ORM\DiscriminatorColumn(name="type", type="string")
|
||||||
|
* @ORM\DiscriminatorMap({"room"="Room","corridor"="Corridor"})
|
||||||
*/
|
*/
|
||||||
class Place
|
class Place
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
/**
|
/**
|
||||||
* @ORM\Entity(repositoryClass=RoomRepository::class)
|
* @ORM\Entity(repositoryClass=RoomRepository::class)
|
||||||
*/
|
*/
|
||||||
class Room
|
class Room extends Place
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user