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:
@@ -271,10 +271,10 @@ export const collectionsTools: BaseTool<any>[] = [
|
||||
|
||||
const query = `
|
||||
INSERT INTO collections (
|
||||
name, "urlId", "teamId", "createdById", description, icon, color,
|
||||
permission, sharing, index, "createdAt", "updatedAt"
|
||||
id, name, "urlId", "teamId", "createdById", description, icon, color,
|
||||
permission, sharing, "maintainerApprovalRequired", index, "createdAt", "updatedAt"
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, NOW(), NOW())
|
||||
VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, false, $10, NOW(), NOW())
|
||||
RETURNING
|
||||
id, "urlId", name, description, icon, color, index, permission,
|
||||
sharing, "teamId", "createdById", "createdAt", "updatedAt"
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -275,6 +275,7 @@ const createShare: BaseTool<CreateShareArgs> = {
|
||||
|
||||
const query = `
|
||||
INSERT INTO shares (
|
||||
id,
|
||||
"urlId",
|
||||
"documentId",
|
||||
"userId",
|
||||
@@ -282,9 +283,11 @@ const createShare: BaseTool<CreateShareArgs> = {
|
||||
"includeChildDocuments",
|
||||
published,
|
||||
views,
|
||||
"allowIndexing",
|
||||
"showLastUpdated",
|
||||
"createdAt",
|
||||
"updatedAt"
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, 0, NOW(), NOW())
|
||||
) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, 0, false, false, NOW(), NOW())
|
||||
RETURNING *
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user