From 73f9d27d2493a7a457cfe94bae272bbea54ae5ab Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Wed, 10 Apr 2024 12:00:58 +0200 Subject: [PATCH] migrate: Unpublish WP articles which are redirected --- ...742455229-UnpublishWPRedirectedArticles.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/migration/1712742455229-UnpublishWPRedirectedArticles.ts diff --git a/db/migration/1712742455229-UnpublishWPRedirectedArticles.ts b/db/migration/1712742455229-UnpublishWPRedirectedArticles.ts new file mode 100644 index 00000000000..35c756bb976 --- /dev/null +++ b/db/migration/1712742455229-UnpublishWPRedirectedArticles.ts @@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner } from "typeorm" + +export class UnpublishRedirectedWPArticles1712742455229 + implements MigrationInterface +{ + public async up(queryRunner: QueryRunner): Promise { + 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 { + // empty + } +}