Newer
Older
Tristan Cherrier
a validé
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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 Version20260208163236 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 departement (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, code VARCHAR(3) NOT NULL, nom VARCHAR(100) NOT NULL, region VARCHAR(100) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_C1765B6377153098 ON departement (code)');
$this->addSql('ALTER TABLE cfe RENAME COLUMN departement TO departement_id');
$this->addSql('ALTER TABLE cfe ADD CONSTRAINT FK_BBAFF59DCCF9E01E FOREIGN KEY (departement_id) REFERENCES departement (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_BBAFF59DCCF9E01E ON cfe (departement_id)');
$this->addSql('ALTER TABLE tfpb RENAME COLUMN departement TO departement_id');
$this->addSql('ALTER TABLE tfpb ADD CONSTRAINT FK_5C026C7CCF9E01E FOREIGN KEY (departement_id) REFERENCES departement (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_5C026C7CCF9E01E ON tfpb (departement_id)');
$this->addSql('ALTER TABLE tfpnb RENAME COLUMN departement TO departement_id');
$this->addSql('ALTER TABLE tfpnb ADD CONSTRAINT FK_D80E37C0CCF9E01E FOREIGN KEY (departement_id) REFERENCES departement (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_D80E37C0CCF9E01E ON tfpnb (departement_id)');
$this->addSql('ALTER TABLE th RENAME COLUMN departement TO departement_id');
$this->addSql('ALTER TABLE th ADD CONSTRAINT FK_49E34767CCF9E01E FOREIGN KEY (departement_id) REFERENCES departement (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_49E34767CCF9E01E ON th (departement_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE departement');
$this->addSql('ALTER TABLE tfpnb DROP CONSTRAINT FK_D80E37C0CCF9E01E');
$this->addSql('DROP INDEX IDX_D80E37C0CCF9E01E');
$this->addSql('ALTER TABLE tfpnb RENAME COLUMN departement_id TO departement');
$this->addSql('ALTER TABLE th DROP CONSTRAINT FK_49E34767CCF9E01E');
$this->addSql('DROP INDEX IDX_49E34767CCF9E01E');
$this->addSql('ALTER TABLE th RENAME COLUMN departement_id TO departement');
$this->addSql('ALTER TABLE tfpb DROP CONSTRAINT FK_5C026C7CCF9E01E');
$this->addSql('DROP INDEX IDX_5C026C7CCF9E01E');
$this->addSql('ALTER TABLE tfpb RENAME COLUMN departement_id TO departement');
$this->addSql('ALTER TABLE cfe DROP CONSTRAINT FK_BBAFF59DCCF9E01E');
$this->addSql('DROP INDEX IDX_BBAFF59DCCF9E01E');
$this->addSql('ALTER TABLE cfe RENAME COLUMN departement_id TO departement');
}
}