-
-
Save SpivEgin/2e002686acebffc0e3ce8ebbd3a06a24 to your computer and use it in GitHub Desktop.
Query to get Django CMS pages into a CSV file to import into WordPress.
This file contains hidden or 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
| -- manifest of all entities | |
| SELECT * | |
| FROM "cms_title" | |
| INNER JOIN "cms_page" | |
| ON ( | |
| "cms_title"."page_id" = "cms_page"."id") | |
| INNER JOIN "django_site" | |
| ON ( | |
| "cms_page"."site_id" = "django_site"."id" | |
| ) | |
| WHERE ( | |
| "cms_page"."publisher_is_draft" = true | |
| ); | |
| --researching what the strucutre of Embedding an app might look like, `embedding-an-app` | |
| SELECT cms_page.id,* | |
| FROM "cms_title" | |
| INNER JOIN "cms_page" | |
| ON "cms_title"."page_id" = "cms_page"."id" | |
| INNER JOIN "django_site" | |
| on "cms_page"."site_id" = "django_site"."id" | |
| WHERE | |
| "cms_page"."publisher_is_draft" = true | |
| and path like '%embedding-an-app%'; | |
| SELECT "cms_page"."id", count("cms_page"."id") | |
| FROM "flex_textplugin" | |
| inner join "cms_cmsplugin" | |
| ON ( "flex_textplugin"."cmsplugin_ptr_id" = "cms_cmsplugin"."id" ) | |
| inner join "cms_page_placeholders" | |
| ON ( "cms_cmsplugin"."placeholder_id" = "cms_page_placeholders"."placeholder_id" ) | |
| inner join "cms_page" | |
| ON ( "cms_page_placeholders"."page_id" = "cms_page"."id") | |
| WHERE ( | |
| "cms_page"."publisher_is_draft" = false | |
| ) | |
| group by "cms_page"."id" | |
| having count("cms_page"."id") > 1 | |
| ORDER BY count("cms_page"."id") desc; | |
| -- All the things we need to pull from | |
| SELECT | |
| cms_page.id AS "PAGE_ID", | |
| cms_page.created_by AS "AUTHOR", | |
| cms_page.parent_id AS "PARENT_ID", | |
| cms_page.creation_date AS "CREATED_AT", | |
| cms_page.publication_date AS "PUBLISHED_AT", | |
| cms_page.in_navigation AS "IN_NAVIGATION", | |
| cms_page.soft_root AS "SOFT_ROOT", | |
| cms_page.template AS "TEMPLATE", | |
| cms_page.level AS "LEVEL", | |
| cms_page.is_home AS "IS_HOME_PAGE", | |
| cms_title.title AS "PAGE_TITLE", | |
| cms_title.slug AS "PAGE_SLUG", | |
| cms_title.path AS "PAGE_PATH", | |
| flex_textplugin.body AS "PAGE_BODY", | |
| CASE WHEN cms_page.parent_id IS NOT null | |
| THEN 'child page' | |
| ELSE 'parent page' END AS struct | |
| FROM flex_textplugin | |
| INNER JOIN cms_cmsplugin | |
| ON flex_textplugin.cmsplugin_ptr_id = cms_cmsplugin.id | |
| INNER JOIN cms_page_placeholders | |
| ON cms_cmsplugin.placeholder_id = cms_page_placeholders.placeholder_id | |
| INNER JOIN cms_page | |
| ON cms_page_placeholders.page_id = cms_page.id | |
| INNER JOIN cms_title | |
| ON cms_title.page_id = cms_page.id | |
| WHERE | |
| cms_page.publisher_is_draft = false and | |
| cms_title.published = true | |
| ORDER BY | |
| cms_page.id; | |
| select * from cms_page_placeholders where id = 1118; | |
| select * from cms_page where id = 617 | |
| ----- dont ever look these up again :) | |
| -- 630 is the usage example set for SS libs, parent = 282 | |
| -- 282 is the nav page for libraries containing links to install, methods, usage, parent = 282 | |
| -- 126 is dev docs, parent is `NULL` | |
| -- 463, example of ss libs, Network Methods, self-contained all methods in one page, 1 for each language | |
| -- All the things we need to pull from plus a little help | |
| CREATE TABLE page_id_map AS | |
| SELECT | |
| ROW_NUMBER() OVER(ORDER BY cms_page) + 1 AS "wp_post_id", | |
| cms_page.id AS "post_id" | |
| --cms_page.created_by AS "AUTHOR", | |
| --cms_page.parent_id AS "post_parent" | |
| --cms_page.creation_date AS "post_date", | |
| --cms_page.publication_date AS "PUBLISHED_AT", | |
| --cms_page.in_navigation AS "IN_NAVIGATION", | |
| --cms_page.soft_root AS "SOFT_ROOT", | |
| --cms_page.template AS "TEMPLATE", | |
| --cms_page.level AS "LEVEL", | |
| --cms_page.is_home AS "IS_HOME_PAGE", | |
| --cms_title.title AS "post_title", | |
| --cms_title.slug AS "PAGE_SLUG", | |
| --cms_title.path AS "PAGE_PATH", | |
| --flex_textplugin.body AS "post_content", | |
| --'page' AS "post_type", | |
| --'publish' AS "post_status", | |
| --'' AS "post_category", | |
| --'' AS "post_tags", | |
| --'' AS "custom_field", | |
| --'admin' AS "post_author" | |
| FROM flex_textplugin | |
| INNER JOIN cms_cmsplugin | |
| ON flex_textplugin.cmsplugin_ptr_id = cms_cmsplugin.id | |
| INNER JOIN cms_page_placeholders | |
| ON cms_cmsplugin.placeholder_id = cms_page_placeholders.placeholder_id | |
| INNER JOIN cms_page | |
| ON cms_page_placeholders.page_id = cms_page.id | |
| INNER JOIN cms_title | |
| ON cms_title.page_id = cms_page.id | |
| WHERE | |
| cms_page.publisher_is_draft = false AND | |
| cms_title.published = true AND | |
| cms_page.is_home IS NOT TRUE | |
| ORDER BY | |
| cms_page.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment