Skip to content

Commit

Permalink
Fix MySQL & PostgreSQL migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
j0k3r committed Dec 14, 2022
1 parent ba7aabb commit 47bf680
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
12 changes: 4 additions & 8 deletions app/DoctrineMigrations/Version20161001072726.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ public function up(Schema $schema): void
WHERE TABLE_NAME = '" . $this->getTable('entry_tag', WallabagMigration::UN_ESCAPED_TABLE) . "' AND CONSTRAINT_NAME LIKE 'FK_%'
AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
);
$query->execute();

foreach ($query->fetchAll() as $fk) {
foreach ($query->fetchAssociative() as $fk) {
$this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
}
break;
Expand All @@ -42,9 +41,8 @@ public function up(Schema $schema): void
AND conrelid::regclass::text = '" . $this->getTable('entry_tag', WallabagMigration::UN_ESCAPED_TABLE) . "'
AND n.nspname = 'public';"
);
$query->execute();

foreach ($query->fetchAll() as $fk) {
foreach ($query->fetchAssociative() as $fk) {
$this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP CONSTRAINT ' . $fk['conname']);
}
break;
Expand All @@ -65,9 +63,8 @@ public function up(Schema $schema): void
AND COLUMN_NAME = 'entry_id'
AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
);
$query->execute();

foreach ($query->fetchAll() as $fk) {
foreach ($query->fetchAssociative() as $fk) {
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
}
break;
Expand All @@ -84,9 +81,8 @@ public function up(Schema $schema): void
AND n.nspname = 'public'
AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
);
$query->execute();

foreach ($query->fetchAll() as $fk) {
foreach ($query->fetchAssociative() as $fk) {
$this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP CONSTRAINT ' . $fk['conname']);
}
break;
Expand Down
5 changes: 2 additions & 3 deletions app/DoctrineMigrations/Version20170719231144.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ public function up(Schema $schema): void
GROUP BY LOWER(label)
HAVING COUNT(*) > 1'
);
$dupTags->execute();

foreach ($dupTags->fetchAll() as $duplicates) {
foreach ($dupTags->fetchAssociative() as $duplicates) {
$label = $duplicates['lower_label'];

// Retrieve all duplicate tags for a given tag
$tags = $this->connection->executeQuery('
$tags = $this->connection->query('
SELECT id
FROM ' . $this->getTable('tag') . '
WHERE LOWER(label) = :label
Expand Down

0 comments on commit 47bf680

Please sign in to comment.