[ { "createCollection": "documents_document", "validator": { "$jsonSchema": { "bsonType": "object", "required": [ "_id", "version", "created_at", "updated_at", "org_id", "workspace_id", "project_id", "file_id", "filename", "status" ], "properties": { "_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "version": { "bsonType": "number" }, "created_at": { "bsonType": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$" }, "updated_at": { "bsonType": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$" }, "org_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "workspace_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "project_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "file_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "filename": { "bsonType": "string" }, "status": { "bsonType": "string", "enum": ["processing", "extracted", "failed"] }, "ocr_job_id": { "bsonType": ["number", "null"] }, "page_count": { "bsonType": ["number", "null"] }, "proposed_count": { "bsonType": ["number", "null"] }, "failure_code": { "bsonType": ["string", "null"], "enum": [ "file_missing", "file_changed", "ocr_failed", "extraction_refused", "extraction_truncated", "extraction_invalid" ] }, "finished_at": { "bsonType": ["string", "null"] } }, "additionalProperties": false } } }, { "createIndex": { "collection": "documents_document", "keys": { "org_id": 1, "workspace_id": 1, "project_id": 1, "file_id": 1 }, "name": "documents_document_org_id_workspace_id_project_id_file_id_key", "unique": true } }, { "createIndex": { "collection": "documents_document", "keys": { "org_id": 1, "workspace_id": 1, "project_id": 1, "status": 1 }, "name": "documents_document_org_id_workspace_id_project_id_status_idx", "unique": false } }, { "createCollection": "documents_line", "validator": { "$jsonSchema": { "bsonType": "object", "required": [ "_id", "version", "created_at", "updated_at", "org_id", "workspace_id", "project_id", "document_id", "proposal_id", "label", "value", "page", "position", "quote", "edited", "approved_by" ], "properties": { "_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "version": { "bsonType": "number" }, "created_at": { "bsonType": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$" }, "updated_at": { "bsonType": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$" }, "org_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "workspace_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "project_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "document_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "proposal_id": { "bsonType": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, "label": { "bsonType": "string" }, "value": { "bsonType": "string" }, "page": { "bsonType": "number" }, "position": { "bsonType": "number" }, "quote": { "bsonType": "string" }, "edited": { "bsonType": "bool" }, "approved_by": { "bsonType": "string" } }, "additionalProperties": false } } }, { "createIndex": { "collection": "documents_line", "keys": { "org_id": 1, "workspace_id": 1, "project_id": 1, "proposal_id": 1 }, "name": "documents_line_org_id_workspace_id_project_id_proposal_id_key", "unique": true } }, { "createIndex": { "collection": "documents_line", "keys": { "org_id": 1, "workspace_id": 1, "project_id": 1, "document_id": 1 }, "name": "documents_line_org_id_workspace_id_project_id_document_id_idx", "unique": false } } ]