-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add gdoc_components_table that stores flat components from all docs
This PR adds a new table that contains an unfolded, flat list of all gdocs components in all gdocs. For each gdoc, the tree in $.content.body is iterated, a copy of the content is made without any children and the children are recursed into. Span arrays are converted to plain text. A new script, reconstructPostsGdocsComponents fills the db initially. When saving gdocs, the components for this gdoc are updated in the new posts_gdocs_components table.
- Loading branch information
Showing
10 changed files
with
584 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
db/migration/1732626230267-addPostsGdocsComponentsTable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class AddPostsGdocsComponentsTable1732626230267 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`-- sql | ||
CREATE TABLE posts_gdocs_components ( | ||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, | ||
gdocId VARCHAR(255), | ||
config JSON, | ||
parent VARCHAR(1024), | ||
path VARCHAR(1024), | ||
FOREIGN KEY (gdocId) REFERENCES posts_gdocs(id) ON DELETE CASCADE ON UPDATE CASCADE, | ||
INDEX idx_gdocId (gdocId) | ||
) ENGINE=InnoDB; | ||
`) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE posts_gdocs_components;`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.