-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(NodesTags): Added a single UUID field to prevent primary key over…
…lap.
- Loading branch information
1 parent
e10c8a4
commit 68fff41
Showing
2 changed files
with
54 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RZ\Roadiz\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230804153629 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Create a single UUID field primary key on nodes_tags table.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('DROP INDEX `primary` ON nodes_tags'); | ||
$this->addSql('ALTER TABLE nodes_tags ADD id VARCHAR(36) DEFAULT NULL'); | ||
$this->addSql('UPDATE nodes_tags SET id = UUID() WHERE id IS NULL'); | ||
$this->addSql('ALTER TABLE nodes_tags CHANGE id id VARCHAR(36) NOT NULL'); | ||
$this->addSql('ALTER TABLE nodes_tags ADD PRIMARY KEY (id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('DROP INDEX `PRIMARY` ON nodes_tags'); | ||
$this->addSql('ALTER TABLE nodes_tags DROP id'); | ||
$this->addSql('ALTER TABLE nodes_tags ADD PRIMARY KEY (node_id, tag_id, position)'); | ||
} | ||
|
||
public function isTransactional(): bool | ||
{ | ||
return false; | ||
} | ||
} |
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