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 + } +}