feat(17-04): menu:import-winter with the D-05 type map and read-only export SQL

- link to url, blog_categories to all-journal-categories, --map old=new on top; page entries dropped
- entries of unknown types or stale registry references dropped with their subtree, one report line per dropped or remapped entry
- ids, menu_id, parent_id, nest columns and sort_order kept; setval for both tables; --force, --dry-run, empty files copy nothing
- scripts/winter-export-menus.sql and winter-export-entries.sql
- TestMenuImportSmoke
This commit is contained in:
2026-10-12 17:35:30 +02:00
parent 08f99b8aad
commit e044bc7b7e
6 changed files with 857 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
-- Menu entries of a WinterCMS site with the Golem15.Menu plugin, one JSON
-- object per line: the --entries input of menu:import-winter.
--
-- mysql -N -B --raw <database> < winter-export-entries.sql > menu-entries.jsonl
--
-- Read-only: it selects from the menu entries table and changes nothing.
-- JSON_OBJECT needs MySQL 5.7.8+ or MariaDB 10.2.3+.
--
-- Check the table name on the server before running:
-- SHOW TABLES LIKE '%menu_menu_entries';
-- This file assumes golem15_menu_menu_entries.
--
-- Check the entry types first; the command maps link to url and
-- blog_categories to all-journal-categories, drops page entries, and drops
-- any other type unless --map old=new names its new type:
-- SELECT type, COUNT(*) FROM golem15_menu_menu_entries GROUP BY type;
SELECT JSON_OBJECT(
'id', e.id,
'menu_id', e.menu_id,
'parent_id', e.parent_id,
'nest_left', e.nest_left,
'nest_right', e.nest_right,
'nest_depth', e.nest_depth,
'sort_order', e.sort_order,
'type', e.type,
'title', e.title,
'url', e.url,
'reference', e.reference,
'code', e.code,
'icon', e.icon,
'css_class', e.css_class,
'target', e.target,
'is_published', e.is_published,
'created_at', e.created_at,
'updated_at', e.updated_at
)
FROM golem15_menu_menu_entries e
ORDER BY e.id;

View File

@@ -0,0 +1,25 @@
-- Menus of a WinterCMS site with the Golem15.Menu plugin, one JSON object
-- per line: the --menus input of menu:import-winter.
--
-- mysql -N -B --raw <database> < winter-export-menus.sql > menus.jsonl
--
-- Read-only: it selects from the menus table and changes nothing.
-- JSON_OBJECT needs MySQL 5.7.8+ or MariaDB 10.2.3+.
--
-- Check the table name on the server before running:
-- SHOW TABLES LIKE '%menu_menus';
-- This file assumes golem15_menu_menus.
--
-- Export the entries with winter-export-entries.sql in the same run: the
-- entries refer to these ids, and the command keeps both.
SELECT JSON_OBJECT(
'id', m.id,
'name', m.name,
'code', m.code,
'is_active', m.is_active,
'css_class', m.css_class,
'created_at', m.created_at,
'updated_at', m.updated_at
)
FROM golem15_menu_menus m
ORDER BY m.id;