Skip to content

Commit

Permalink
🔨 fix posts_links FK constraint, add reusable block tombstones
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Nov 29, 2023
1 parent 1956f0c commit 28beebc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions db/migration/1701280181658-FixPostLinksForeingKeyDeleteClause.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class FixPostLinksForeingKeyDeleteClause1701280181658
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE posts_links
DROP FOREIGN KEY posts_links_ibfk_1;
`)
await queryRunner.query(`
ALTER TABLE posts_links
ADD CONSTRAINT posts_links_ibfk_1
FOREIGN KEY (sourceId)
REFERENCES posts(id)
ON UPDATE CASCADE
ON DELETE CASCADE;
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {}

Check warning on line 21 in db/migration/1701280181658-FixPostLinksForeingKeyDeleteClause.ts

View workflow job for this annotation

GitHub Actions / eslint

'queryRunner' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 21 in db/migration/1701280181658-FixPostLinksForeingKeyDeleteClause.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected empty async method 'down'

Check warning on line 21 in db/migration/1701280181658-FixPostLinksForeingKeyDeleteClause.ts

View workflow job for this annotation

GitHub Actions / eslint

'queryRunner' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 21 in db/migration/1701280181658-FixPostLinksForeingKeyDeleteClause.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected empty async method 'down'
}
5 changes: 4 additions & 1 deletion db/syncPostsToGrapher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ function buildReplacerFunction(
matches: Record<string, string>
) => {
const block = blocks[matches["id"].toString()]
return block ? block.post_content : ""
return block
? `<!-- wp-block-tombstone ${matches["id"]} -->` +
block.post_content
: ""
}
}

Expand Down

0 comments on commit 28beebc

Please sign in to comment.