diff --git a/.gitignore b/.gitignore index f71a9f3..40390fd 100644 --- a/.gitignore +++ b/.gitignore @@ -137,4 +137,4 @@ dist .yarn/install-state.gz .pnp.* -.storage +storage/organizations/ diff --git a/artifacts/pdf-audit/payload-parity-report.json b/artifacts/pdf-audit/payload-parity-report.json index 16491da..02db715 100644 --- a/artifacts/pdf-audit/payload-parity-report.json +++ b/artifacts/pdf-audit/payload-parity-report.json @@ -1,13 +1,13 @@ { "audit": "payload-parity", "overallStatus": "PASS", - "quotationCode": "CRA2606-1121", - "previewHash": "f50ad995d51a33c5ae169f788591f9efe6e70b7a4f96d6861b549b0c6f71cd2e", - "generationHash": "f50ad995d51a33c5ae169f788591f9efe6e70b7a4f96d6861b549b0c6f71cd2e", - "snapshotHash": "f50ad995d51a33c5ae169f788591f9efe6e70b7a4f96d6861b549b0c6f71cd2e", + "quotationCode": "CRA2606-1108", + "previewHash": "8f93479501b66dfd397c742447b010eaf427697429bfcfd523cd127d06106f26", + "generationHash": "8f93479501b66dfd397c742447b010eaf427697429bfcfd523cd127d06106f26", + "snapshotHash": "8f93479501b66dfd397c742447b010eaf427697429bfcfd523cd127d06106f26", "mismatches": [], - "comparableFieldCount": 25, - "topicInputKeyCount": 0, + "comparableFieldCount": 31, + "topicInputKeyCount": 6, "signatureParity": true, "priceTableParity": true, "priceTableRowCount": 1, diff --git a/artifacts/pdf-audit/placeholder-integrity-report.json b/artifacts/pdf-audit/placeholder-integrity-report.json index cbc8a95..5f91724 100644 --- a/artifacts/pdf-audit/placeholder-integrity-report.json +++ b/artifacts/pdf-audit/placeholder-integrity-report.json @@ -3,7 +3,7 @@ "overallStatus": "PASS", "results": [ { - "templateName": "ALLA Demo Organization Quotation Standard", + "templateName": "ALLA Demo Quotation Standard", "organizationId": "daf796fc-4588-5240-a27e-9bfef0739658", "version": "1.0", "duplicateFieldNames": [], diff --git a/artifacts/pdf-audit/runtime-payload-report.json b/artifacts/pdf-audit/runtime-payload-report.json index 92ebdff..9f62c83 100644 --- a/artifacts/pdf-audit/runtime-payload-report.json +++ b/artifacts/pdf-audit/runtime-payload-report.json @@ -2,10 +2,10 @@ "audit": "runtime-payload", "overallStatus": "PASS", "staticLabelsStatus": "PASS", - "quotationCode": "CRA2606-1121", - "templateName": "ALLA Demo Organization Quotation Standard", + "quotationCode": "CRA2606-1108", + "templateName": "ALLA Demo Quotation Standard", "templateVersion": "1.0", - "findingCount": 86, + "findingCount": 168, "findings": [ { "field": "documentData.company.id", @@ -18,35 +18,35 @@ "field": "documentData.company.name", "source": "documentData", "status": "PASS", - "value": "ALLA Demo Organization", + "value": "ALLA Demo", "message": "String is populated" }, { "field": "documentData.customer.id", "source": "documentData", "status": "PASS", - "value": "a6d9dec1-ff9d-4749-9542-f16d8efcf761", + "value": "cf2c1f29-ce0a-41dd-acc0-13b7f82086cd", "message": "String is populated" }, { "field": "documentData.customer.name", "source": "documentData", "status": "PASS", - "value": "บริษัท แอดวานซ์ โปรเจค คอนซัลแทนท์ จำกัด", + "value": "มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าพระนครเหนือ", "message": "String is populated" }, { "field": "documentData.customer.address", "source": "documentData", "status": "PASS", - "value": "Bang Pakong, Chachoengsao", + "value": "Bang Sue, Bangkok", "message": "String is populated" }, { "field": "documentData.customer.phone", "source": "documentData", "status": "PASS", - "value": "02-600832", + "value": "02-400827", "message": "String is populated" }, { @@ -60,14 +60,14 @@ "field": "documentData.contact.id", "source": "documentData", "status": "PASS", - "value": "df4b3f5f-a4e0-42d7-9181-d56319b23275", + "value": "7c88a108-419f-47ed-a62b-1d784a7b8455", "message": "String is populated" }, { "field": "documentData.contact.name", "source": "documentData", "status": "PASS", - "value": "คุณวราภรณ์ จิรโรจน์", + "value": "คุณวราภรณ์ เกษมศรี", "message": "String is populated" }, { @@ -81,56 +81,56 @@ "field": "documentData.contact.mobile", "source": "documentData", "status": "PASS", - "value": "0810000303", + "value": "0810000250", "message": "String is populated" }, { "field": "documentData.contact.position", "source": "documentData", "status": "PASS", - "value": "Maintenance Supervisor", + "value": "Procurement Manager", "message": "String is populated" }, { "field": "documentData.quotation.id", "source": "documentData", "status": "PASS", - "value": "16ea6fca-ef77-4cb9-8079-0b8dbcdbff57", + "value": "0bbb3fce-f3a2-408a-b93a-6faaa4d74f55", "message": "String is populated" }, { "field": "documentData.quotation.code", "source": "documentData", "status": "PASS", - "value": "CRA2606-1121", + "value": "CRA2606-1108", "message": "String is populated" }, { "field": "documentData.quotation.projectName", "source": "documentData", "status": "PASS", - "value": "บริษัท แอดวานซ์ โปรเจค คอนซัลแทนท์ จำกัด - Phase 2", + "value": "Material Handling Lab Crane", "message": "String is populated" }, { "field": "documentData.quotation.projectLocation", "source": "documentData", "status": "PASS", - "value": "Bang Pakong, Chachoengsao", + "value": "Bang Sue Engineering Faculty", "message": "String is populated" }, { "field": "documentData.quotation.attention", "source": "documentData", "status": "PASS", - "value": "Attention", + "value": "คุณวราภรณ์ เกษมศรี", "message": "String is populated" }, { "field": "documentData.quotation.reference", "source": "documentData", "status": "PASS", - "value": "Reference", + "value": "crm-uat-seed-v1:university-lab-crane-approved", "message": "String is populated" }, { @@ -151,83 +151,279 @@ "field": "documentData.quotation.subtotal", "source": "documentData", "status": "PASS", - "value": 0, + "value": 3008000, "message": "Scalar value is populated" }, { "field": "documentData.quotation.totalAmount", "source": "documentData", "status": "PASS", - "value": 0, + "value": 3122003, "message": "Scalar value is populated" }, { "field": "documentData.items", "source": "documentData", "status": "PASS", - "value": "rows:0", - "message": "Array shape is valid" + "value": "rows:4", + "message": "Collection payload is populated" + }, + { + "field": "documentData.items[0].id", + "source": "documentData", + "status": "PASS", + "value": "f37f7d99-f1e8-4aa9-a207-0a280ec74e26", + "message": "String is populated" + }, + { + "field": "documentData.items[0].itemNumber", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[0].description", + "source": "documentData", + "status": "PASS", + "value": "Main equipment supply for Material Handling Lab Crane", + "message": "String is populated" + }, + { + "field": "documentData.items[0].quantity", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[0].unitLabel", + "source": "documentData", + "status": "PASS", + "value": "Set", + "message": "String is populated" + }, + { + "field": "documentData.items[0].unitPrice", + "source": "documentData", + "status": "PASS", + "value": 1717102, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[0].discount", + "source": "documentData", + "status": "PASS", + "value": 0, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[0].totalPrice", + "source": "documentData", + "status": "PASS", + "value": 1717102, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[1].id", + "source": "documentData", + "status": "PASS", + "value": "63809391-7dd6-4ebd-8aba-3cb5d18b148a", + "message": "String is populated" + }, + { + "field": "documentData.items[1].itemNumber", + "source": "documentData", + "status": "PASS", + "value": 2, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[1].description", + "source": "documentData", + "status": "PASS", + "value": "Installation and commissioning for Material Handling Lab Crane", + "message": "String is populated" + }, + { + "field": "documentData.items[1].quantity", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[1].unitLabel", + "source": "documentData", + "status": "PASS", + "value": "Job", + "message": "String is populated" + }, + { + "field": "documentData.items[1].unitPrice", + "source": "documentData", + "status": "PASS", + "value": 874161, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[1].discount", + "source": "documentData", + "status": "PASS", + "value": 0, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[1].totalPrice", + "source": "documentData", + "status": "PASS", + "value": 874161, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[2].id", + "source": "documentData", + "status": "PASS", + "value": "6e304b78-bbb6-4beb-b04e-6958a9e3ca69", + "message": "String is populated" + }, + { + "field": "documentData.items[2].itemNumber", + "source": "documentData", + "status": "PASS", + "value": 3, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[2].description", + "source": "documentData", + "status": "PASS", + "value": "Operator training and documentation for Material Handling Lab Crane", + "message": "String is populated" + }, + { + "field": "documentData.items[2].quantity", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[2].unitLabel", + "source": "documentData", + "status": "PASS", + "value": "Job", + "message": "String is populated" + }, + { + "field": "documentData.items[2].unitPrice", + "source": "documentData", + "status": "PASS", + "value": 312200, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[2].discount", + "source": "documentData", + "status": "PASS", + "value": 0, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[2].totalPrice", + "source": "documentData", + "status": "PASS", + "value": 312200, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[3].id", + "source": "documentData", + "status": "PASS", + "value": "e28c0f75-086f-4d4a-bc81-a3292fce97b2", + "message": "String is populated" + }, + { + "field": "documentData.items[3].itemNumber", + "source": "documentData", + "status": "PASS", + "value": 4, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[3].description", + "source": "documentData", + "status": "PASS", + "value": "Project management and testing for Material Handling Lab Crane", + "message": "String is populated" + }, + { + "field": "documentData.items[3].quantity", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[3].unitLabel", + "source": "documentData", + "status": "PASS", + "value": "Job", + "message": "String is populated" + }, + { + "field": "documentData.items[3].unitPrice", + "source": "documentData", + "status": "PASS", + "value": 218540, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[3].discount", + "source": "documentData", + "status": "PASS", + "value": 0, + "message": "Scalar value is populated" + }, + { + "field": "documentData.items[3].totalPrice", + "source": "documentData", + "status": "PASS", + "value": 218540, + "message": "Scalar value is populated" }, { "field": "documentData.quotationCustomers", "source": "documentData", "status": "PASS", - "value": "rows:2", + "value": "rows:1", "message": "Collection payload is populated" }, { "field": "documentData.quotationCustomers[0].id", "source": "documentData", "status": "PASS", - "value": "8eac2230-5fc4-4e14-9fa4-b7457efe5660", + "value": "3eb300e9-8410-4a97-b2f3-2fb935e60a0b", "message": "String is populated" }, { "field": "documentData.quotationCustomers[0].customerId", "source": "documentData", "status": "PASS", - "value": "05ae3d52-1157-499e-b6b2-d7e5ab509e4e", + "value": "cf2c1f29-ce0a-41dd-acc0-13b7f82086cd", "message": "String is populated" }, { "field": "documentData.quotationCustomers[0].role", "source": "documentData", "status": "PASS", - "value": "a3b51c9b-e1e6-48b9-95ba-f6e35ba5406e", + "value": "3c5a0f5b-86d5-41bf-9188-7873da5b7bd4", "message": "String is populated" }, { "field": "documentData.quotationCustomers[0].isPrimary", "source": "documentData", "status": "PASS", - "value": false, - "message": "Scalar value is populated" - }, - { - "field": "documentData.quotationCustomers[1].id", - "source": "documentData", - "status": "PASS", - "value": "a8a589b5-5de5-403a-a6bb-a6d9c55efe71", - "message": "String is populated" - }, - { - "field": "documentData.quotationCustomers[1].customerId", - "source": "documentData", - "status": "PASS", - "value": "a6d9dec1-ff9d-4749-9542-f16d8efcf761", - "message": "String is populated" - }, - { - "field": "documentData.quotationCustomers[1].role", - "source": "documentData", - "status": "PASS", - "value": "cfaf96fd-39a2-4074-b295-a4798cf23253", - "message": "String is populated" - }, - { - "field": "documentData.quotationCustomers[1].isPrimary", - "source": "documentData", - "status": "PASS", "value": true, "message": "Scalar value is populated" }, @@ -235,15 +431,267 @@ "field": "documentData.topics.all", "source": "documentData", "status": "PASS", - "value": "rows:0", - "message": "Array shape is valid" + "value": "rows:3", + "message": "Collection payload is populated" + }, + { + "field": "documentData.topics.all[0].id", + "source": "documentData", + "status": "PASS", + "value": "3013a775-bc86-4b22-90f9-048fa1225a91", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[0].title", + "source": "documentData", + "status": "PASS", + "value": "Scope of Work", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[0].topicCode", + "source": "documentData", + "status": "PASS", + "value": "scope", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[0].topicType", + "source": "documentData", + "status": "PASS", + "value": "Scope", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[0].items", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Collection payload is populated" + }, + { + "field": "documentData.topics.all[0].items[0].content", + "source": "documentData", + "status": "PASS", + "value": "Supply and execute material handling lab crane according to approved drawing.", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[0].items[0].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.topics.all[0].items[1].content", + "source": "documentData", + "status": "PASS", + "value": "Include testing, commissioning, and handover documentation.", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[0].items[1].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 2, + "message": "Scalar value is populated" + }, + { + "field": "documentData.topics.all[1].id", + "source": "documentData", + "status": "PASS", + "value": "bf614822-2e02-456e-af35-c9dc50b0140f", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[1].title", + "source": "documentData", + "status": "PASS", + "value": "Exclusions", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[1].topicCode", + "source": "documentData", + "status": "PASS", + "value": "exclusion", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[1].topicType", + "source": "documentData", + "status": "PASS", + "value": "Exclusion", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[1].items", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Collection payload is populated" + }, + { + "field": "documentData.topics.all[1].items[0].content", + "source": "documentData", + "status": "PASS", + "value": "Civil work, main power cable, and customer standby crew are excluded.", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[1].items[0].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.topics.all[1].items[1].content", + "source": "documentData", + "status": "PASS", + "value": "Work outside normal business hours is not included.", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[1].items[1].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 2, + "message": "Scalar value is populated" + }, + { + "field": "documentData.topics.all[2].id", + "source": "documentData", + "status": "PASS", + "value": "eee9e6f9-15d5-4540-9cce-628026bc0281", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[2].title", + "source": "documentData", + "status": "PASS", + "value": "Payment Terms", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[2].topicCode", + "source": "documentData", + "status": "PASS", + "value": "payment", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[2].topicType", + "source": "documentData", + "status": "PASS", + "value": "Payment", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[2].items", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Collection payload is populated" + }, + { + "field": "documentData.topics.all[2].items[0].content", + "source": "documentData", + "status": "PASS", + "value": "40% deposit, 50% after delivery, 10% after commissioning.", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[2].items[0].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.topics.all[2].items[1].content", + "source": "documentData", + "status": "PASS", + "value": "Price validity 30 days and delivery 60-90 days after order confirmation.", + "message": "String is populated" + }, + { + "field": "documentData.topics.all[2].items[1].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 2, + "message": "Scalar value is populated" }, { "field": "documentData.topics.exclusion", "source": "documentData", "status": "PASS", - "value": "rows:0", - "message": "Array shape is valid" + "value": "rows:1", + "message": "Collection payload is populated" + }, + { + "field": "documentData.topics.exclusion[0].id", + "source": "documentData", + "status": "PASS", + "value": "bf614822-2e02-456e-af35-c9dc50b0140f", + "message": "String is populated" + }, + { + "field": "documentData.topics.exclusion[0].title", + "source": "documentData", + "status": "PASS", + "value": "Exclusions", + "message": "String is populated" + }, + { + "field": "documentData.topics.exclusion[0].topicCode", + "source": "documentData", + "status": "PASS", + "value": "exclusion", + "message": "String is populated" + }, + { + "field": "documentData.topics.exclusion[0].topicType", + "source": "documentData", + "status": "PASS", + "value": "Exclusion", + "message": "String is populated" + }, + { + "field": "documentData.topics.exclusion[0].items", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Collection payload is populated" + }, + { + "field": "documentData.topics.exclusion[0].items[0].content", + "source": "documentData", + "status": "PASS", + "value": "Civil work, main power cable, and customer standby crew are excluded.", + "message": "String is populated" + }, + { + "field": "documentData.topics.exclusion[0].items[0].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 1, + "message": "Scalar value is populated" + }, + { + "field": "documentData.topics.exclusion[0].items[1].content", + "source": "documentData", + "status": "PASS", + "value": "Work outside normal business hours is not included.", + "message": "String is populated" + }, + { + "field": "documentData.topics.exclusion[0].items[1].sortOrder", + "source": "documentData", + "status": "PASS", + "value": 2, + "message": "Scalar value is populated" }, { "field": "documentData.pdfme.labels.tel", @@ -284,14 +732,14 @@ "field": "documentData.pdfme.quotation_date", "source": "documentData", "status": "PASS", - "value": "Jun 30, 2026", + "value": "Jun 15, 2026", "message": "String is populated" }, { "field": "documentData.pdfme.quotation_price", "source": "documentData", "status": "PASS", - "value": "THB 0.00", + "value": "THB 3,008,000.00", "message": "String is populated" }, { @@ -305,9 +753,51 @@ "field": "documentData.pdfme.exclusion_data", "source": "documentData", "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "documentData.pdfme.topic_inputs.topic_1_0", + "source": "documentData", + "status": "PASS", "value": "rows:1", "message": "Array shape is valid" }, + { + "field": "documentData.pdfme.topic_inputs.item_topic_1_0", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "documentData.pdfme.topic_inputs.topic_1_1", + "source": "documentData", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "documentData.pdfme.topic_inputs.item_topic_1_1", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "documentData.pdfme.topic_inputs.topic_1_2", + "source": "documentData", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "documentData.pdfme.topic_inputs.item_topic_1_2", + "source": "documentData", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, { "field": "documentData.signatures.preparedBy.name", "source": "documentData", @@ -326,7 +816,7 @@ "field": "documentData.signatures.preparedBy.actedAt", "source": "documentData", "status": "PASS", - "value": "2026-06-30T11:21:06.000Z", + "value": "2026-06-15T09:00:00.000Z", "message": "String is populated" }, { @@ -354,42 +844,42 @@ "field": "documentData.signatures.authorizedBy.name", "source": "documentData", "status": "PASS", - "value": "-", + "value": "Sales Manager UAT", "message": "String is populated" }, { "field": "documentData.signatures.authorizedBy.position", "source": "documentData", "status": "PASS", - "value": "-", + "value": "Sales Manager", "message": "String is populated" }, { "field": "documentData.signatures.authorizedBy.actedAt", "source": "documentData", - "status": "WARNING", - "value": null, - "message": "Value is null" + "status": "PASS", + "value": "2026-06-17T11:00:00.000Z", + "message": "String is populated" }, { "field": "templateInput.customer_name", "source": "templateInput", "status": "PASS", - "value": "บริษัท แอดวานซ์ โปรเจค คอนซัลแทนท์ จำกัด", + "value": "มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าพระนครเหนือ", "message": "String is populated" }, { "field": "templateInput.customer_addr", "source": "templateInput", "status": "PASS", - "value": "Bang Pakong, Chachoengsao", + "value": "Bang Sue, Bangkok", "message": "String is populated" }, { "field": "templateInput.customer_tel", "source": "templateInput", "status": "PASS", - "value": "02-600832", + "value": "02-400827", "message": "String is populated" }, { @@ -403,35 +893,35 @@ "field": "templateInput.customer_att", "source": "templateInput", "status": "PASS", - "value": "Attention", + "value": "คุณวราภรณ์ เกษมศรี", "message": "String is populated" }, { "field": "templateInput.project_name", "source": "templateInput", "status": "PASS", - "value": "บริษัท แอดวานซ์ โปรเจค คอนซัลแทนท์ จำกัด - Phase 2", + "value": "Material Handling Lab Crane", "message": "String is populated" }, { "field": "templateInput.site_location", "source": "templateInput", "status": "PASS", - "value": "Bang Pakong, Chachoengsao", + "value": "Bang Sue Engineering Faculty", "message": "String is populated" }, { "field": "templateInput.quotation_date_data", "source": "templateInput", "status": "PASS", - "value": "Jun 30, 2026", + "value": "Jun 15, 2026", "message": "String is populated" }, { "field": "templateInput.quotation_code_data", "source": "templateInput", "status": "PASS", - "value": "CRA2606-1121", + "value": "CRA2606-1108", "message": "String is populated" }, { @@ -445,7 +935,7 @@ "field": "templateInput.quotation_price", "source": "templateInput", "status": "PASS", - "value": "THB 0.00", + "value": "THB 3,008,000.00", "message": "String is populated" }, { @@ -522,30 +1012,114 @@ "field": "templateInput.app3", "source": "templateInput", "status": "PASS", - "value": "-", + "value": "Sales Manager UAT", "message": "String is populated" }, { "field": "templateInput.app3_position", "source": "templateInput", "status": "PASS", - "value": "-", + "value": "Sales Manager", "message": "String is populated" }, { "field": "templateInput.quotation_date", "source": "templateInput", "status": "PASS", - "value": "Jun 30, 2026", + "value": "Jun 15, 2026", "message": "String is populated" }, + { + "field": "templateInput.topic_1_0", + "source": "templateInput", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "templateInput.item_topic_1_0", + "source": "templateInput", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "templateInput.topic_1_1", + "source": "templateInput", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "templateInput.item_topic_1_1", + "source": "templateInput", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "templateInput.topic_1_2", + "source": "templateInput", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "templateInput.item_topic_1_2", + "source": "templateInput", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, { "field": "templateInput.quotation_code", "source": "templateInput", "status": "PASS", - "value": "CRA2606-1121", + "value": "CRA2606-1108", "message": "String is populated" }, + { + "field": "topicInputs.topic_1_0", + "source": "topicInputs", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "topicInputs.item_topic_1_0", + "source": "topicInputs", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "topicInputs.topic_1_1", + "source": "topicInputs", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "topicInputs.item_topic_1_1", + "source": "topicInputs", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, + { + "field": "topicInputs.topic_1_2", + "source": "topicInputs", + "status": "PASS", + "value": "rows:1", + "message": "Array shape is valid" + }, + { + "field": "topicInputs.item_topic_1_2", + "source": "topicInputs", + "status": "PASS", + "value": "rows:2", + "message": "Array shape is valid" + }, { "field": "templateInput.quotation_price_data", "source": "templateInput", @@ -564,7 +1138,7 @@ "field": "templateInput.quotation_price_data[0][1]", "source": "templateInput", "status": "PASS", - "value": "฿0.00", + "value": "฿3,008,000.00", "message": "Price table amount cell is formatted" }, { diff --git a/artifacts/pdf-audit/signature-audit-report.json b/artifacts/pdf-audit/signature-audit-report.json index fd8347a..2cb365c 100644 --- a/artifacts/pdf-audit/signature-audit-report.json +++ b/artifacts/pdf-audit/signature-audit-report.json @@ -1,13 +1,13 @@ { "audit": "approved-snapshot-parity", "overallStatus": "PASS", - "quotationCode": "CRA2606-1121", + "quotationCode": "CRA2606-1108", "approvedSnapshotAvailable": true, - "approvedTemplateVersionId": "adf930b4-3d63-4ee1-bec9-3e82854ca406", - "computedTemplateVersionId": "adf930b4-3d63-4ee1-bec9-3e82854ca406", + "approvedTemplateVersionId": "e7e89bf2-f107-4f90-b03d-4a7533883d84", + "computedTemplateVersionId": "e7e89bf2-f107-4f90-b03d-4a7533883d84", "inconsistentTemplateKeys": [], - "computedSignatureHash": "ef7a8fc3429f1c5b5a74ac0452d3de809558842f5431d0d5b02122980a286117", - "storedSignatureHash": "ef7a8fc3429f1c5b5a74ac0452d3de809558842f5431d0d5b02122980a286117", + "computedSignatureHash": "922ab2a823f98b032b17da281c86c3a2780d27cca73a60a7b983d14ad039b229", + "storedSignatureHash": "922ab2a823f98b032b17da281c86c3a2780d27cca73a60a7b983d14ad039b229", "approvedArtifactReference": null, "refreshedFixtureSnapshot": true, "usedAuditFixture": false diff --git a/artifacts/pdf-audit/summary.json b/artifacts/pdf-audit/summary.json index 39fa9a7..07d177a 100644 --- a/artifacts/pdf-audit/summary.json +++ b/artifacts/pdf-audit/summary.json @@ -1,7 +1,7 @@ { - "generatedAt": "2026-06-30T13:14:19.935Z", - "overallStatus": "FAIL", - "quotationCode": "CRA2606-1121", + "generatedAt": "2026-06-30T16:18:58.393Z", + "overallStatus": "PASS", + "quotationCode": "CRA2606-1108", "artifacts": { "templateVersionReport": "template-version-report.json", "placeholderIntegrityReport": "placeholder-integrity-report.json", @@ -11,11 +11,11 @@ "signatureAuditReport": "signature-audit-report.json" }, "statuses": { - "templateVersion": "FAIL", + "templateVersion": "PASS", "placeholderIntegrity": "PASS", "runtimePayload": "PASS", "payloadParity": "PASS", - "topicRuntime": "FAIL", + "topicRuntime": "PASS", "approvedSnapshotParity": "PASS", "staticLabels": "PASS" }, diff --git a/artifacts/pdf-audit/summary.md b/artifacts/pdf-audit/summary.md index 2666133..f786102 100644 --- a/artifacts/pdf-audit/summary.md +++ b/artifacts/pdf-audit/summary.md @@ -1,16 +1,16 @@ # PDF Integrity Summary -- Generated At: 2026-06-30T13:14:19.935Z -- Overall Status: FAIL -- Quotation Code: CRA2606-1121 +- Generated At: 2026-06-30T16:18:58.393Z +- Overall Status: PASS +- Quotation Code: CRA2606-1108 ## Statuses -- Template Version Integrity: FAIL +- Template Version Integrity: PASS - Placeholder Integrity: PASS - Runtime Payload: PASS - Payload Parity: PASS -- Topic Runtime: FAIL +- Topic Runtime: PASS - Approved Snapshot Parity: PASS - Static Labels: PASS - Price Table Present: Yes diff --git a/artifacts/pdf-audit/template-version-report.json b/artifacts/pdf-audit/template-version-report.json index d3522b3..e460b67 100644 --- a/artifacts/pdf-audit/template-version-report.json +++ b/artifacts/pdf-audit/template-version-report.json @@ -1,21 +1,9 @@ { "audit": "template-version-integrity", - "overallStatus": "FAIL", + "overallStatus": "PASS", "activeTemplateCount": 1, - "quotationCode": "CRA2606-1121", + "quotationCode": "CRA2606-1108", "approvedTemplateVersionId": null, "approvedTemplateVersionIsActive": false, - "issues": [ - { - "kind": "ACTIVE_VERSION_SCHEMA_DRIFT", - "message": "Active template version does not match source JSON for ALLA Demo Organization Quotation Standard.", - "context": { - "templateId": "83928eee-0b3b-4dcb-9756-726dc2337e6c", - "organizationName": "ALLA Demo Organization", - "activeVersionId": "adf930b4-3d63-4ee1-bec9-3e82854ca406", - "activeVersion": "1.0", - "sourceFile": "src/pdfme_template/ALLA_template_pdfme_fainal3.json" - } - } - ] + "issues": [] } diff --git a/artifacts/pdf-audit/topic-runtime-report.json b/artifacts/pdf-audit/topic-runtime-report.json index 37393fd..fd65a3d 100644 --- a/artifacts/pdf-audit/topic-runtime-report.json +++ b/artifacts/pdf-audit/topic-runtime-report.json @@ -1,10 +1,18 @@ { "audit": "topic-runtime", - "overallStatus": "FAIL", - "quotationCode": "CRA2606-1121", - "topicCount": 0, - "topicInputKeys": [], - "itemTopicInputKeys": [], + "overallStatus": "PASS", + "quotationCode": "CRA2606-1108", + "topicCount": 3, + "topicInputKeys": [ + "topic_1_0", + "topic_1_1", + "topic_1_2" + ], + "itemTopicInputKeys": [ + "item_topic_1_0", + "item_topic_1_1", + "item_topic_1_2" + ], "duplicateKeys": [], "emptySections": [] } diff --git a/docs/implementation/pdf-audit-report.json b/docs/implementation/pdf-audit-report.json index 913b977..b124f9a 100644 --- a/docs/implementation/pdf-audit-report.json +++ b/docs/implementation/pdf-audit-report.json @@ -1,12 +1,12 @@ { - "generatedAt": "2026-06-30T13:14:09.584Z", + "generatedAt": "2026-06-30T16:18:57.428Z", "overallStatus": "PASS", - "quotationCode": "CRA2606-1121", + "quotationCode": "CRA2606-1108", "expectedFixtureCode": "QT-H5-AUDIT", "template": { - "templateName": "ALLA Demo Organization Quotation Standard", + "templateName": "ALLA Demo Quotation Standard", "version": "1.0", - "versionId": "adf930b4-3d63-4ee1-bec9-3e82854ca406", + "versionId": "e7e89bf2-f107-4f90-b03d-4a7533883d84", "fieldCount": 44, "previousVersion": null, "deletedFields": [], @@ -238,11 +238,11 @@ ] }, "metrics": { - "topicCount": 0, - "itemCount": 0, - "partyCount": 2, - "dynamicTopicFieldCount": 0, - "dynamicTopicItemFieldCount": 0, + "topicCount": 3, + "itemCount": 4, + "partyCount": 1, + "dynamicTopicFieldCount": 3, + "dynamicTopicItemFieldCount": 3, "mappingCount": 23 }, "mappingCoverage": { @@ -256,8 +256,8 @@ "itemTableColumns": [] }, "runtimePayload": { - "templateInputKeys": 25, - "topicInputKeys": 0, + "templateInputKeys": 31, + "topicInputKeys": 6, "priceTableRows": 1 }, "consistency": { diff --git a/docs/implementation/pdf-audit-report.md b/docs/implementation/pdf-audit-report.md index 7f303f2..e61b192 100644 --- a/docs/implementation/pdf-audit-report.md +++ b/docs/implementation/pdf-audit-report.md @@ -1,16 +1,16 @@ # PDF Audit Report -- Generated At: 2026-06-30T13:14:09.584Z +- Generated At: 2026-06-30T16:18:57.428Z - Overall Status: PASS -- Quotation Code: CRA2606-1121 -- Template: ALLA Demo Organization Quotation Standard v1.0 +- Quotation Code: CRA2606-1108 +- Template: ALLA Demo Quotation Standard v1.0 - Previous Version: None ## Metrics -- Topic Count: 0 -- Item Count: 0 -- Project Party Count: 2 +- Topic Count: 3 +- Item Count: 4 +- Project Party Count: 1 - Mapping Count: 23 ## Mapping Coverage diff --git a/drizzle/0000_hard_butterfly.sql b/drizzle/0000_short_the_executioner.sql similarity index 72% rename from drizzle/0000_hard_butterfly.sql rename to drizzle/0000_short_the_executioner.sql index 4f30360..cbdfeed 100644 --- a/drizzle/0000_hard_butterfly.sql +++ b/drizzle/0000_short_the_executioner.sql @@ -1,3 +1,106 @@ +CREATE TABLE "app_notification_deliveries" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "notification_id" text NOT NULL, + "channel" text NOT NULL, + "recipient_address" text, + "status" text DEFAULT 'pending' NOT NULL, + "attempt_count" integer DEFAULT 0 NOT NULL, + "last_error" text, + "sent_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "app_notification_dispatches" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "event_id" text NOT NULL, + "template_id" text, + "entity_type" text NOT NULL, + "entity_id" text NOT NULL, + "channel" text NOT NULL, + "provider_key" text NOT NULL, + "status" text DEFAULT 'pending' NOT NULL, + "recipient_to" jsonb NOT NULL, + "recipient_cc" jsonb, + "recipient_bcc" jsonb, + "reply_to" text, + "subject" text NOT NULL, + "body_text" text NOT NULL, + "body_html" text, + "attachments" jsonb, + "recipient_user_id" text, + "recipient_address" text, + "requested_by" text NOT NULL, + "metadata" jsonb, + "last_error" text, + "retry_count" integer DEFAULT 0 NOT NULL, + "max_retry_count" integer DEFAULT 3 NOT NULL, + "last_attempt_at" timestamp with time zone, + "sent_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "app_notification_events" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "event_type" text NOT NULL, + "entity_type" text NOT NULL, + "entity_id" text NOT NULL, + "actor_user_id" text, + "payload" jsonb, + "dedupe_key" text, + "status" text DEFAULT 'pending' NOT NULL, + "last_error" text, + "published_at" timestamp with time zone DEFAULT now() NOT NULL, + "processed_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "app_notification_templates" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "event_type" text NOT NULL, + "code" text DEFAULT '' NOT NULL, + "name" text DEFAULT '' NOT NULL, + "channel" text NOT NULL, + "subject_template" text, + "title_template" text NOT NULL, + "body_template" text NOT NULL, + "body_format" text DEFAULT 'plain' NOT NULL, + "link_template" text, + "language" text DEFAULT 'th' NOT NULL, + "variables" jsonb, + "version" integer DEFAULT 1 NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "metadata" jsonb, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text NOT NULL, + "updated_by" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "app_notifications" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "recipient_user_id" text NOT NULL, + "event_id" text NOT NULL, + "title" text NOT NULL, + "body" text NOT NULL, + "link_url" text, + "severity" text DEFAULT 'info' NOT NULL, + "status" text DEFAULT 'unread' NOT NULL, + "read_at" timestamp with time zone, + "archived_at" timestamp with time zone, + "metadata" jsonb, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint CREATE TABLE "crm_approval_actions" ( "id" text PRIMARY KEY NOT NULL, "organization_id" text NOT NULL, @@ -12,6 +115,60 @@ CREATE TABLE "crm_approval_actions" ( "deleted_at" timestamp with time zone ); --> statement-breakpoint +CREATE TABLE "crm_approval_escalation_policies" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "workflow_id" text NOT NULL, + "step_number" integer NOT NULL, + "trigger_after_hours" integer NOT NULL, + "target_type" text NOT NULL, + "target_value" text, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text NOT NULL, + "updated_by" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "crm_approval_matrices" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "entity_type" text NOT NULL, + "workflow_id" text NOT NULL, + "branch_id" text, + "product_type" text, + "min_amount" double precision, + "max_amount" double precision, + "currency" text, + "priority" integer DEFAULT 100 NOT NULL, + "is_default" boolean DEFAULT false NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "description" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text NOT NULL, + "updated_by" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "crm_approval_reminder_policies" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "workflow_id" text NOT NULL, + "step_number" integer NOT NULL, + "sla_hours" integer DEFAULT 24 NOT NULL, + "reminder_offsets_hours" integer[] DEFAULT '{}' NOT NULL, + "calendar_mode" text DEFAULT 'calendar_days' NOT NULL, + "timeout_action" text DEFAULT 'none' NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text NOT NULL, + "updated_by" text NOT NULL +); +--> statement-breakpoint CREATE TABLE "crm_approval_requests" ( "id" text PRIMARY KEY NOT NULL, "organization_id" text NOT NULL, @@ -19,6 +176,7 @@ CREATE TABLE "crm_approval_requests" ( "entity_type" text NOT NULL, "entity_id" text NOT NULL, "current_step" integer DEFAULT 1 NOT NULL, + "current_step_started_at" timestamp with time zone DEFAULT now() NOT NULL, "status" text NOT NULL, "requested_by" text NOT NULL, "requested_at" timestamp with time zone DEFAULT now() NOT NULL, @@ -35,7 +193,11 @@ CREATE TABLE "crm_approval_steps" ( "step_number" integer NOT NULL, "role_code" text NOT NULL, "role_name" text NOT NULL, + "approval_mode" text DEFAULT 'sequential' NOT NULL, "is_required" boolean DEFAULT true NOT NULL, + "sla_hours" integer DEFAULT 24 NOT NULL, + "calendar_mode" text DEFAULT 'calendar_days' NOT NULL, + "timeout_action" text DEFAULT 'none' NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL, "deleted_at" timestamp with time zone @@ -47,7 +209,11 @@ CREATE TABLE "crm_approval_workflows" ( "code" text NOT NULL, "name" text NOT NULL, "entity_type" text NOT NULL, + "description" text, + "is_system" boolean DEFAULT false NOT NULL, "is_active" boolean DEFAULT true NOT NULL, + "created_by" text NOT NULL, + "updated_by" text NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL, "deleted_at" timestamp with time zone @@ -164,6 +330,49 @@ CREATE TABLE "crm_document_artifacts" ( "deleted_at" timestamp with time zone ); --> statement-breakpoint +CREATE TABLE "crm_document_libraries" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "code" text NOT NULL, + "name" text NOT NULL, + "document_type" text NOT NULL, + "description" text, + "brand" text NOT NULL, + "language" text NOT NULL, + "product_type" text NOT NULL, + "status" text DEFAULT 'active' NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text NOT NULL, + "updated_by" text NOT NULL +); +--> statement-breakpoint +CREATE TABLE "crm_document_library_versions" ( + "id" text PRIMARY KEY NOT NULL, + "organization_id" text NOT NULL, + "library_id" text NOT NULL, + "version" text NOT NULL, + "file_name" text NOT NULL, + "storage_provider" text NOT NULL, + "storage_key" text NOT NULL, + "mime_type" text NOT NULL, + "file_size" integer NOT NULL, + "checksum" text NOT NULL, + "page_count" integer NOT NULL, + "status" text DEFAULT 'draft' NOT NULL, + "is_active" boolean DEFAULT false NOT NULL, + "published_at" timestamp with time zone, + "published_by" text, + "archived_at" timestamp with time zone, + "archived_by" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "deleted_at" timestamp with time zone, + "created_by" text NOT NULL +); +--> statement-breakpoint CREATE TABLE "crm_document_template_mappings" ( "id" text PRIMARY KEY NOT NULL, "organization_id" text NOT NULL, @@ -201,6 +410,7 @@ CREATE TABLE "crm_document_template_versions" ( "version" text NOT NULL, "file_path" text, "schema_json" jsonb NOT NULL, + "metadata_json" jsonb, "preview_image_url" text, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, @@ -270,6 +480,7 @@ CREATE TABLE "crm_opportunities" ( "project_location" text, "product_type" text NOT NULL, "status" text NOT NULL, + "outcome_status" text DEFAULT 'open' NOT NULL, "priority" text NOT NULL, "lead_channel" text, "estimated_value" double precision, @@ -281,6 +492,7 @@ CREATE TABLE "crm_opportunities" ( "is_hot_project" boolean DEFAULT false NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "pipeline_stage" text DEFAULT 'lead' NOT NULL, + "closed_at" timestamp with time zone, "closed_won_at" timestamp with time zone, "closed_lost_at" timestamp with time zone, "closed_by_user_id" text, @@ -289,8 +501,11 @@ CREATE TABLE "crm_opportunities" ( "po_amount" double precision, "po_currency" text, "lost_reason" text, + "lost_detail" text, "lost_competitor" text, "lost_remark" text, + "cancel_reason" text, + "no_quotation_reason" text, "assigned_to_user_id" text, "assigned_at" timestamp with time zone, "assigned_by" text, @@ -549,11 +764,14 @@ CREATE TABLE "document_sequences" ( "id" text PRIMARY KEY NOT NULL, "organization_id" text NOT NULL, "branch_id" text DEFAULT '' NOT NULL, + "product_type" text DEFAULT 'all' NOT NULL, "document_type" text NOT NULL, "prefix" text NOT NULL, "period" text NOT NULL, "current_number" integer DEFAULT 0 NOT NULL, "padding_length" integer DEFAULT 3 NOT NULL, + "format" text DEFAULT '{prefix}{period}-{running}' NOT NULL, + "reset_policy" text DEFAULT 'period' NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL @@ -637,10 +855,17 @@ CREATE TABLE "users" ( "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint +CREATE UNIQUE INDEX "app_notification_dispatches_org_event_channel_recipient_idx" ON "app_notification_dispatches" USING btree ("organization_id","event_id","channel","recipient_address");--> statement-breakpoint +CREATE UNIQUE INDEX "app_notification_events_org_dedupe_idx" ON "app_notification_events" USING btree ("organization_id","dedupe_key");--> statement-breakpoint +CREATE UNIQUE INDEX "app_notification_templates_org_event_channel_idx" ON "app_notification_templates" USING btree ("organization_id","event_type","channel");--> statement-breakpoint +CREATE UNIQUE INDEX "app_notifications_recipient_event_idx" ON "app_notifications" USING btree ("recipient_user_id","event_id");--> statement-breakpoint +CREATE UNIQUE INDEX "crm_approval_reminder_policies_workflow_step_idx" ON "crm_approval_reminder_policies" USING btree ("workflow_id","step_number");--> statement-breakpoint CREATE UNIQUE INDEX "crm_approval_steps_workflow_step_idx" ON "crm_approval_steps" USING btree ("workflow_id","step_number");--> statement-breakpoint CREATE UNIQUE INDEX "crm_approval_workflows_org_code_idx" ON "crm_approval_workflows" USING btree ("organization_id","code");--> statement-breakpoint CREATE UNIQUE INDEX "crm_contact_shares_org_contact_shared_user_idx" ON "crm_contact_shares" USING btree ("organization_id","contact_id","shared_to_user_id");--> statement-breakpoint CREATE UNIQUE INDEX "crm_customers_org_code_idx" ON "crm_customers" USING btree ("organization_id","code");--> statement-breakpoint +CREATE UNIQUE INDEX "crm_document_libraries_org_code_idx" ON "crm_document_libraries" USING btree ("organization_id","code");--> statement-breakpoint +CREATE UNIQUE INDEX "crm_document_library_versions_library_version_idx" ON "crm_document_library_versions" USING btree ("library_id","version");--> statement-breakpoint CREATE UNIQUE INDEX "crm_document_template_mappings_version_placeholder_idx" ON "crm_document_template_mappings" USING btree ("template_version_id","placeholder_key");--> statement-breakpoint CREATE UNIQUE INDEX "crm_document_template_table_columns_mapping_name_idx" ON "crm_document_template_table_columns" USING btree ("mapping_id","column_name");--> statement-breakpoint CREATE UNIQUE INDEX "crm_document_template_versions_template_version_idx" ON "crm_document_template_versions" USING btree ("template_id","version");--> statement-breakpoint @@ -651,7 +876,7 @@ CREATE UNIQUE INDEX "crm_quotations_org_code_idx" ON "crm_quotations" USING btre CREATE UNIQUE INDEX "crm_report_definitions_org_code_idx" ON "crm_report_definitions" USING btree ("organization_id","code");--> statement-breakpoint CREATE UNIQUE INDEX "crm_role_profiles_org_code_idx" ON "crm_role_profiles" USING btree ("organization_id","code");--> statement-breakpoint CREATE UNIQUE INDEX "crm_user_role_assignments_org_user_role_idx" ON "crm_user_role_assignments" USING btree ("organization_id","user_id","role_profile_id");--> statement-breakpoint -CREATE UNIQUE INDEX "document_sequences_org_doc_period_branch_idx" ON "document_sequences" USING btree ("organization_id","document_type","period","branch_id");--> statement-breakpoint +CREATE UNIQUE INDEX "document_sequences_org_branch_product_doc_period_idx" ON "document_sequences" USING btree ("organization_id","branch_id","product_type","document_type","period");--> statement-breakpoint CREATE UNIQUE INDEX "ms_options_org_category_code_idx" ON "ms_options" USING btree ("organization_id","category","code");--> statement-breakpoint CREATE UNIQUE INDEX "organizations_slug_idx" ON "organizations" USING btree ("slug");--> statement-breakpoint CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email"); \ No newline at end of file diff --git a/drizzle/0001_lazy_otto_octavius.sql b/drizzle/0001_lazy_otto_octavius.sql deleted file mode 100644 index a8112b9..0000000 --- a/drizzle/0001_lazy_otto_octavius.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE "crm_opportunities" ADD COLUMN "outcome_status" text DEFAULT 'open' NOT NULL;--> statement-breakpoint -ALTER TABLE "crm_opportunities" ADD COLUMN "closed_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_opportunities" ADD COLUMN "lost_detail" text;--> statement-breakpoint -ALTER TABLE "crm_opportunities" ADD COLUMN "cancel_reason" text;--> statement-breakpoint -ALTER TABLE "crm_opportunities" ADD COLUMN "no_quotation_reason" text; \ No newline at end of file diff --git a/drizzle/0002_calm_approval_matrix.sql b/drizzle/0002_calm_approval_matrix.sql deleted file mode 100644 index d6551a7..0000000 --- a/drizzle/0002_calm_approval_matrix.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "crm_approval_matrices" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "entity_type" text NOT NULL, - "workflow_id" text NOT NULL, - "branch_id" text, - "product_type" text, - "min_amount" double precision, - "max_amount" double precision, - "currency" text, - "priority" integer DEFAULT 100 NOT NULL, - "is_default" boolean DEFAULT false NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "description" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text NOT NULL -); diff --git a/drizzle/0003_workflow_builder_foundation.sql b/drizzle/0003_workflow_builder_foundation.sql deleted file mode 100644 index a6b4efa..0000000 --- a/drizzle/0003_workflow_builder_foundation.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER TABLE "crm_approval_workflows" -ADD COLUMN "description" text; ---> statement-breakpoint -ALTER TABLE "crm_approval_workflows" -ADD COLUMN "is_system" boolean DEFAULT false NOT NULL; ---> statement-breakpoint -ALTER TABLE "crm_approval_workflows" -ADD COLUMN "created_by" text NOT NULL DEFAULT ''; ---> statement-breakpoint -ALTER TABLE "crm_approval_workflows" -ADD COLUMN "updated_by" text NOT NULL DEFAULT ''; ---> statement-breakpoint -ALTER TABLE "crm_approval_steps" -ADD COLUMN "approval_mode" text DEFAULT 'sequential' NOT NULL; diff --git a/drizzle/0004_unusual_hairball.sql b/drizzle/0004_unusual_hairball.sql deleted file mode 100644 index 89dbf68..0000000 --- a/drizzle/0004_unusual_hairball.sql +++ /dev/null @@ -1,73 +0,0 @@ -CREATE TABLE "app_notification_deliveries" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "notification_id" text NOT NULL, - "channel" text NOT NULL, - "recipient_address" text, - "status" text DEFAULT 'pending' NOT NULL, - "attempt_count" integer DEFAULT 0 NOT NULL, - "last_error" text, - "sent_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "app_notification_events" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "event_type" text NOT NULL, - "entity_type" text NOT NULL, - "entity_id" text NOT NULL, - "actor_user_id" text, - "payload" jsonb, - "dedupe_key" text, - "status" text DEFAULT 'pending' NOT NULL, - "last_error" text, - "published_at" timestamp with time zone DEFAULT now() NOT NULL, - "processed_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "app_notification_templates" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "event_type" text NOT NULL, - "channel" text NOT NULL, - "title_template" text NOT NULL, - "body_template" text NOT NULL, - "link_template" text, - "is_active" boolean DEFAULT true NOT NULL, - "metadata" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text NOT NULL -); ---> statement-breakpoint -CREATE TABLE "app_notifications" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "recipient_user_id" text NOT NULL, - "event_id" text NOT NULL, - "title" text NOT NULL, - "body" text NOT NULL, - "link_url" text, - "severity" text DEFAULT 'info' NOT NULL, - "status" text DEFAULT 'unread' NOT NULL, - "read_at" timestamp with time zone, - "archived_at" timestamp with time zone, - "metadata" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE UNIQUE INDEX "app_notification_events_org_dedupe_idx" - ON "app_notification_events" USING btree ("organization_id", "dedupe_key"); ---> statement-breakpoint -CREATE UNIQUE INDEX "app_notification_templates_org_event_channel_idx" - ON "app_notification_templates" USING btree ("organization_id", "event_type", "channel"); ---> statement-breakpoint -CREATE UNIQUE INDEX "app_notifications_recipient_event_idx" - ON "app_notifications" USING btree ("recipient_user_id", "event_id"); diff --git a/drizzle/0005_furry_maelstrom.sql b/drizzle/0005_furry_maelstrom.sql deleted file mode 100644 index a154b2e..0000000 --- a/drizzle/0005_furry_maelstrom.sql +++ /dev/null @@ -1,38 +0,0 @@ -CREATE TABLE "crm_approval_escalation_policies" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "workflow_id" text NOT NULL, - "step_number" integer NOT NULL, - "trigger_after_hours" integer NOT NULL, - "target_type" text NOT NULL, - "target_value" text, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text NOT NULL -); ---> statement-breakpoint -CREATE TABLE "crm_approval_reminder_policies" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "workflow_id" text NOT NULL, - "step_number" integer NOT NULL, - "sla_hours" integer DEFAULT 24 NOT NULL, - "reminder_offsets_hours" integer[] DEFAULT '{}' NOT NULL, - "calendar_mode" text DEFAULT 'calendar_days' NOT NULL, - "timeout_action" text DEFAULT 'none' NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text NOT NULL -); ---> statement-breakpoint -ALTER TABLE "crm_approval_requests" ADD COLUMN "current_step_started_at" timestamp with time zone DEFAULT now() NOT NULL;--> statement-breakpoint -ALTER TABLE "crm_approval_steps" ADD COLUMN "sla_hours" integer DEFAULT 24 NOT NULL;--> statement-breakpoint -ALTER TABLE "crm_approval_steps" ADD COLUMN "calendar_mode" text DEFAULT 'calendar_days' NOT NULL;--> statement-breakpoint -ALTER TABLE "crm_approval_steps" ADD COLUMN "timeout_action" text DEFAULT 'none' NOT NULL;--> statement-breakpoint -CREATE UNIQUE INDEX "crm_approval_reminder_policies_workflow_step_idx" ON "crm_approval_reminder_policies" USING btree ("workflow_id","step_number"); \ No newline at end of file diff --git a/drizzle/0006_lazy_shiver_man.sql b/drizzle/0006_lazy_shiver_man.sql deleted file mode 100644 index b5dddb6..0000000 --- a/drizzle/0006_lazy_shiver_man.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER TABLE "crm_document_template_versions" ADD COLUMN "metadata_json" jsonb; ---> statement-breakpoint -UPDATE "crm_document_template_versions" -SET - "metadata_json" = COALESCE("metadata_json", "schema_json" -> '__templateManagement'), - "schema_json" = CASE - WHEN "schema_json" ? '__templateManagement' - THEN "schema_json" - '__templateManagement' - ELSE "schema_json" - END -WHERE "schema_json" ? '__templateManagement'; diff --git a/drizzle/0007_document_library_foundation.sql b/drizzle/0007_document_library_foundation.sql deleted file mode 100644 index 42990df..0000000 --- a/drizzle/0007_document_library_foundation.sql +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE "crm_document_libraries" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "document_type" text NOT NULL, - "description" text, - "brand" text NOT NULL, - "language" text NOT NULL, - "product_type" text NOT NULL, - "status" text DEFAULT 'active' NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text NOT NULL -); ---> statement-breakpoint -CREATE UNIQUE INDEX "crm_document_libraries_org_code_idx" ON "crm_document_libraries" USING btree ("organization_id","code"); ---> statement-breakpoint -CREATE TABLE "crm_document_library_versions" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "library_id" text NOT NULL, - "version" text NOT NULL, - "file_name" text NOT NULL, - "storage_provider" text NOT NULL, - "storage_key" text NOT NULL, - "mime_type" text NOT NULL, - "file_size" integer NOT NULL, - "checksum" text NOT NULL, - "page_count" integer NOT NULL, - "status" text DEFAULT 'draft' NOT NULL, - "is_active" boolean DEFAULT false NOT NULL, - "published_at" timestamp with time zone, - "published_by" text, - "archived_at" timestamp with time zone, - "archived_by" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL -); ---> statement-breakpoint -CREATE UNIQUE INDEX "crm_document_library_versions_library_version_idx" ON "crm_document_library_versions" USING btree ("library_id","version"); ---> statement-breakpoint -CREATE UNIQUE INDEX "crm_document_library_versions_active_library_idx" - ON "crm_document_library_versions" USING btree ("library_id") - WHERE "is_active" = true AND "deleted_at" IS NULL; diff --git a/drizzle/0008_document_sequence_scope_refactor.sql b/drizzle/0008_document_sequence_scope_refactor.sql deleted file mode 100644 index 16d5865..0000000 --- a/drizzle/0008_document_sequence_scope_refactor.sql +++ /dev/null @@ -1,28 +0,0 @@ -ALTER TABLE "document_sequences" -ADD COLUMN "product_type" text DEFAULT 'all' NOT NULL; ---> statement-breakpoint -ALTER TABLE "document_sequences" -ADD COLUMN "format" text DEFAULT '{prefix}{period}-{running}' NOT NULL; ---> statement-breakpoint -ALTER TABLE "document_sequences" -ADD COLUMN "reset_policy" text DEFAULT 'period' NOT NULL; ---> statement-breakpoint -UPDATE "document_sequences" -SET - "product_type" = CASE - WHEN "document_type" = 'quotation' THEN 'legacy' - ELSE 'all' - END, - "format" = '{prefix}{period}-{running}', - "reset_policy" = 'period'; ---> statement-breakpoint -DROP INDEX "document_sequences_org_doc_period_branch_idx"; ---> statement-breakpoint -CREATE UNIQUE INDEX "document_sequences_org_branch_product_doc_period_idx" -ON "document_sequences" USING btree ( - "organization_id", - "branch_id", - "product_type", - "document_type", - "period" -); diff --git a/drizzle/0009_notification_delivery_foundation.sql b/drizzle/0009_notification_delivery_foundation.sql deleted file mode 100644 index 8131377..0000000 --- a/drizzle/0009_notification_delivery_foundation.sql +++ /dev/null @@ -1,60 +0,0 @@ -ALTER TABLE "app_notification_templates" - ADD COLUMN "code" text DEFAULT '' NOT NULL, - ADD COLUMN "name" text DEFAULT '' NOT NULL, - ADD COLUMN "subject_template" text, - ADD COLUMN "body_format" text DEFAULT 'plain' NOT NULL, - ADD COLUMN "language" text DEFAULT 'th' NOT NULL, - ADD COLUMN "variables" jsonb, - ADD COLUMN "version" integer DEFAULT 1 NOT NULL; ---> statement-breakpoint -UPDATE "app_notification_templates" -SET - "code" = CASE - WHEN "code" = '' THEN replace("event_type", '.', '_') || '_' || "channel" - ELSE "code" - END, - "name" = CASE - WHEN "name" = '' THEN "event_type" || ' (' || "channel" || ')' - ELSE "name" - END, - "subject_template" = COALESCE("subject_template", "title_template"), - "variables" = COALESCE("variables", '[]'::jsonb); ---> statement-breakpoint -CREATE TABLE "app_notification_dispatches" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "event_id" text NOT NULL, - "template_id" text, - "entity_type" text NOT NULL, - "entity_id" text NOT NULL, - "channel" text NOT NULL, - "provider_key" text NOT NULL, - "status" text DEFAULT 'pending' NOT NULL, - "recipient_to" jsonb NOT NULL, - "recipient_cc" jsonb, - "recipient_bcc" jsonb, - "reply_to" text, - "subject" text NOT NULL, - "body_text" text NOT NULL, - "body_html" text, - "attachments" jsonb, - "recipient_user_id" text, - "recipient_address" text, - "requested_by" text NOT NULL, - "metadata" jsonb, - "last_error" text, - "retry_count" integer DEFAULT 0 NOT NULL, - "max_retry_count" integer DEFAULT 3 NOT NULL, - "last_attempt_at" timestamp with time zone, - "sent_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE UNIQUE INDEX "app_notification_dispatches_org_event_channel_recipient_idx" - ON "app_notification_dispatches" USING btree ( - "organization_id", - "event_id", - "channel", - "recipient_address" - ); diff --git a/drizzle/0009_stale_next_avengers.sql b/drizzle/0009_stale_next_avengers.sql deleted file mode 100644 index 18822d1..0000000 --- a/drizzle/0009_stale_next_avengers.sql +++ /dev/null @@ -1,89 +0,0 @@ -CREATE TABLE "app_notification_dispatches" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "event_id" text NOT NULL, - "template_id" text, - "entity_type" text NOT NULL, - "entity_id" text NOT NULL, - "channel" text NOT NULL, - "provider_key" text NOT NULL, - "status" text DEFAULT 'pending' NOT NULL, - "recipient_to" jsonb NOT NULL, - "recipient_cc" jsonb, - "recipient_bcc" jsonb, - "reply_to" text, - "subject" text NOT NULL, - "body_text" text NOT NULL, - "body_html" text, - "attachments" jsonb, - "recipient_user_id" text, - "recipient_address" text, - "requested_by" text NOT NULL, - "metadata" jsonb, - "last_error" text, - "retry_count" integer DEFAULT 0 NOT NULL, - "max_retry_count" integer DEFAULT 3 NOT NULL, - "last_attempt_at" timestamp with time zone, - "sent_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "crm_document_libraries" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "document_type" text NOT NULL, - "description" text, - "brand" text NOT NULL, - "language" text NOT NULL, - "product_type" text NOT NULL, - "status" text DEFAULT 'active' NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL, - "updated_by" text NOT NULL -); ---> statement-breakpoint -CREATE TABLE "crm_document_library_versions" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "library_id" text NOT NULL, - "version" text NOT NULL, - "file_name" text NOT NULL, - "storage_provider" text NOT NULL, - "storage_key" text NOT NULL, - "mime_type" text NOT NULL, - "file_size" integer NOT NULL, - "checksum" text NOT NULL, - "page_count" integer NOT NULL, - "status" text DEFAULT 'draft' NOT NULL, - "is_active" boolean DEFAULT false NOT NULL, - "published_at" timestamp with time zone, - "published_by" text, - "archived_at" timestamp with time zone, - "archived_by" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - "created_by" text NOT NULL -); ---> statement-breakpoint -DROP INDEX "document_sequences_org_doc_period_branch_idx";--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "code" text DEFAULT '' NOT NULL;--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "name" text DEFAULT '' NOT NULL;--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "subject_template" text;--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "body_format" text DEFAULT 'plain' NOT NULL;--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "language" text DEFAULT 'th' NOT NULL;--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "variables" jsonb;--> statement-breakpoint -ALTER TABLE "app_notification_templates" ADD COLUMN "version" integer DEFAULT 1 NOT NULL;--> statement-breakpoint -ALTER TABLE "document_sequences" ADD COLUMN "product_type" text DEFAULT 'all' NOT NULL;--> statement-breakpoint -ALTER TABLE "document_sequences" ADD COLUMN "format" text DEFAULT '{prefix}{period}-{running}' NOT NULL;--> statement-breakpoint -ALTER TABLE "document_sequences" ADD COLUMN "reset_policy" text DEFAULT 'period' NOT NULL;--> statement-breakpoint -CREATE UNIQUE INDEX "app_notification_dispatches_org_event_channel_recipient_idx" ON "app_notification_dispatches" USING btree ("organization_id","event_id","channel","recipient_address");--> statement-breakpoint -CREATE UNIQUE INDEX "crm_document_libraries_org_code_idx" ON "crm_document_libraries" USING btree ("organization_id","code");--> statement-breakpoint -CREATE UNIQUE INDEX "crm_document_library_versions_library_version_idx" ON "crm_document_library_versions" USING btree ("library_id","version");--> statement-breakpoint -CREATE UNIQUE INDEX "document_sequences_org_branch_product_doc_period_idx" ON "document_sequences" USING btree ("organization_id","branch_id","product_type","document_type","period"); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json index e51701b..36daf96 100644 --- a/drizzle/meta/0000_snapshot.json +++ b/drizzle/meta/0000_snapshot.json @@ -1,9 +1,733 @@ { - "id": "e01a80c3-a4b5-4461-afb0-52b663dfa084", + "id": "6eb8d614-2b85-48c3-919e-af8fa13f0fb6", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", "tables": { + "public.app_notification_deliveries": { + "name": "app_notification_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notification_id": { + "name": "notification_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_address": { + "name": "recipient_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_notification_dispatches": { + "name": "app_notification_dispatches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_key": { + "name": "provider_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "recipient_to": { + "name": "recipient_to", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "recipient_cc": { + "name": "recipient_cc", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "recipient_bcc": { + "name": "recipient_bcc", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "reply_to": { + "name": "reply_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_html": { + "name": "body_html", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "recipient_address": { + "name": "recipient_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requested_by": { + "name": "requested_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "retry_count": { + "name": "retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_retry_count": { + "name": "max_retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "last_attempt_at": { + "name": "last_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sent_at": { + "name": "sent_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_notification_dispatches_org_event_channel_recipient_idx": { + "name": "app_notification_dispatches_org_event_channel_recipient_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "recipient_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_notification_events": { + "name": "app_notification_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_notification_events_org_dedupe_idx": { + "name": "app_notification_events_org_dedupe_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_notification_templates": { + "name": "app_notification_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject_template": { + "name": "subject_template", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title_template": { + "name": "title_template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_template": { + "name": "body_template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_format": { + "name": "body_format", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'plain'" + }, + "link_template": { + "name": "link_template", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'th'" + }, + "variables": { + "name": "variables", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "app_notification_templates_org_event_channel_idx": { + "name": "app_notification_templates_org_event_channel_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.app_notifications": { + "name": "app_notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "link_url": { + "name": "link_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'info'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unread'" + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "app_notifications_recipient_event_idx": { + "name": "app_notifications_recipient_event_idx", + "columns": [ + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.crm_approval_actions": { "name": "crm_approval_actions", "schema": "", @@ -86,6 +810,352 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.crm_approval_escalation_policies": { + "name": "crm_approval_escalation_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "step_number": { + "name": "step_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "trigger_after_hours": { + "name": "trigger_after_hours", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_value": { + "name": "target_value", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.crm_approval_matrices": { + "name": "crm_approval_matrices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch_id": { + "name": "branch_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "product_type": { + "name": "product_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "min_amount": { + "name": "min_amount", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "max_amount": { + "name": "max_amount", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "priority": { + "name": "priority", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 100 + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.crm_approval_reminder_policies": { + "name": "crm_approval_reminder_policies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "step_number": { + "name": "step_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "sla_hours": { + "name": "sla_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "reminder_offsets_hours": { + "name": "reminder_offsets_hours", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "calendar_mode": { + "name": "calendar_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'calendar_days'" + }, + "timeout_action": { + "name": "timeout_action", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "crm_approval_reminder_policies_workflow_step_idx": { + "name": "crm_approval_reminder_policies_workflow_step_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "step_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.crm_approval_requests": { "name": "crm_approval_requests", "schema": "", @@ -127,6 +1197,13 @@ "notNull": true, "default": 1 }, + "current_step_started_at": { + "name": "current_step_started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, "status": { "name": "status", "type": "text", @@ -221,6 +1298,13 @@ "primaryKey": false, "notNull": true }, + "approval_mode": { + "name": "approval_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'sequential'" + }, "is_required": { "name": "is_required", "type": "boolean", @@ -228,6 +1312,27 @@ "notNull": true, "default": true }, + "sla_hours": { + "name": "sla_hours", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 24 + }, + "calendar_mode": { + "name": "calendar_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'calendar_days'" + }, + "timeout_action": { + "name": "timeout_action", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", @@ -313,6 +1418,19 @@ "primaryKey": false, "notNull": true }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_system": { + "name": "is_system", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, "is_active": { "name": "is_active", "type": "boolean", @@ -320,6 +1438,18 @@ "notNull": true, "default": true }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", @@ -1080,6 +2210,306 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.crm_document_libraries": { + "name": "crm_document_libraries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_type": { + "name": "document_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_type": { + "name": "product_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "crm_document_libraries_org_code_idx": { + "name": "crm_document_libraries_org_code_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.crm_document_library_versions": { + "name": "crm_document_library_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "library_id": { + "name": "library_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_provider": { + "name": "storage_provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "checksum": { + "name": "checksum", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_count": { + "name": "page_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_by": { + "name": "archived_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "crm_document_library_versions_library_version_idx": { + "name": "crm_document_library_versions_library_version_idx", + "columns": [ + { + "expression": "library_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.crm_document_template_mappings": { "name": "crm_document_template_mappings", "schema": "", @@ -1340,6 +2770,12 @@ "primaryKey": false, "notNull": true }, + "metadata_json": { + "name": "metadata_json", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, "preview_image_url": { "name": "preview_image_url", "type": "text", @@ -1834,6 +3270,13 @@ "primaryKey": false, "notNull": true }, + "outcome_status": { + "name": "outcome_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, "priority": { "name": "priority", "type": "text", @@ -1903,6 +3346,12 @@ "notNull": true, "default": "'lead'" }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "closed_won_at": { "name": "closed_won_at", "type": "timestamp with time zone", @@ -1951,6 +3400,12 @@ "primaryKey": false, "notNull": false }, + "lost_detail": { + "name": "lost_detail", + "type": "text", + "primaryKey": false, + "notNull": false + }, "lost_competitor": { "name": "lost_competitor", "type": "text", @@ -1963,6 +3418,18 @@ "primaryKey": false, "notNull": false }, + "cancel_reason": { + "name": "cancel_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "no_quotation_reason": { + "name": "no_quotation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, "assigned_to_user_id": { "name": "assigned_to_user_id", "type": "text", @@ -3623,6 +5090,13 @@ "notNull": true, "default": "''" }, + "product_type": { + "name": "product_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'all'" + }, "document_type": { "name": "document_type", "type": "text", @@ -3655,6 +5129,20 @@ "notNull": true, "default": 3 }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'{prefix}{period}-{running}'" + }, + "reset_policy": { + "name": "reset_policy", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'period'" + }, "is_active": { "name": "is_active", "type": "boolean", @@ -3678,8 +5166,8 @@ } }, "indexes": { - "document_sequences_org_doc_period_branch_idx": { - "name": "document_sequences_org_doc_period_branch_idx", + "document_sequences_org_branch_product_doc_period_idx": { + "name": "document_sequences_org_branch_product_doc_period_idx", "columns": [ { "expression": "organization_id", @@ -3687,6 +5175,18 @@ "asc": true, "nulls": "last" }, + { + "expression": "branch_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "product_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, { "expression": "document_type", "isExpression": false, @@ -3698,12 +5198,6 @@ "isExpression": false, "asc": true, "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" } ], "isUnique": true, diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json deleted file mode 100644 index 73de703..0000000 --- a/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,4294 +0,0 @@ -{ - "id": "76a80d29-837a-4056-874e-600b1e297b11", - "prevId": "e01a80c3-a4b5-4461-afb0-52b663dfa084", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.crm_approval_actions": { - "name": "crm_approval_actions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_request_id": { - "name": "approval_request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "acted_by": { - "name": "acted_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "acted_at": { - "name": "acted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_requests": { - "name": "crm_approval_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_step": { - "name": "current_step", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_steps": { - "name": "crm_approval_steps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_code": { - "name": "role_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_steps_workflow_step_idx": { - "name": "crm_approval_steps_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_workflows": { - "name": "crm_approval_workflows", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_workflows_org_code_idx": { - "name": "crm_approval_workflows_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_contact_shares": { - "name": "crm_contact_shares", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_to_user_id": { - "name": "shared_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_by_user_id": { - "name": "shared_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_at": { - "name": "shared_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_contact_shares_org_contact_shared_user_idx": { - "name": "crm_contact_shares_org_contact_shared_user_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "contact_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "shared_to_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_contacts": { - "name": "crm_customer_contacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "position": { - "name": "position", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department": { - "name": "department", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mobile": { - "name": "mobile", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_owner_history": { - "name": "crm_customer_owner_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "old_owner_user_id": { - "name": "old_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "new_owner_user_id": { - "name": "new_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "changed_by": { - "name": "changed_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "changed_at": { - "name": "changed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customers": { - "name": "crm_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "abbr": { - "name": "abbr", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_id": { - "name": "tax_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_type": { - "name": "customer_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_status": { - "name": "customer_status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "province": { - "name": "province", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "district": { - "name": "district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sub_district": { - "name": "sub_district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "fax": { - "name": "fax", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "website": { - "name": "website", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_group": { - "name": "customer_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_sub_group": { - "name": "customer_sub_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_user_id": { - "name": "owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_at": { - "name": "owner_assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_by": { - "name": "owner_assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_customers_org_code_idx": { - "name": "crm_customers_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_artifacts": { - "name": "crm_document_artifacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "artifact_type": { - "name": "artifact_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checksum": { - "name": "checksum", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "generated_by": { - "name": "generated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "generated_at": { - "name": "generated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "locked_by": { - "name": "locked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "voided_at": { - "name": "voided_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "voided_by": { - "name": "voided_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "void_reason": { - "name": "void_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_mappings": { - "name": "crm_document_template_mappings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "placeholder_key": { - "name": "placeholder_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_path": { - "name": "source_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "data_type": { - "name": "data_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sheet_name": { - "name": "sheet_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "default_value": { - "name": "default_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_mappings_version_placeholder_idx": { - "name": "crm_document_template_mappings_version_placeholder_idx", - "columns": [ - { - "expression": "template_version_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "placeholder_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_table_columns": { - "name": "crm_document_template_table_columns", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mapping_id": { - "name": "mapping_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_name": { - "name": "column_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_field": { - "name": "source_field", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_letter": { - "name": "column_letter", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_table_columns_mapping_name_idx": { - "name": "crm_document_template_table_columns_mapping_name_idx", - "columns": [ - { - "expression": "mapping_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "column_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_versions": { - "name": "crm_document_template_versions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "schema_json": { - "name": "schema_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "preview_image_url": { - "name": "preview_image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_template_versions_template_version_idx": { - "name": "crm_document_template_versions_template_version_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_templates": { - "name": "crm_document_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_name": { - "name": "template_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_templates_org_doc_product_file_name_idx": { - "name": "crm_document_templates_org_doc_product_file_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "product_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "file_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_leads": { - "name": "crm_leads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "awareness_id": { - "name": "awareness_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'new_job'" - }, - "followup_status": { - "name": "followup_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "owner_marketing_user_id": { - "name": "owner_marketing_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_sales_owner_id": { - "name": "assigned_sales_owner_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_leads_org_code_idx": { - "name": "crm_leads_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunities": { - "name": "crm_opportunities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_id": { - "name": "lead_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "requirement": { - "name": "requirement", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "outcome_status": { - "name": "outcome_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "expected_close_date": { - "name": "expected_close_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pipeline_stage": { - "name": "pipeline_stage", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'lead'" - }, - "closed_at": { - "name": "closed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_won_at": { - "name": "closed_won_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_lost_at": { - "name": "closed_lost_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_by_user_id": { - "name": "closed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_number": { - "name": "po_number", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_date": { - "name": "po_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "po_amount": { - "name": "po_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "po_currency": { - "name": "po_currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_detail": { - "name": "lost_detail", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "cancel_reason": { - "name": "cancel_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "no_quotation_reason": { - "name": "no_quotation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_to_user_id": { - "name": "assigned_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_opportunities_org_code_idx": { - "name": "crm_opportunities_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_attachments": { - "name": "crm_opportunity_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_customers": { - "name": "crm_opportunity_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_followups": { - "name": "crm_opportunity_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_attachments": { - "name": "crm_quotation_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_customers": { - "name": "crm_quotation_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_followups": { - "name": "crm_quotation_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_items": { - "name": "crm_quotation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "item_number": { - "name": "item_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "unit": { - "name": "unit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unit_price": { - "name": "unit_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_price": { - "name": "total_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topic_items": { - "name": "crm_quotation_topic_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_id": { - "name": "topic_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topics": { - "name": "crm_quotation_topics", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_type": { - "name": "topic_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotations": { - "name": "crm_quotations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "quotation_date": { - "name": "quotation_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "valid_until": { - "name": "valid_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "quotation_type": { - "name": "quotation_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attention": { - "name": "attention", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference": { - "name": "reference", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "revision": { - "name": "revision", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "parent_quotation_id": { - "name": "parent_quotation_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revision_remark": { - "name": "revision_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "exchange_rate": { - "name": "exchange_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "subtotal": { - "name": "subtotal", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tax_amount": { - "name": "tax_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_amount": { - "name": "total_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "salesman_id": { - "name": "salesman_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_sent": { - "name": "is_sent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sent_via": { - "name": "sent_via", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "approved_artifact_id": { - "name": "approved_artifact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_pdf_url": { - "name": "approved_pdf_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_snapshot": { - "name": "approved_snapshot", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "approved_template_version_id": { - "name": "approved_template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "accepted_at": { - "name": "accepted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejected_at": { - "name": "rejected_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejection_reason": { - "name": "rejection_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_quotations_org_code_idx": { - "name": "crm_quotations_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_report_definitions": { - "name": "crm_report_definitions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "crm_report_definitions_org_code_idx": { - "name": "crm_report_definitions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_role_profiles": { - "name": "crm_role_profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "product_scope_mode": { - "name": "product_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "ownership_scope": { - "name": "ownership_scope", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'own'" - }, - "approval_authority": { - "name": "approval_authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_role_profiles_org_code_idx": { - "name": "crm_role_profiles_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_user_role_assignments": { - "name": "crm_user_role_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_profile_id": { - "name": "role_profile_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_mode": { - "name": "product_type_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_user_role_assignments_org_user_role_idx": { - "name": "crm_user_role_assignments_org_user_role_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role_profile_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.document_sequences": { - "name": "document_sequences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "period": { - "name": "period", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_number": { - "name": "current_number", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "padding_length": { - "name": "padding_length", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_sequences_org_doc_period_branch_idx": { - "name": "document_sequences_org_doc_period_branch_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "period", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "business_role": { - "name": "business_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sales_support'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.ms_options": { - "name": "ms_options", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "label": { - "name": "label", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "parent_id": { - "name": "parent_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "ms_options_org_category_code_idx": { - "name": "ms_options_org_category_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tr_audit_logs": { - "name": "tr_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "before_data": { - "name": "before_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after_data": { - "name": "after_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "system_role": { - "name": "system_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0004_snapshot.json b/drizzle/meta/0004_snapshot.json deleted file mode 100644 index 4c2596c..0000000 --- a/drizzle/meta/0004_snapshot.json +++ /dev/null @@ -1,4909 +0,0 @@ -{ - "id": "d0a45ce4-f9df-4afd-9020-c23d19e9d39f", - "prevId": "76a80d29-837a-4056-874e-600b1e297b11", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.app_notification_deliveries": { - "name": "app_notification_deliveries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "notification_id": { - "name": "notification_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_address": { - "name": "recipient_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_events": { - "name": "app_notification_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "actor_user_id": { - "name": "actor_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notification_events_org_dedupe_idx": { - "name": "app_notification_events_org_dedupe_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_templates": { - "name": "app_notification_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title_template": { - "name": "title_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_template": { - "name": "body_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_template": { - "name": "link_template", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "app_notification_templates_org_event_channel_idx": { - "name": "app_notification_templates_org_event_channel_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "channel", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notifications": { - "name": "app_notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_id": { - "name": "event_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body": { - "name": "body", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_url": { - "name": "link_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "severity": { - "name": "severity", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'info'" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'unread'" - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "archived_at": { - "name": "archived_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notifications_recipient_event_idx": { - "name": "app_notifications_recipient_event_idx", - "columns": [ - { - "expression": "recipient_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_actions": { - "name": "crm_approval_actions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_request_id": { - "name": "approval_request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "acted_by": { - "name": "acted_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "acted_at": { - "name": "acted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_matrices": { - "name": "crm_approval_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "min_amount": { - "name": "min_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "max_amount": { - "name": "max_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 100 - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_requests": { - "name": "crm_approval_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_step": { - "name": "current_step", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_steps": { - "name": "crm_approval_steps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_code": { - "name": "role_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_mode": { - "name": "approval_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sequential'" - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_steps_workflow_step_idx": { - "name": "crm_approval_steps_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_workflows": { - "name": "crm_approval_workflows", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_workflows_org_code_idx": { - "name": "crm_approval_workflows_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_contact_shares": { - "name": "crm_contact_shares", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_to_user_id": { - "name": "shared_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_by_user_id": { - "name": "shared_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_at": { - "name": "shared_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_contact_shares_org_contact_shared_user_idx": { - "name": "crm_contact_shares_org_contact_shared_user_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "contact_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "shared_to_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_contacts": { - "name": "crm_customer_contacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "position": { - "name": "position", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department": { - "name": "department", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mobile": { - "name": "mobile", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_owner_history": { - "name": "crm_customer_owner_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "old_owner_user_id": { - "name": "old_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "new_owner_user_id": { - "name": "new_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "changed_by": { - "name": "changed_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "changed_at": { - "name": "changed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customers": { - "name": "crm_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "abbr": { - "name": "abbr", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_id": { - "name": "tax_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_type": { - "name": "customer_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_status": { - "name": "customer_status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "province": { - "name": "province", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "district": { - "name": "district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sub_district": { - "name": "sub_district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "fax": { - "name": "fax", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "website": { - "name": "website", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_group": { - "name": "customer_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_sub_group": { - "name": "customer_sub_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_user_id": { - "name": "owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_at": { - "name": "owner_assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_by": { - "name": "owner_assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_customers_org_code_idx": { - "name": "crm_customers_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_artifacts": { - "name": "crm_document_artifacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "artifact_type": { - "name": "artifact_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checksum": { - "name": "checksum", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "generated_by": { - "name": "generated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "generated_at": { - "name": "generated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "locked_by": { - "name": "locked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "voided_at": { - "name": "voided_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "voided_by": { - "name": "voided_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "void_reason": { - "name": "void_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_mappings": { - "name": "crm_document_template_mappings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "placeholder_key": { - "name": "placeholder_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_path": { - "name": "source_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "data_type": { - "name": "data_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sheet_name": { - "name": "sheet_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "default_value": { - "name": "default_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_mappings_version_placeholder_idx": { - "name": "crm_document_template_mappings_version_placeholder_idx", - "columns": [ - { - "expression": "template_version_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "placeholder_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_table_columns": { - "name": "crm_document_template_table_columns", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mapping_id": { - "name": "mapping_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_name": { - "name": "column_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_field": { - "name": "source_field", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_letter": { - "name": "column_letter", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_table_columns_mapping_name_idx": { - "name": "crm_document_template_table_columns_mapping_name_idx", - "columns": [ - { - "expression": "mapping_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "column_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_versions": { - "name": "crm_document_template_versions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "schema_json": { - "name": "schema_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "preview_image_url": { - "name": "preview_image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_template_versions_template_version_idx": { - "name": "crm_document_template_versions_template_version_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_templates": { - "name": "crm_document_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_name": { - "name": "template_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_templates_org_doc_product_file_name_idx": { - "name": "crm_document_templates_org_doc_product_file_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "product_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "file_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_leads": { - "name": "crm_leads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "awareness_id": { - "name": "awareness_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'new_job'" - }, - "followup_status": { - "name": "followup_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "owner_marketing_user_id": { - "name": "owner_marketing_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_sales_owner_id": { - "name": "assigned_sales_owner_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_leads_org_code_idx": { - "name": "crm_leads_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunities": { - "name": "crm_opportunities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_id": { - "name": "lead_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "requirement": { - "name": "requirement", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "outcome_status": { - "name": "outcome_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "expected_close_date": { - "name": "expected_close_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pipeline_stage": { - "name": "pipeline_stage", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'lead'" - }, - "closed_at": { - "name": "closed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_won_at": { - "name": "closed_won_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_lost_at": { - "name": "closed_lost_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_by_user_id": { - "name": "closed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_number": { - "name": "po_number", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_date": { - "name": "po_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "po_amount": { - "name": "po_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "po_currency": { - "name": "po_currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_detail": { - "name": "lost_detail", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "cancel_reason": { - "name": "cancel_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "no_quotation_reason": { - "name": "no_quotation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_to_user_id": { - "name": "assigned_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_opportunities_org_code_idx": { - "name": "crm_opportunities_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_attachments": { - "name": "crm_opportunity_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_customers": { - "name": "crm_opportunity_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_followups": { - "name": "crm_opportunity_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_attachments": { - "name": "crm_quotation_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_customers": { - "name": "crm_quotation_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_followups": { - "name": "crm_quotation_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_items": { - "name": "crm_quotation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "item_number": { - "name": "item_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "unit": { - "name": "unit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unit_price": { - "name": "unit_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_price": { - "name": "total_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topic_items": { - "name": "crm_quotation_topic_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_id": { - "name": "topic_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topics": { - "name": "crm_quotation_topics", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_type": { - "name": "topic_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotations": { - "name": "crm_quotations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "quotation_date": { - "name": "quotation_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "valid_until": { - "name": "valid_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "quotation_type": { - "name": "quotation_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attention": { - "name": "attention", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference": { - "name": "reference", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "revision": { - "name": "revision", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "parent_quotation_id": { - "name": "parent_quotation_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revision_remark": { - "name": "revision_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "exchange_rate": { - "name": "exchange_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "subtotal": { - "name": "subtotal", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tax_amount": { - "name": "tax_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_amount": { - "name": "total_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "salesman_id": { - "name": "salesman_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_sent": { - "name": "is_sent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sent_via": { - "name": "sent_via", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "approved_artifact_id": { - "name": "approved_artifact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_pdf_url": { - "name": "approved_pdf_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_snapshot": { - "name": "approved_snapshot", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "approved_template_version_id": { - "name": "approved_template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "accepted_at": { - "name": "accepted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejected_at": { - "name": "rejected_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejection_reason": { - "name": "rejection_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_quotations_org_code_idx": { - "name": "crm_quotations_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_report_definitions": { - "name": "crm_report_definitions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "crm_report_definitions_org_code_idx": { - "name": "crm_report_definitions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_role_profiles": { - "name": "crm_role_profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "product_scope_mode": { - "name": "product_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "ownership_scope": { - "name": "ownership_scope", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'own'" - }, - "approval_authority": { - "name": "approval_authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_role_profiles_org_code_idx": { - "name": "crm_role_profiles_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_user_role_assignments": { - "name": "crm_user_role_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_profile_id": { - "name": "role_profile_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_mode": { - "name": "product_type_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_user_role_assignments_org_user_role_idx": { - "name": "crm_user_role_assignments_org_user_role_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role_profile_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.document_sequences": { - "name": "document_sequences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "period": { - "name": "period", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_number": { - "name": "current_number", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "padding_length": { - "name": "padding_length", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_sequences_org_doc_period_branch_idx": { - "name": "document_sequences_org_doc_period_branch_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "period", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "business_role": { - "name": "business_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sales_support'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.ms_options": { - "name": "ms_options", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "label": { - "name": "label", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "parent_id": { - "name": "parent_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "ms_options_org_category_code_idx": { - "name": "ms_options_org_category_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tr_audit_logs": { - "name": "tr_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "before_data": { - "name": "before_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after_data": { - "name": "after_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "system_role": { - "name": "system_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0005_snapshot.json b/drizzle/meta/0005_snapshot.json deleted file mode 100644 index ba2f651..0000000 --- a/drizzle/meta/0005_snapshot.json +++ /dev/null @@ -1,5157 +0,0 @@ -{ - "id": "6b9c3902-feb2-4170-a430-092e68140a0f", - "prevId": "d0a45ce4-f9df-4afd-9020-c23d19e9d39f", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.app_notification_deliveries": { - "name": "app_notification_deliveries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "notification_id": { - "name": "notification_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_address": { - "name": "recipient_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_events": { - "name": "app_notification_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "actor_user_id": { - "name": "actor_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notification_events_org_dedupe_idx": { - "name": "app_notification_events_org_dedupe_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_templates": { - "name": "app_notification_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title_template": { - "name": "title_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_template": { - "name": "body_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_template": { - "name": "link_template", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "app_notification_templates_org_event_channel_idx": { - "name": "app_notification_templates_org_event_channel_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "channel", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notifications": { - "name": "app_notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_id": { - "name": "event_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body": { - "name": "body", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_url": { - "name": "link_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "severity": { - "name": "severity", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'info'" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'unread'" - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "archived_at": { - "name": "archived_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notifications_recipient_event_idx": { - "name": "app_notifications_recipient_event_idx", - "columns": [ - { - "expression": "recipient_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_actions": { - "name": "crm_approval_actions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_request_id": { - "name": "approval_request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "acted_by": { - "name": "acted_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "acted_at": { - "name": "acted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_escalation_policies": { - "name": "crm_approval_escalation_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "trigger_after_hours": { - "name": "trigger_after_hours", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "target_type": { - "name": "target_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "target_value": { - "name": "target_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_matrices": { - "name": "crm_approval_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "min_amount": { - "name": "min_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "max_amount": { - "name": "max_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 100 - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_reminder_policies": { - "name": "crm_approval_reminder_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "sla_hours": { - "name": "sla_hours", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 24 - }, - "reminder_offsets_hours": { - "name": "reminder_offsets_hours", - "type": "integer[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "calendar_mode": { - "name": "calendar_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'calendar_days'" - }, - "timeout_action": { - "name": "timeout_action", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_approval_reminder_policies_workflow_step_idx": { - "name": "crm_approval_reminder_policies_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_requests": { - "name": "crm_approval_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_step": { - "name": "current_step", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "current_step_started_at": { - "name": "current_step_started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_steps": { - "name": "crm_approval_steps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_code": { - "name": "role_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_mode": { - "name": "approval_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sequential'" - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "sla_hours": { - "name": "sla_hours", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 24 - }, - "calendar_mode": { - "name": "calendar_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'calendar_days'" - }, - "timeout_action": { - "name": "timeout_action", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_steps_workflow_step_idx": { - "name": "crm_approval_steps_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_workflows": { - "name": "crm_approval_workflows", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_workflows_org_code_idx": { - "name": "crm_approval_workflows_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_contact_shares": { - "name": "crm_contact_shares", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_to_user_id": { - "name": "shared_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_by_user_id": { - "name": "shared_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_at": { - "name": "shared_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_contact_shares_org_contact_shared_user_idx": { - "name": "crm_contact_shares_org_contact_shared_user_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "contact_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "shared_to_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_contacts": { - "name": "crm_customer_contacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "position": { - "name": "position", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department": { - "name": "department", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mobile": { - "name": "mobile", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_owner_history": { - "name": "crm_customer_owner_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "old_owner_user_id": { - "name": "old_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "new_owner_user_id": { - "name": "new_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "changed_by": { - "name": "changed_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "changed_at": { - "name": "changed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customers": { - "name": "crm_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "abbr": { - "name": "abbr", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_id": { - "name": "tax_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_type": { - "name": "customer_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_status": { - "name": "customer_status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "province": { - "name": "province", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "district": { - "name": "district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sub_district": { - "name": "sub_district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "fax": { - "name": "fax", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "website": { - "name": "website", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_group": { - "name": "customer_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_sub_group": { - "name": "customer_sub_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_user_id": { - "name": "owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_at": { - "name": "owner_assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_by": { - "name": "owner_assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_customers_org_code_idx": { - "name": "crm_customers_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_artifacts": { - "name": "crm_document_artifacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "artifact_type": { - "name": "artifact_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checksum": { - "name": "checksum", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "generated_by": { - "name": "generated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "generated_at": { - "name": "generated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "locked_by": { - "name": "locked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "voided_at": { - "name": "voided_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "voided_by": { - "name": "voided_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "void_reason": { - "name": "void_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_mappings": { - "name": "crm_document_template_mappings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "placeholder_key": { - "name": "placeholder_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_path": { - "name": "source_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "data_type": { - "name": "data_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sheet_name": { - "name": "sheet_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "default_value": { - "name": "default_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_mappings_version_placeholder_idx": { - "name": "crm_document_template_mappings_version_placeholder_idx", - "columns": [ - { - "expression": "template_version_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "placeholder_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_table_columns": { - "name": "crm_document_template_table_columns", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mapping_id": { - "name": "mapping_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_name": { - "name": "column_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_field": { - "name": "source_field", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_letter": { - "name": "column_letter", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_table_columns_mapping_name_idx": { - "name": "crm_document_template_table_columns_mapping_name_idx", - "columns": [ - { - "expression": "mapping_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "column_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_versions": { - "name": "crm_document_template_versions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "schema_json": { - "name": "schema_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "preview_image_url": { - "name": "preview_image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_template_versions_template_version_idx": { - "name": "crm_document_template_versions_template_version_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_templates": { - "name": "crm_document_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_name": { - "name": "template_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_templates_org_doc_product_file_name_idx": { - "name": "crm_document_templates_org_doc_product_file_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "product_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "file_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_leads": { - "name": "crm_leads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "awareness_id": { - "name": "awareness_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'new_job'" - }, - "followup_status": { - "name": "followup_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "owner_marketing_user_id": { - "name": "owner_marketing_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_sales_owner_id": { - "name": "assigned_sales_owner_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_leads_org_code_idx": { - "name": "crm_leads_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunities": { - "name": "crm_opportunities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_id": { - "name": "lead_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "requirement": { - "name": "requirement", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "outcome_status": { - "name": "outcome_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "expected_close_date": { - "name": "expected_close_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pipeline_stage": { - "name": "pipeline_stage", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'lead'" - }, - "closed_at": { - "name": "closed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_won_at": { - "name": "closed_won_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_lost_at": { - "name": "closed_lost_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_by_user_id": { - "name": "closed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_number": { - "name": "po_number", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_date": { - "name": "po_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "po_amount": { - "name": "po_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "po_currency": { - "name": "po_currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_detail": { - "name": "lost_detail", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "cancel_reason": { - "name": "cancel_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "no_quotation_reason": { - "name": "no_quotation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_to_user_id": { - "name": "assigned_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_opportunities_org_code_idx": { - "name": "crm_opportunities_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_attachments": { - "name": "crm_opportunity_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_customers": { - "name": "crm_opportunity_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_followups": { - "name": "crm_opportunity_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_attachments": { - "name": "crm_quotation_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_customers": { - "name": "crm_quotation_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_followups": { - "name": "crm_quotation_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_items": { - "name": "crm_quotation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "item_number": { - "name": "item_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "unit": { - "name": "unit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unit_price": { - "name": "unit_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_price": { - "name": "total_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topic_items": { - "name": "crm_quotation_topic_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_id": { - "name": "topic_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topics": { - "name": "crm_quotation_topics", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_type": { - "name": "topic_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotations": { - "name": "crm_quotations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "quotation_date": { - "name": "quotation_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "valid_until": { - "name": "valid_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "quotation_type": { - "name": "quotation_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attention": { - "name": "attention", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference": { - "name": "reference", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "revision": { - "name": "revision", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "parent_quotation_id": { - "name": "parent_quotation_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revision_remark": { - "name": "revision_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "exchange_rate": { - "name": "exchange_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "subtotal": { - "name": "subtotal", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tax_amount": { - "name": "tax_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_amount": { - "name": "total_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "salesman_id": { - "name": "salesman_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_sent": { - "name": "is_sent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sent_via": { - "name": "sent_via", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "approved_artifact_id": { - "name": "approved_artifact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_pdf_url": { - "name": "approved_pdf_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_snapshot": { - "name": "approved_snapshot", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "approved_template_version_id": { - "name": "approved_template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "accepted_at": { - "name": "accepted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejected_at": { - "name": "rejected_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejection_reason": { - "name": "rejection_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_quotations_org_code_idx": { - "name": "crm_quotations_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_report_definitions": { - "name": "crm_report_definitions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "crm_report_definitions_org_code_idx": { - "name": "crm_report_definitions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_role_profiles": { - "name": "crm_role_profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "product_scope_mode": { - "name": "product_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "ownership_scope": { - "name": "ownership_scope", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'own'" - }, - "approval_authority": { - "name": "approval_authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_role_profiles_org_code_idx": { - "name": "crm_role_profiles_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_user_role_assignments": { - "name": "crm_user_role_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_profile_id": { - "name": "role_profile_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_mode": { - "name": "product_type_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_user_role_assignments_org_user_role_idx": { - "name": "crm_user_role_assignments_org_user_role_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role_profile_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.document_sequences": { - "name": "document_sequences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "period": { - "name": "period", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_number": { - "name": "current_number", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "padding_length": { - "name": "padding_length", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_sequences_org_doc_period_branch_idx": { - "name": "document_sequences_org_doc_period_branch_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "period", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "business_role": { - "name": "business_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sales_support'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.ms_options": { - "name": "ms_options", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "label": { - "name": "label", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "parent_id": { - "name": "parent_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "ms_options_org_category_code_idx": { - "name": "ms_options_org_category_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tr_audit_logs": { - "name": "tr_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "before_data": { - "name": "before_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after_data": { - "name": "after_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "system_role": { - "name": "system_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0006_snapshot.json b/drizzle/meta/0006_snapshot.json deleted file mode 100644 index 210ba92..0000000 --- a/drizzle/meta/0006_snapshot.json +++ /dev/null @@ -1,5163 +0,0 @@ -{ - "id": "61cab7a1-31a8-47e2-b563-e6c9dc313f32", - "prevId": "6b9c3902-feb2-4170-a430-092e68140a0f", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.app_notification_deliveries": { - "name": "app_notification_deliveries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "notification_id": { - "name": "notification_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_address": { - "name": "recipient_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_events": { - "name": "app_notification_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "actor_user_id": { - "name": "actor_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notification_events_org_dedupe_idx": { - "name": "app_notification_events_org_dedupe_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_templates": { - "name": "app_notification_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title_template": { - "name": "title_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_template": { - "name": "body_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_template": { - "name": "link_template", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "app_notification_templates_org_event_channel_idx": { - "name": "app_notification_templates_org_event_channel_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "channel", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notifications": { - "name": "app_notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_id": { - "name": "event_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body": { - "name": "body", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_url": { - "name": "link_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "severity": { - "name": "severity", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'info'" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'unread'" - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "archived_at": { - "name": "archived_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notifications_recipient_event_idx": { - "name": "app_notifications_recipient_event_idx", - "columns": [ - { - "expression": "recipient_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_actions": { - "name": "crm_approval_actions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_request_id": { - "name": "approval_request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "acted_by": { - "name": "acted_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "acted_at": { - "name": "acted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_escalation_policies": { - "name": "crm_approval_escalation_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "trigger_after_hours": { - "name": "trigger_after_hours", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "target_type": { - "name": "target_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "target_value": { - "name": "target_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_matrices": { - "name": "crm_approval_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "min_amount": { - "name": "min_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "max_amount": { - "name": "max_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 100 - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_reminder_policies": { - "name": "crm_approval_reminder_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "sla_hours": { - "name": "sla_hours", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 24 - }, - "reminder_offsets_hours": { - "name": "reminder_offsets_hours", - "type": "integer[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "calendar_mode": { - "name": "calendar_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'calendar_days'" - }, - "timeout_action": { - "name": "timeout_action", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_approval_reminder_policies_workflow_step_idx": { - "name": "crm_approval_reminder_policies_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_requests": { - "name": "crm_approval_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_step": { - "name": "current_step", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "current_step_started_at": { - "name": "current_step_started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_steps": { - "name": "crm_approval_steps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_code": { - "name": "role_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_mode": { - "name": "approval_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sequential'" - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "sla_hours": { - "name": "sla_hours", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 24 - }, - "calendar_mode": { - "name": "calendar_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'calendar_days'" - }, - "timeout_action": { - "name": "timeout_action", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_steps_workflow_step_idx": { - "name": "crm_approval_steps_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_workflows": { - "name": "crm_approval_workflows", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_workflows_org_code_idx": { - "name": "crm_approval_workflows_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_contact_shares": { - "name": "crm_contact_shares", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_to_user_id": { - "name": "shared_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_by_user_id": { - "name": "shared_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_at": { - "name": "shared_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_contact_shares_org_contact_shared_user_idx": { - "name": "crm_contact_shares_org_contact_shared_user_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "contact_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "shared_to_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_contacts": { - "name": "crm_customer_contacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "position": { - "name": "position", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department": { - "name": "department", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mobile": { - "name": "mobile", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_owner_history": { - "name": "crm_customer_owner_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "old_owner_user_id": { - "name": "old_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "new_owner_user_id": { - "name": "new_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "changed_by": { - "name": "changed_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "changed_at": { - "name": "changed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customers": { - "name": "crm_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "abbr": { - "name": "abbr", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_id": { - "name": "tax_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_type": { - "name": "customer_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_status": { - "name": "customer_status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "province": { - "name": "province", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "district": { - "name": "district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sub_district": { - "name": "sub_district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "fax": { - "name": "fax", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "website": { - "name": "website", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_group": { - "name": "customer_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_sub_group": { - "name": "customer_sub_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_user_id": { - "name": "owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_at": { - "name": "owner_assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_by": { - "name": "owner_assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_customers_org_code_idx": { - "name": "crm_customers_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_artifacts": { - "name": "crm_document_artifacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "artifact_type": { - "name": "artifact_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checksum": { - "name": "checksum", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "generated_by": { - "name": "generated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "generated_at": { - "name": "generated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "locked_by": { - "name": "locked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "voided_at": { - "name": "voided_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "voided_by": { - "name": "voided_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "void_reason": { - "name": "void_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_mappings": { - "name": "crm_document_template_mappings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "placeholder_key": { - "name": "placeholder_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_path": { - "name": "source_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "data_type": { - "name": "data_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sheet_name": { - "name": "sheet_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "default_value": { - "name": "default_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_mappings_version_placeholder_idx": { - "name": "crm_document_template_mappings_version_placeholder_idx", - "columns": [ - { - "expression": "template_version_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "placeholder_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_table_columns": { - "name": "crm_document_template_table_columns", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mapping_id": { - "name": "mapping_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_name": { - "name": "column_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_field": { - "name": "source_field", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_letter": { - "name": "column_letter", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_table_columns_mapping_name_idx": { - "name": "crm_document_template_table_columns_mapping_name_idx", - "columns": [ - { - "expression": "mapping_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "column_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_versions": { - "name": "crm_document_template_versions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "schema_json": { - "name": "schema_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "metadata_json": { - "name": "metadata_json", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "preview_image_url": { - "name": "preview_image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_template_versions_template_version_idx": { - "name": "crm_document_template_versions_template_version_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_templates": { - "name": "crm_document_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_name": { - "name": "template_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_templates_org_doc_product_file_name_idx": { - "name": "crm_document_templates_org_doc_product_file_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "product_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "file_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_leads": { - "name": "crm_leads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "awareness_id": { - "name": "awareness_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'new_job'" - }, - "followup_status": { - "name": "followup_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "owner_marketing_user_id": { - "name": "owner_marketing_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_sales_owner_id": { - "name": "assigned_sales_owner_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_leads_org_code_idx": { - "name": "crm_leads_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunities": { - "name": "crm_opportunities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_id": { - "name": "lead_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "requirement": { - "name": "requirement", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "outcome_status": { - "name": "outcome_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "expected_close_date": { - "name": "expected_close_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pipeline_stage": { - "name": "pipeline_stage", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'lead'" - }, - "closed_at": { - "name": "closed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_won_at": { - "name": "closed_won_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_lost_at": { - "name": "closed_lost_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_by_user_id": { - "name": "closed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_number": { - "name": "po_number", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_date": { - "name": "po_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "po_amount": { - "name": "po_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "po_currency": { - "name": "po_currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_detail": { - "name": "lost_detail", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "cancel_reason": { - "name": "cancel_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "no_quotation_reason": { - "name": "no_quotation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_to_user_id": { - "name": "assigned_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_opportunities_org_code_idx": { - "name": "crm_opportunities_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_attachments": { - "name": "crm_opportunity_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_customers": { - "name": "crm_opportunity_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_followups": { - "name": "crm_opportunity_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_attachments": { - "name": "crm_quotation_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_customers": { - "name": "crm_quotation_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_followups": { - "name": "crm_quotation_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_items": { - "name": "crm_quotation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "item_number": { - "name": "item_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "unit": { - "name": "unit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unit_price": { - "name": "unit_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_price": { - "name": "total_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topic_items": { - "name": "crm_quotation_topic_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_id": { - "name": "topic_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topics": { - "name": "crm_quotation_topics", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_type": { - "name": "topic_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotations": { - "name": "crm_quotations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "quotation_date": { - "name": "quotation_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "valid_until": { - "name": "valid_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "quotation_type": { - "name": "quotation_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attention": { - "name": "attention", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference": { - "name": "reference", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "revision": { - "name": "revision", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "parent_quotation_id": { - "name": "parent_quotation_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revision_remark": { - "name": "revision_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "exchange_rate": { - "name": "exchange_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "subtotal": { - "name": "subtotal", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tax_amount": { - "name": "tax_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_amount": { - "name": "total_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "salesman_id": { - "name": "salesman_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_sent": { - "name": "is_sent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sent_via": { - "name": "sent_via", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "approved_artifact_id": { - "name": "approved_artifact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_pdf_url": { - "name": "approved_pdf_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_snapshot": { - "name": "approved_snapshot", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "approved_template_version_id": { - "name": "approved_template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "accepted_at": { - "name": "accepted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejected_at": { - "name": "rejected_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejection_reason": { - "name": "rejection_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_quotations_org_code_idx": { - "name": "crm_quotations_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_report_definitions": { - "name": "crm_report_definitions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "crm_report_definitions_org_code_idx": { - "name": "crm_report_definitions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_role_profiles": { - "name": "crm_role_profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "product_scope_mode": { - "name": "product_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "ownership_scope": { - "name": "ownership_scope", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'own'" - }, - "approval_authority": { - "name": "approval_authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_role_profiles_org_code_idx": { - "name": "crm_role_profiles_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_user_role_assignments": { - "name": "crm_user_role_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_profile_id": { - "name": "role_profile_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_mode": { - "name": "product_type_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_user_role_assignments_org_user_role_idx": { - "name": "crm_user_role_assignments_org_user_role_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role_profile_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.document_sequences": { - "name": "document_sequences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "period": { - "name": "period", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_number": { - "name": "current_number", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "padding_length": { - "name": "padding_length", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_sequences_org_doc_period_branch_idx": { - "name": "document_sequences_org_doc_period_branch_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "period", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "business_role": { - "name": "business_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sales_support'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.ms_options": { - "name": "ms_options", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "label": { - "name": "label", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "parent_id": { - "name": "parent_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "ms_options_org_category_code_idx": { - "name": "ms_options_org_category_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tr_audit_logs": { - "name": "tr_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "before_data": { - "name": "before_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after_data": { - "name": "after_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "system_role": { - "name": "system_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0009_snapshot.json b/drizzle/meta/0009_snapshot.json deleted file mode 100644 index 83839c9..0000000 --- a/drizzle/meta/0009_snapshot.json +++ /dev/null @@ -1,5757 +0,0 @@ -{ - "id": "feac04da-e5b6-4e63-926a-15526b1de66f", - "prevId": "61cab7a1-31a8-47e2-b563-e6c9dc313f32", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.app_notification_deliveries": { - "name": "app_notification_deliveries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "notification_id": { - "name": "notification_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_address": { - "name": "recipient_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_dispatches": { - "name": "app_notification_dispatches", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_id": { - "name": "event_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_key": { - "name": "provider_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "recipient_to": { - "name": "recipient_to", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "recipient_cc": { - "name": "recipient_cc", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "recipient_bcc": { - "name": "recipient_bcc", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "reply_to": { - "name": "reply_to", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subject": { - "name": "subject", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_text": { - "name": "body_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_html": { - "name": "body_html", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attachments": { - "name": "attachments", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "recipient_address": { - "name": "recipient_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "retry_count": { - "name": "retry_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "max_retry_count": { - "name": "max_retry_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "last_attempt_at": { - "name": "last_attempt_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notification_dispatches_org_event_channel_recipient_idx": { - "name": "app_notification_dispatches_org_event_channel_recipient_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "channel", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "recipient_address", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_events": { - "name": "app_notification_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "actor_user_id": { - "name": "actor_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "last_error": { - "name": "last_error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notification_events_org_dedupe_idx": { - "name": "app_notification_events_org_dedupe_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notification_templates": { - "name": "app_notification_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "channel": { - "name": "channel", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "subject_template": { - "name": "subject_template", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "title_template": { - "name": "title_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_template": { - "name": "body_template", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body_format": { - "name": "body_format", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'plain'" - }, - "link_template": { - "name": "link_template", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "language": { - "name": "language", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'th'" - }, - "variables": { - "name": "variables", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "app_notification_templates_org_event_channel_idx": { - "name": "app_notification_templates_org_event_channel_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "channel", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.app_notifications": { - "name": "app_notifications", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "event_id": { - "name": "event_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "body": { - "name": "body", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "link_url": { - "name": "link_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "severity": { - "name": "severity", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'info'" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'unread'" - }, - "read_at": { - "name": "read_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "archived_at": { - "name": "archived_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "app_notifications_recipient_event_idx": { - "name": "app_notifications_recipient_event_idx", - "columns": [ - { - "expression": "recipient_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "event_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_actions": { - "name": "crm_approval_actions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_request_id": { - "name": "approval_request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "acted_by": { - "name": "acted_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "acted_at": { - "name": "acted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_escalation_policies": { - "name": "crm_approval_escalation_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "trigger_after_hours": { - "name": "trigger_after_hours", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "target_type": { - "name": "target_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "target_value": { - "name": "target_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_matrices": { - "name": "crm_approval_matrices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "min_amount": { - "name": "min_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "max_amount": { - "name": "max_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 100 - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_reminder_policies": { - "name": "crm_approval_reminder_policies", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "sla_hours": { - "name": "sla_hours", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 24 - }, - "reminder_offsets_hours": { - "name": "reminder_offsets_hours", - "type": "integer[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "calendar_mode": { - "name": "calendar_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'calendar_days'" - }, - "timeout_action": { - "name": "timeout_action", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_approval_reminder_policies_workflow_step_idx": { - "name": "crm_approval_reminder_policies_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_requests": { - "name": "crm_approval_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_step": { - "name": "current_step", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "current_step_started_at": { - "name": "current_step_started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_by": { - "name": "requested_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_steps": { - "name": "crm_approval_steps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workflow_id": { - "name": "workflow_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_code": { - "name": "role_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "approval_mode": { - "name": "approval_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sequential'" - }, - "is_required": { - "name": "is_required", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "sla_hours": { - "name": "sla_hours", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 24 - }, - "calendar_mode": { - "name": "calendar_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'calendar_days'" - }, - "timeout_action": { - "name": "timeout_action", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_steps_workflow_step_idx": { - "name": "crm_approval_steps_workflow_step_idx", - "columns": [ - { - "expression": "workflow_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_approval_workflows": { - "name": "crm_approval_workflows", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_approval_workflows_org_code_idx": { - "name": "crm_approval_workflows_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_contact_shares": { - "name": "crm_contact_shares", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_to_user_id": { - "name": "shared_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_by_user_id": { - "name": "shared_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "shared_at": { - "name": "shared_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_contact_shares_org_contact_shared_user_idx": { - "name": "crm_contact_shares_org_contact_shared_user_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "contact_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "shared_to_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_contacts": { - "name": "crm_customer_contacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "position": { - "name": "position", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "department": { - "name": "department", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "mobile": { - "name": "mobile", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customer_owner_history": { - "name": "crm_customer_owner_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "old_owner_user_id": { - "name": "old_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "new_owner_user_id": { - "name": "new_owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "changed_by": { - "name": "changed_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "changed_at": { - "name": "changed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_customers": { - "name": "crm_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "abbr": { - "name": "abbr", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_id": { - "name": "tax_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_type": { - "name": "customer_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_status": { - "name": "customer_status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address": { - "name": "address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "province": { - "name": "province", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "district": { - "name": "district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sub_district": { - "name": "sub_district", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "phone": { - "name": "phone", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "fax": { - "name": "fax", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "website": { - "name": "website", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_group": { - "name": "customer_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_sub_group": { - "name": "customer_sub_group", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_user_id": { - "name": "owner_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_at": { - "name": "owner_assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "owner_assigned_by": { - "name": "owner_assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_customers_org_code_idx": { - "name": "crm_customers_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_artifacts": { - "name": "crm_document_artifacts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "artifact_type": { - "name": "artifact_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content_type": { - "name": "content_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checksum": { - "name": "checksum", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "generated_by": { - "name": "generated_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "generated_at": { - "name": "generated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "locked_by": { - "name": "locked_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "voided_at": { - "name": "voided_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "voided_by": { - "name": "voided_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "void_reason": { - "name": "void_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_libraries": { - "name": "crm_document_libraries", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "brand": { - "name": "brand", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "language": { - "name": "language", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_libraries_org_code_idx": { - "name": "crm_document_libraries_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_library_versions": { - "name": "crm_document_library_versions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "library_id": { - "name": "library_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "checksum": { - "name": "checksum", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "page_count": { - "name": "page_count", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'draft'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "published_at": { - "name": "published_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "published_by": { - "name": "published_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "archived_at": { - "name": "archived_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "archived_by": { - "name": "archived_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_library_versions_library_version_idx": { - "name": "crm_document_library_versions_library_version_idx", - "columns": [ - { - "expression": "library_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_mappings": { - "name": "crm_document_template_mappings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_version_id": { - "name": "template_version_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "placeholder_key": { - "name": "placeholder_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_path": { - "name": "source_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "data_type": { - "name": "data_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sheet_name": { - "name": "sheet_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "default_value": { - "name": "default_value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_mappings_version_placeholder_idx": { - "name": "crm_document_template_mappings_version_placeholder_idx", - "columns": [ - { - "expression": "template_version_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "placeholder_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_table_columns": { - "name": "crm_document_template_table_columns", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mapping_id": { - "name": "mapping_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_name": { - "name": "column_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source_field": { - "name": "source_field", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "column_letter": { - "name": "column_letter", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "format_mask": { - "name": "format_mask", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_document_template_table_columns_mapping_name_idx": { - "name": "crm_document_template_table_columns_mapping_name_idx", - "columns": [ - { - "expression": "mapping_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "column_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_template_versions": { - "name": "crm_document_template_versions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_id": { - "name": "template_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "schema_json": { - "name": "schema_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "metadata_json": { - "name": "metadata_json", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "preview_image_url": { - "name": "preview_image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_template_versions_template_version_idx": { - "name": "crm_document_template_versions_template_version_idx", - "columns": [ - { - "expression": "template_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_document_templates": { - "name": "crm_document_templates", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "template_name": { - "name": "template_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_document_templates_org_doc_product_file_name_idx": { - "name": "crm_document_templates_org_doc_product_file_name_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "product_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "file_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "template_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_leads": { - "name": "crm_leads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "awareness_id": { - "name": "awareness_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'new_job'" - }, - "followup_status": { - "name": "followup_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "owner_marketing_user_id": { - "name": "owner_marketing_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_sales_owner_id": { - "name": "assigned_sales_owner_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_leads_org_code_idx": { - "name": "crm_leads_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunities": { - "name": "crm_opportunities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lead_id": { - "name": "lead_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "requirement": { - "name": "requirement", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "outcome_status": { - "name": "outcome_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'open'" - }, - "priority": { - "name": "priority", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "lead_channel": { - "name": "lead_channel", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "estimated_value": { - "name": "estimated_value", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "expected_close_date": { - "name": "expected_close_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "pipeline_stage": { - "name": "pipeline_stage", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'lead'" - }, - "closed_at": { - "name": "closed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_won_at": { - "name": "closed_won_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_lost_at": { - "name": "closed_lost_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "closed_by_user_id": { - "name": "closed_by_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_number": { - "name": "po_number", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "po_date": { - "name": "po_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "po_amount": { - "name": "po_amount", - "type": "double precision", - "primaryKey": false, - "notNull": false - }, - "po_currency": { - "name": "po_currency", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_reason": { - "name": "lost_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_detail": { - "name": "lost_detail", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "cancel_reason": { - "name": "cancel_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "no_quotation_reason": { - "name": "no_quotation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_to_user_id": { - "name": "assigned_to_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "assignment_remark": { - "name": "assignment_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_opportunities_org_code_idx": { - "name": "crm_opportunities_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_attachments": { - "name": "crm_opportunity_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_provider": { - "name": "storage_provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "storage_key": { - "name": "storage_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_customers": { - "name": "crm_opportunity_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_opportunity_followups": { - "name": "crm_opportunity_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_attachments": { - "name": "crm_quotation_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_name": { - "name": "file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "original_file_name": { - "name": "original_file_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_path": { - "name": "file_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "file_size": { - "name": "file_size", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_type": { - "name": "file_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "uploaded_at": { - "name": "uploaded_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "uploaded_by": { - "name": "uploaded_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_customers": { - "name": "crm_quotation_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "remark": { - "name": "remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_followups": { - "name": "crm_quotation_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "followup_date": { - "name": "followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "followup_type": { - "name": "followup_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "next_followup_date": { - "name": "next_followup_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "next_action": { - "name": "next_action", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_items": { - "name": "crm_quotation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "item_number": { - "name": "item_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "unit": { - "name": "unit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unit_price": { - "name": "unit_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_price": { - "name": "total_price", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topic_items": { - "name": "crm_quotation_topic_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_id": { - "name": "topic_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotation_topics": { - "name": "crm_quotation_topics", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "quotation_id": { - "name": "quotation_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "topic_type": { - "name": "topic_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_quotations": { - "name": "crm_quotations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "opportunity_id": { - "name": "opportunity_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact_id": { - "name": "contact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "quotation_date": { - "name": "quotation_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "valid_until": { - "name": "valid_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "quotation_type": { - "name": "quotation_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attention": { - "name": "attention", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reference": { - "name": "reference", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "notes": { - "name": "notes", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "revision": { - "name": "revision", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "parent_quotation_id": { - "name": "parent_quotation_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "revision_remark": { - "name": "revision_remark", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "exchange_rate": { - "name": "exchange_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "subtotal": { - "name": "subtotal", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount": { - "name": "discount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "discount_type": { - "name": "discount_type", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tax_rate": { - "name": "tax_rate", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tax_amount": { - "name": "tax_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_amount": { - "name": "total_amount", - "type": "double precision", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "chance_percent": { - "name": "chance_percent", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_hot_project": { - "name": "is_hot_project", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "competitor": { - "name": "competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "salesman_id": { - "name": "salesman_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_sent": { - "name": "is_sent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "sent_at": { - "name": "sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sent_via": { - "name": "sent_via", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "approved_artifact_id": { - "name": "approved_artifact_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_pdf_url": { - "name": "approved_pdf_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "approved_snapshot": { - "name": "approved_snapshot", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "approved_template_version_id": { - "name": "approved_template_version_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "accepted_at": { - "name": "accepted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejected_at": { - "name": "rejected_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "rejection_reason": { - "name": "rejection_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_quotations_org_code_idx": { - "name": "crm_quotations_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_report_definitions": { - "name": "crm_report_definitions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "crm_report_definitions_org_code_idx": { - "name": "crm_report_definitions_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_role_profiles": { - "name": "crm_role_profiles", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "product_scope_mode": { - "name": "product_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'assigned'" - }, - "ownership_scope": { - "name": "ownership_scope", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'own'" - }, - "approval_authority": { - "name": "approval_authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "is_system": { - "name": "is_system", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_by": { - "name": "updated_by", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "crm_role_profiles_org_code_idx": { - "name": "crm_role_profiles_org_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.crm_user_role_assignments": { - "name": "crm_user_role_assignments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_profile_id": { - "name": "role_profile_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_scope_mode": { - "name": "branch_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_mode": { - "name": "product_type_scope_mode", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'inherit'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "assigned_by": { - "name": "assigned_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "assigned_at": { - "name": "assigned_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "crm_user_role_assignments_org_user_role_idx": { - "name": "crm_user_role_assignments_org_user_role_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role_profile_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.document_sequences": { - "name": "document_sequences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "product_type": { - "name": "product_type", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'all'" - }, - "document_type": { - "name": "document_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "prefix": { - "name": "prefix", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "period": { - "name": "period", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "current_number": { - "name": "current_number", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "padding_length": { - "name": "padding_length", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "format": { - "name": "format", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'{prefix}{period}-{running}'" - }, - "reset_policy": { - "name": "reset_policy", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'period'" - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_sequences_org_branch_product_doc_period_idx": { - "name": "document_sequences_org_branch_product_doc_period_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "product_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "document_type", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "period", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.memberships": { - "name": "memberships", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "business_role": { - "name": "business_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'sales_support'" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "branch_scope_ids": { - "name": "branch_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "product_type_scope_ids": { - "name": "product_type_scope_ids", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.ms_options": { - "name": "ms_options", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "label": { - "name": "label", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "parent_id": { - "name": "parent_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "ms_options_org_category_code_idx": { - "name": "ms_options_org_category_code_idx", - "columns": [ - { - "expression": "organization_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.organizations": { - "name": "organizations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "slug": { - "name": "slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "image_url": { - "name": "image_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "plan": { - "name": "plan", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "created_by": { - "name": "created_by", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "organizations_slug_idx": { - "name": "organizations_slug_idx", - "columns": [ - { - "expression": "slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.products": { - "name": "products", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "integer", - "primaryKey": true, - "notNull": true, - "identity": { - "type": "always", - "name": "products_id_seq", - "schema": "public", - "increment": "1", - "startWith": "1", - "minValue": "1", - "maxValue": "2147483647", - "cache": "1", - "cycle": false - } - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "photo_url": { - "name": "photo_url", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "double precision", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tr_audit_logs": { - "name": "tr_audit_logs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch_id": { - "name": "branch_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_type": { - "name": "entity_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "entity_id": { - "name": "entity_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "before_data": { - "name": "before_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "after_data": { - "name": "after_data", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "system_role": { - "name": "system_role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'user'" - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_organization_id": { - "name": "active_organization_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "users_email_idx": { - "name": "users_email_idx", - "columns": [ - { - "expression": "email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 81902e4..b5a9599 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -5,71 +5,8 @@ { "idx": 0, "version": "7", - "when": 1782359607850, - "tag": "0000_hard_butterfly", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1782381033930, - "tag": "0001_lazy_otto_octavius", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1782604800000, - "tag": "0002_calm_approval_matrix", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1782691200000, - "tag": "0003_workflow_builder_foundation", - "breakpoints": true - }, - { - "idx": 4, - "version": "7", - "when": 1782455991734, - "tag": "0004_unusual_hairball", - "breakpoints": true - }, - { - "idx": 5, - "version": "7", - "when": 1782464526434, - "tag": "0005_furry_maelstrom", - "breakpoints": true - }, - { - "idx": 6, - "version": "7", - "when": 1782749787685, - "tag": "0006_lazy_shiver_man", - "breakpoints": true - }, - { - "idx": 7, - "version": "7", - "when": 1782910000000, - "tag": "0007_document_library_foundation", - "breakpoints": true - }, - { - "idx": 8, - "version": "7", - "when": 1782913600000, - "tag": "0008_document_sequence_scope_refactor", - "breakpoints": true - }, - { - "idx": 9, - "version": "7", - "when": 1782815675836, - "tag": "0009_stale_next_avengers", + "when": 1782833951256, + "tag": "0000_short_the_executioner", "breakpoints": true } ] diff --git a/next-env.d.ts b/next-env.d.ts index 9edff1c..c4b7818 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/types/routes.d.ts"; +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/plans/task-p.7.2.1.md b/plans/task-p.7.2.1.md new file mode 100644 index 0000000..07100c7 --- /dev/null +++ b/plans/task-p.7.2.1.md @@ -0,0 +1,327 @@ +# Amendment to Task P.7.1.2 – Working Documents & Official Documents UX + +## Design Revision + +Following the UX review, the document experience will be refined to better reflect the actual CRM business process. + +The terminology **Draft PDF** is too technical for end users and should not be the primary wording exposed in the UI. + +The new UX separates documents into three business levels. + +--- + +# Level 1 — Working Documents + +Purpose: + +Internal working documents used during quotation preparation. + +Source: + +Live quotation data. + +Characteristics: + +* Generated from current database values. +* Changes whenever quotation data changes. +* Used internally only. +* Not legally or commercially binding. +* Not intended for customer delivery. +* Not part of audit history. + +UI terminology: + +```text +Working Documents +``` + +Primary document: + +```text +Preview PDF +``` + +The UI should avoid exposing the technical term **Draft PDF**. + +Instead: + +```text +Preview PDF +``` + +or + +```text +Working Copy +``` + +may be displayed. + +Available actions: + +```text +Generate +Preview +``` + +No Download button is required unless business rules explicitly allow downloading internal working copies. + +--- + +# Level 2 — Official Documents + +Purpose: + +Business-approved immutable documents. + +Source: + +Approved Snapshot. + +Characteristics: + +* Generated only after approval. +* Immutable. +* Stored as document artifact. +* Used for audit. +* Used for revision history. +* Used as official company record. + +UI terminology: + +```text +Official Documents +``` + +Primary document: + +```text +Approved PDF +``` + +Available actions: + +```text +Preview +Download +``` + +No Generate button should appear here because approval already created the official document. + +--- + +# Level 3 — Customer Package + +Purpose: + +Deliverable package sent to customers. + +Source: + +Approved PDF + +plus + +Document Library appendices. + +Example: + +```text +Approved PDF + ++ + +SLA + ++ + +Warranty + ++ + +Datasheet + ++ + +Drawing +``` + +Characteristics: + +* Generated after document assembly. +* Built from official documents. +* Represents exactly what customers receive. +* May be regenerated if append documents change. + +Available actions: + +```text +Generate Package + +Preview Package + +Download Package + +Send Package (future) +``` + +--- + +# Relationship Between Document Types + +Business flow becomes: + +```text +Quotation + +↓ + +Working Documents + +↓ + +Approval + +↓ + +Official Documents + +↓ + +Customer Package + +↓ + +Email Customer +``` + +This hierarchy should be reflected visually. + +--- + +# Documents Tab Layout + +Replace the previous layout with: + +```text +Documents + +──────────────────────── + +Working Documents + +Preview PDF + +[Generate] + +[Preview] + +──────────────────────── + +Official Documents + +Approved PDF + +[Preview] + +[Download] + +──────────────────────── + +Customer Package + +Status + +Included Documents + +Warnings + +[Generate Package] + +[Preview Package] + +[Download Package] + +[Send Package] +``` + +The **Send Package** action remains disabled until P.7.2. + +--- + +# Customer Package Tab + +The dedicated Customer Package tab remains. + +It focuses on operational details: + +* Package status +* Included documents +* Assembly warnings +* Generated time +* Generated by +* Page count +* Checksum +* Generate / Regenerate +* Preview +* Download + +This tab is not responsible for previewing individual PDFs. + +--- + +# UX Rules + +Working Documents + +* Can always regenerate. +* Uses live quotation data. +* Intended for internal review. + +Official Documents + +* Never regenerate from this screen. +* Always read-only. +* Represents approved business record. + +Customer Package + +* Always assembled from Official Documents. +* Must never assemble from Working Documents. +* If no Approved PDF exists, package generation must fail with a business-readable message. + +--- + +# Business Rules + +Customer Package must always use: + +```text +Approved PDF + ++ + +Active Document Library files +``` + +Customer Package must never use: + +```text +Working Documents + +Preview PDF + +Draft runtime output +``` + +This guarantees that every package delivered to a customer is assembled from approved, auditable content. + +--- + +# Acceptance Criteria (Additional) + +* "Draft PDF" is no longer the primary UI terminology. +* Documents are clearly separated into Working Documents, Official Documents, and Customer Package. +* Customer Package assembly is based exclusively on Approved PDF. +* UI hierarchy reflects the CRM document lifecycle. +* The new terminology is reusable across future modules such as Purchase Order, Service Report, Inspection Report, and Work Order. diff --git a/scripts/seed-uat.ts b/scripts/seed-uat.ts index b2c54ce..39f64f3 100644 --- a/scripts/seed-uat.ts +++ b/scripts/seed-uat.ts @@ -1,7 +1,7 @@ -import { runNodeScript } from './lib/seed-utils.ts'; +import { runNodeScript } from "./lib/seed-utils.ts"; function main() { - runNodeScript('seed:uat:core', 'src/db/seeds/uat.seed.ts'); + runNodeScript("seed:uat:core", "src/db/seeds/uat.seed.ts"); } main(); diff --git a/src/db/seeds/foundation.seed.ts b/src/db/seeds/foundation.seed.ts index 7df2ba3..0c2c5b6 100644 --- a/src/db/seeds/foundation.seed.ts +++ b/src/db/seeds/foundation.seed.ts @@ -1576,7 +1576,7 @@ async function upsertDocumentSequencesForOrganizationV2( async function upsertApprovalWorkflowsForOrganization( sql: SqlClient, - organizationId: string, + organization: { id: string; createdBy: string }, ) { for (const workflow of APPROVAL_WORKFLOWS) { const [workflowRow] = await sql` @@ -1587,14 +1587,18 @@ async function upsertApprovalWorkflowsForOrganization( name, entity_type, is_active, + created_by, + updated_by, deleted_at ) values ( ${crypto.randomUUID()}, - ${organizationId}, + ${organization.id}, ${workflow.code}, ${workflow.name}, ${workflow.entityType}, ${true}, + ${organization.createdBy}, + ${organization.createdBy}, ${null} ) on conflict (organization_id, code) do update @@ -1602,6 +1606,7 @@ async function upsertApprovalWorkflowsForOrganization( name = excluded.name, entity_type = excluded.entity_type, is_active = excluded.is_active, + updated_by = excluded.updated_by, deleted_at = excluded.deleted_at, updated_at = now() returning id @@ -1620,7 +1625,7 @@ async function upsertApprovalWorkflowsForOrganization( deleted_at ) values ( ${crypto.randomUUID()}, - ${organizationId}, + ${organization.id}, ${workflowRow.id}, ${step.stepNumber}, ${step.roleCode}, @@ -2338,7 +2343,7 @@ async function main() { organization, branchRows, ); - await upsertApprovalWorkflowsForOrganization(sql, organization.id); + await upsertApprovalWorkflowsForOrganization(sql, organization); await upsertApprovalMatricesForOrganization(sql, organization); await upsertDocumentTemplatesForOrganization(sql, organization); await upsertDocumentLibraryForOrganization(sql, organization); diff --git a/src/db/seeds/system-organization.seed.ts b/src/db/seeds/system-organization.seed.ts index 30322be..b97b050 100644 --- a/src/db/seeds/system-organization.seed.ts +++ b/src/db/seeds/system-organization.seed.ts @@ -1,5 +1,9 @@ -import { getDefaultPermissions } from '../../lib/auth/rbac.ts'; -import { createSqlClient, deterministicId, type SqlClient } from '../../../scripts/lib/seed-utils.ts'; +import { getDefaultPermissions } from "../../lib/auth/rbac.ts"; +import { + createSqlClient, + deterministicId, + type SqlClient, +} from "../../../scripts/lib/seed-utils.ts"; type UserRow = { id: string; @@ -7,17 +11,19 @@ type UserRow = { }; const DEFAULT_ORGANIZATION = { - id: deterministicId('organization:alla-demo'), - name: 'ALLA Demo Organization', - slug: 'alla-demo', - membershipId: deterministicId('membership:alla-demo:super-admin') + id: deterministicId("organization:alla-demo"), + name: "ALLA Demo", + slug: "alla-demo", + membershipId: deterministicId("membership:alla-demo:super-admin"), }; async function resolveSuperAdmin(sql: SqlClient): Promise { const email = process.env.SUPER_ADMIN_EMAIL?.trim().toLowerCase(); if (!email) { - throw new Error('SUPER_ADMIN_EMAIL is required before running system organization seed.'); + throw new Error( + "SUPER_ADMIN_EMAIL is required before running system organization seed.", + ); } const [user] = await sql` @@ -28,7 +34,7 @@ async function resolveSuperAdmin(sql: SqlClient): Promise { `; if (!user) { - throw new Error('Super admin user not found. Run seed-super-admin first.'); + throw new Error("Super admin user not found. Run seed-super-admin first."); } return user; @@ -46,7 +52,7 @@ async function ensureOrganization(sql: SqlClient, superAdmin: UserRow) { ${DEFAULT_ORGANIZATION.id}, ${DEFAULT_ORGANIZATION.name}, ${DEFAULT_ORGANIZATION.slug}, - ${'enterprise'}, + ${"enterprise"}, ${superAdmin.id} ) on conflict (slug) do update @@ -56,7 +62,7 @@ async function ensureOrganization(sql: SqlClient, superAdmin: UserRow) { updated_at = now() `; - const membershipPermissions = getDefaultPermissions('admin', 'crm_admin'); + const membershipPermissions = getDefaultPermissions("admin", "crm_admin"); const [existingMembership] = await sql<{ id: string }[]>` select id from memberships @@ -69,8 +75,8 @@ async function ensureOrganization(sql: SqlClient, superAdmin: UserRow) { await sql` update memberships set - role = ${'admin'}, - business_role = ${'crm_admin'}, + role = ${"admin"}, + business_role = ${"crm_admin"}, permissions = ${sql.array(membershipPermissions)}, updated_at = now() where id = ${existingMembership.id} @@ -90,8 +96,8 @@ async function ensureOrganization(sql: SqlClient, superAdmin: UserRow) { ${DEFAULT_ORGANIZATION.membershipId}, ${superAdmin.id}, ${DEFAULT_ORGANIZATION.id}, - ${'admin'}, - ${'crm_admin'}, + ${"admin"}, + ${"crm_admin"}, ${sql.array(membershipPermissions)}, ${sql.array([])}, ${sql.array([])} @@ -122,8 +128,8 @@ async function main() { main().catch((error) => { console.error( - '[seed:system-org] Failed:', - error instanceof Error ? error.message : String(error) + "[seed:system-org] Failed:", + error instanceof Error ? error.message : String(error), ); process.exitCode = 1; }); diff --git a/src/features/foundation/document-library/types.ts b/src/features/foundation/document-library/types.ts index 2924ccb..d4ee42d 100644 --- a/src/features/foundation/document-library/types.ts +++ b/src/features/foundation/document-library/types.ts @@ -1,36 +1,38 @@ export const DOCUMENT_LIBRARY_TYPES = [ - 'sla', - 'warranty', - 'terms_conditions', - 'company_profile', - 'datasheet', - 'drawing', - 'certificate', - 'appendix', - 'safety_document', - 'installation_manual' + "sla", + "warranty", + "terms_conditions", + "company_profile", + "datasheet", + "drawing", + "certificate", + "appendix", + "safety_document", + "installation_manual", ] as const; -export const DOCUMENT_LIBRARY_BRANDS = ['alla', 'onvalla', 'generic'] as const; -export const DOCUMENT_LIBRARY_LANGUAGES = ['th', 'en'] as const; +export const DOCUMENT_LIBRARY_BRANDS = ["alla", "onvalla", "generic"] as const; +export const DOCUMENT_LIBRARY_LANGUAGES = ["th", "en"] as const; export const DOCUMENT_LIBRARY_PRODUCT_TYPES = [ - 'all', - 'crane', - 'dock_door', - 'solar', - 'service' + "all", + "crane", + "dock_door", + "solar", + "service", ] as const; export const DOCUMENT_LIBRARY_VERSION_STATUSES = [ - 'draft', - 'published', - 'active', - 'archived' + "draft", + "published", + "active", + "archived", ] as const; export type DocumentLibraryType = (typeof DOCUMENT_LIBRARY_TYPES)[number]; export type DocumentLibraryBrand = (typeof DOCUMENT_LIBRARY_BRANDS)[number]; -export type DocumentLibraryLanguage = (typeof DOCUMENT_LIBRARY_LANGUAGES)[number]; -export type DocumentLibraryProductType = (typeof DOCUMENT_LIBRARY_PRODUCT_TYPES)[number]; +export type DocumentLibraryLanguage = + (typeof DOCUMENT_LIBRARY_LANGUAGES)[number]; +export type DocumentLibraryProductType = + (typeof DOCUMENT_LIBRARY_PRODUCT_TYPES)[number]; export type DocumentLibraryVersionStatus = (typeof DOCUMENT_LIBRARY_VERSION_STATUSES)[number]; @@ -44,7 +46,7 @@ export interface DocumentLibraryRecord { brand: DocumentLibraryBrand; language: DocumentLibraryLanguage; productType: DocumentLibraryProductType; - status: 'active' | 'inactive'; + status: "active" | "inactive"; isActive: boolean; createdBy: string; updatedBy: string; @@ -91,7 +93,7 @@ export interface DocumentLibraryFilters { brand?: DocumentLibraryBrand; language?: DocumentLibraryLanguage; productType?: DocumentLibraryProductType; - isActive?: 'true' | 'false'; + isActive?: "true" | "false"; } export interface DocumentLibraryMutationPayload { diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/017e27ad-84c4-4c04-98af-a41d3bbc07a0/sla-alla-crane-th-v1.1.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/017e27ad-84c4-4c04-98af-a41d3bbc07a0/sla-alla-crane-th-v1.1.pdf new file mode 100644 index 0000000..26dc68a Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/017e27ad-84c4-4c04-98af-a41d3bbc07a0/sla-alla-crane-th-v1.1.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/2c041346-7d76-4b64-9da9-0e4bb36fc7b1/sla-alla-crane-th-v1.0.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/2c041346-7d76-4b64-9da9-0e4bb36fc7b1/sla-alla-crane-th-v1.0.pdf new file mode 100644 index 0000000..752433a Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/2c041346-7d76-4b64-9da9-0e4bb36fc7b1/sla-alla-crane-th-v1.0.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/6dc39768-b910-485a-8bfb-5d97ad216c67/SLA-ALLA-TH.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/6dc39768-b910-485a-8bfb-5d97ad216c67/SLA-ALLA-TH.pdf new file mode 100644 index 0000000..c6c03b8 Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/287924c6-0a9f-414e-af4c-2e4e7b924b67/6dc39768-b910-485a-8bfb-5d97ad216c67/SLA-ALLA-TH.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/71dc92b7-0d29-4e58-a24a-f1cc2ae3ee58/bf887071-7414-496e-9201-49d70ea36d50/warranty-onvalla-dock-door-en-v1.0.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/71dc92b7-0d29-4e58-a24a-f1cc2ae3ee58/bf887071-7414-496e-9201-49d70ea36d50/warranty-onvalla-dock-door-en-v1.0.pdf new file mode 100644 index 0000000..f854cd8 Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/71dc92b7-0d29-4e58-a24a-f1cc2ae3ee58/bf887071-7414-496e-9201-49d70ea36d50/warranty-onvalla-dock-door-en-v1.0.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/d5b7b7a1-d5a6-4eb4-9a56-4b01829c2cf3/23dbd03d-b6fb-4eab-90b2-5d176a48976f/company-profile-alla-all-th-2026.01.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/d5b7b7a1-d5a6-4eb4-9a56-4b01829c2cf3/23dbd03d-b6fb-4eab-90b2-5d176a48976f/company-profile-alla-all-th-2026.01.pdf new file mode 100644 index 0000000..bbacb3b Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/d5b7b7a1-d5a6-4eb4-9a56-4b01829c2cf3/23dbd03d-b6fb-4eab-90b2-5d176a48976f/company-profile-alla-all-th-2026.01.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/d5b7b7a1-d5a6-4eb4-9a56-4b01829c2cf3/81d34d28-fcc7-45c9-aee5-744baca9a7cd/company-profile-alla-all-th-2025.12.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/d5b7b7a1-d5a6-4eb4-9a56-4b01829c2cf3/81d34d28-fcc7-45c9-aee5-744baca9a7cd/company-profile-alla-all-th-2025.12.pdf new file mode 100644 index 0000000..668f371 Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/document-library/d5b7b7a1-d5a6-4eb4-9a56-4b01829c2cf3/81d34d28-fcc7-45c9-aee5-744baca9a7cd/company-profile-alla-all-th-2025.12.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/02d6b4b3-b11c-4a6e-9518-1258c8fcf4a1-CRA2606-1107-assembled.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/02d6b4b3-b11c-4a6e-9518-1258c8fcf4a1-CRA2606-1107-assembled.pdf new file mode 100644 index 0000000..8ee4030 Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/02d6b4b3-b11c-4a6e-9518-1258c8fcf4a1-CRA2606-1107-assembled.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/16ea6fca-ef77-4cb9-8079-0b8dbcdbff57-CRA2606-1121-assembled.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/16ea6fca-ef77-4cb9-8079-0b8dbcdbff57-CRA2606-1121-assembled.pdf new file mode 100644 index 0000000..7400907 Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/16ea6fca-ef77-4cb9-8079-0b8dbcdbff57-CRA2606-1121-assembled.pdf differ diff --git a/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/c0a3c490-30ae-4c77-8f80-ec9328eeb66e-CRA2606-1107-assembled.pdf b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/c0a3c490-30ae-4c77-8f80-ec9328eeb66e-CRA2606-1107-assembled.pdf new file mode 100644 index 0000000..39073c6 Binary files /dev/null and b/storage/organizations/daf796fc-4588-5240-a27e-9bfef0739658/quotations/assembled/c0a3c490-30ae-4c77-8f80-ec9328eeb66e-CRA2606-1107-assembled.pdf differ