Skip to content

Commit 82b1861

Browse files
committed
DB migration to unassign deleted tags
1 parent 4c0594b commit 82b1861

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
use Phinx\Migration\AbstractMigration;
4+
5+
class UnassignDeletedTags extends AbstractMigration
6+
{
7+
public function change(): void
8+
{
9+
$updated_rows = $this->execute('
10+
UPDATE tags_relations tr
11+
INNER JOIN tags t ON t.id = tr.tag_id
12+
SET tr.deleted_on = t.deleted, tr.deleted_by_id = 1
13+
WHERE tr.deleted_on IS NULL AND t.deleted > 0
14+
');
15+
$this->output->writeln('Updated rows: '.$updated_rows);
16+
}
17+
}

0 commit comments

Comments
 (0)