88c10da0b0
Centralize the wiki category-path normalization (separator/quote cleanup, type-label stripping, dedup, depth cap) into a single types helper shared by the service, repository, and taxonomy layers so stored and queried paths are always cleaned identically and cannot drift. Flatten category_path into fixed category_l1/l2/l3 columns (kept in sync on write) and rewrite ListDistinctCategoryPathsByType to group, count, and paginate directly in cross-dialect SQL, returning the page of child folders plus the total distinct count. This removes the prior full-column scan and in-memory pagination (whose maxPaths cap was effectively dead) and makes Total and later pages correct. Add the level columns + composite index to the wiki migrations and the repo test schema, and cover the SQL grouping/counting/pagination with a new test.
15 lines
655 B
SQL
15 lines
655 B
SQL
-- Migration: 000061_wiki_page_hierarchy (rollback)
|
|
|
|
DROP INDEX IF EXISTS idx_wiki_pages_category_levels;
|
|
DROP INDEX IF EXISTS idx_wiki_pages_tree;
|
|
DROP INDEX IF EXISTS idx_wiki_pages_parent_slug;
|
|
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS category_l3;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS category_l2;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS category_l1;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS sort_order;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS depth;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS wiki_path;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS category_path;
|
|
ALTER TABLE wiki_pages DROP COLUMN IF EXISTS parent_slug;
|