fix: Schema bugs in create operations - id/urlId columns missing

Fixed 3 schema compatibility bugs found during Round 3 write testing:
- create_document: Added id, urlId, teamId, isWelcome, fullWidth, insightsEnabled
- create_collection: Added id, maintainerApprovalRequired
- shares_create: Added id, allowIndexing, showLastUpdated

All write operations now include required NOT NULL columns.
Bumped version to 1.3.6.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 18:08:52 +00:00
parent 2808d4aec0
commit 354e8ae21f
9 changed files with 140 additions and 78 deletions

View File

@@ -229,19 +229,32 @@ const createDocument: BaseTool<CreateDocumentArgs> = {
const text = args.text ? sanitizeInput(args.text) : '';
const publishedAt = args.publish ? new Date().toISOString() : null;
// Obter teamId da collection
const teamResult = await pgClient.query(
`SELECT "teamId" FROM collections WHERE id = $1`,
[args.collection_id]
);
const teamId = teamResult.rows[0]?.teamId;
const query = `
INSERT INTO documents (
title, text, "collectionId", "parentDocumentId", "createdById",
"lastModifiedById", template, "publishedAt", "createdAt", "updatedAt", version
id, "urlId", title, text, "collectionId", "teamId", "parentDocumentId", "createdById",
"lastModifiedById", template, "publishedAt", "createdAt", "updatedAt", version,
"isWelcome", "fullWidth", "insightsEnabled"
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NOW(), NOW(), 1)
RETURNING id, title, "collectionId", "publishedAt", "createdAt"
VALUES (
gen_random_uuid(),
substring(replace(gen_random_uuid()::text, '-', '') from 1 for 21),
$1, $2, $3, $4, $5, $6, $7, $8, $9, NOW(), NOW(), 1, false, false, false
)
RETURNING id, "urlId", title, "collectionId", "publishedAt", "createdAt"
`;
const params = [
title,
text,
args.collection_id,
teamId,
args.parent_document_id || null,
userId,
userId,