Skip to content

Commit

Permalink
Merge pull request #3471 from owid/migrate-unpublish-redirected-articles
Browse files Browse the repository at this point in the history
migrate: Unpublish WP articles which are redirected
  • Loading branch information
marcelgerber authored Apr 12, 2024
2 parents 2d9eb0d + 73f9d27 commit e8cda62
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions db/migration/1712742455229-UnpublishWPRedirectedArticles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class UnpublishRedirectedWPArticles1712742455229
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`-- sql
UPDATE posts p
INNER JOIN redirects r ON r.source = CONCAT("/", p.slug)
SET status = "private",
wpApiSnapshot = JSON_SET(wpApiSnapshot, "$.status", "private")
WHERE p.status = "publish"
AND p.content != ""`)
}

public async down(): Promise<void> {
// empty
}
}

0 comments on commit e8cda62

Please sign in to comment.