-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
50 additions
and
24 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
src/Component/Migrations/Version20240816121145_DatabaseEntry.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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240816121145_DatabaseEntry extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add database entry foreign keys and indices'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE stu_ships ALTER database_id DROP NOT NULL'); | ||
$this->addSql('UPDATE stu_ships SET database_id = null WHERE database_id = 0'); | ||
$this->addSql('ALTER TABLE stu_colonies ADD CONSTRAINT FK_D1C60F73F0AA09DB FOREIGN KEY (database_id) REFERENCES stu_database_entrys (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_D1C60F73F0AA09DB ON stu_colonies (database_id)'); | ||
$this->addSql('ALTER TABLE stu_ships ADD CONSTRAINT FK_A560DD56F0AA09DB FOREIGN KEY (database_id) REFERENCES stu_database_entrys (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_A560DD56F0AA09DB ON stu_ships (database_id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE stu_ships DROP CONSTRAINT FK_A560DD56F0AA09DB'); | ||
$this->addSql('DROP INDEX UNIQ_A560DD56F0AA09DB'); | ||
$this->addSql('ALTER TABLE stu_colonies DROP CONSTRAINT FK_D1C60F73F0AA09DB'); | ||
$this->addSql('DROP INDEX UNIQ_D1C60F73F0AA09DB'); | ||
} | ||
} |
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