fix(migration): correct schema mismatch between migration script and Document model
SUMMARY: Fixed visibility field schema mismatch causing documents to be internal when they should be public. ISSUE: Migration script used 'public: true' (boolean) but Document model requires 'visibility: "public"' (string enum). Documents migrated with incorrect schema weren't appearing in public document lists. FIX: - Changed migration script to use visibility field (string) - Map legacy 'public' boolean to 'visibility' string - Valid values: 'public', 'internal', 'confidential', 'archived' - Also extract 'category' from frontmatter (was using metadata.type) VALIDATION: - Research governance ROI case study now appears with visibility: public - Category: case-studies (for docs.html sidebar) - Frontmatter properly parsed and mapped to schema RELATED: Enables proper publication of research case study to public documentation. 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7c62d35bf9
commit
0ed9966e7c
1 changed files with 25 additions and 5 deletions
|
|
@ -167,10 +167,29 @@ async function processMarkdownFile(filePath, sourcePath) {
|
|||
slug.toLowerCase().includes(pattern)
|
||||
);
|
||||
|
||||
// Check front matter for explicit public field
|
||||
const isPublic = frontMatter.public !== undefined
|
||||
? frontMatter.public === true || frontMatter.public === 'true'
|
||||
: !isInternal; // Default to public unless it matches internal patterns
|
||||
// Determine visibility from front matter or default based on patterns
|
||||
let visibility = frontMatter.visibility || null;
|
||||
|
||||
if (!visibility) {
|
||||
// Check for legacy public field
|
||||
if (frontMatter.public !== undefined) {
|
||||
const isPublic = frontMatter.public === true || frontMatter.public === 'true';
|
||||
visibility = isPublic ? 'public' : 'internal';
|
||||
} else {
|
||||
// Default to internal if matches internal patterns, otherwise public
|
||||
visibility = isInternal ? 'internal' : 'public';
|
||||
}
|
||||
}
|
||||
|
||||
// Validate visibility value
|
||||
const validVisibility = ['public', 'internal', 'confidential', 'archived'];
|
||||
if (!validVisibility.includes(visibility)) {
|
||||
console.warn(`Invalid visibility '${visibility}' for ${filename}, defaulting to 'internal'`);
|
||||
visibility = 'internal';
|
||||
}
|
||||
|
||||
// Determine category from front matter or metadata type
|
||||
const category = frontMatter.category || metadata.type || 'none';
|
||||
|
||||
// Build document object matching Document model schema
|
||||
const doc = {
|
||||
|
|
@ -178,10 +197,11 @@ async function processMarkdownFile(filePath, sourcePath) {
|
|||
slug: slug,
|
||||
quadrant: metadata.quadrant,
|
||||
persistence: 'HIGH', // Default for technical documents
|
||||
visibility: visibility,
|
||||
category: category,
|
||||
content_html: htmlContent,
|
||||
content_markdown: content,
|
||||
toc: tableOfContents,
|
||||
public: isPublic,
|
||||
metadata: {
|
||||
author: metadata.author,
|
||||
version: metadata.version,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue