-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: Add information about the renewed contracts
- Loading branch information
1 parent
4eb3d3c
commit d310130
Showing
8 changed files
with
174 additions
and
7 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
migrations/Version20241212082910AddRenewedByToContract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
// This file is part of Bileto. | ||
// Copyright 2022-2024 Probesys | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Platforms\MariaDBPlatform; | ||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
// phpcs:disable Generic.Files.LineLength | ||
final class Version20241212082910AddRenewedByToContract extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add the renewed_by_id to the contract table'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$dbPlatform = $this->connection->getDatabasePlatform(); | ||
if ($dbPlatform instanceof PostgreSQLPlatform) { | ||
$this->addSql('ALTER TABLE contract ADD renewed_by_id INT DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE contract ADD CONSTRAINT FK_E98F2859B26CE351 FOREIGN KEY (renewed_by_id) REFERENCES contract (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_E98F2859B26CE351 ON contract (renewed_by_id)'); | ||
} elseif ($dbPlatform instanceof MariaDBPlatform) { | ||
$this->addSql('ALTER TABLE contract ADD renewed_by_id INT DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE contract ADD CONSTRAINT FK_E98F2859B26CE351 FOREIGN KEY (renewed_by_id) REFERENCES contract (id)'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_E98F2859B26CE351 ON contract (renewed_by_id)'); | ||
} | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$dbPlatform = $this->connection->getDatabasePlatform(); | ||
if ($dbPlatform instanceof PostgreSQLPlatform) { | ||
$this->addSql('ALTER TABLE contract DROP CONSTRAINT FK_E98F2859B26CE351'); | ||
$this->addSql('DROP INDEX UNIQ_E98F2859B26CE351'); | ||
$this->addSql('ALTER TABLE contract DROP renewed_by_id'); | ||
} elseif ($dbPlatform instanceof MariaDBPlatform) { | ||
$this->addSql('ALTER TABLE contract DROP FOREIGN KEY FK_E98F2859B26CE351'); | ||
$this->addSql('DROP INDEX UNIQ_E98F2859B26CE351 ON contract'); | ||
$this->addSql('ALTER TABLE contract DROP renewed_by_id'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters