From ed28ff6b5018bb8ff6aac3e0628e3f3a1d1c94f2 Mon Sep 17 00:00:00 2001 From: phaichayon Date: Wed, 1 Jul 2026 13:57:16 +0700 Subject: [PATCH] task-d.6.2 --- artifacts/pdf-audit/summary.json | 2 +- artifacts/pdf-audit/summary.md | 2 +- docs/implementation/pdf-audit-report.json | 2 +- docs/implementation/pdf-audit-report.md | 2 +- ...ion-prefill-project-timeline-2026-07-01.md | 60 + ...rtunity_quotation_timeline_hot_project.sql | 11 + drizzle/0003_curious_wild_child.sql | 10 + .../meta/0003_snapshot.json | 2759 ++++++++--- drizzle/meta/_journal.json | 16 +- drizzle_bk/0000_icy_lizard.sql | 48 - drizzle_bk/0001_orange_mandarin.sql | 46 - drizzle_bk/0002_plain_anthem.sql | 52 - drizzle_bk/0003_blushing_bruce_banner.sql | 50 - drizzle_bk/0004_worthless_ender_wiggin.sql | 138 - drizzle_bk/0005_numerous_blob.sql | 57 - drizzle_bk/0006_worried_mordo.sql | 66 - drizzle_bk/0007_luxuriant_malice.sql | 4 - drizzle_bk/0008_clean_justin_hammer.sql | 5 - drizzle_bk/0009_lazy_shard.sql | 30 - drizzle_bk/0010_calm_wendell_rand.sql | 13 - drizzle_bk/0011_brief_hobgoblin.sql | 2 - drizzle_bk/0011_goofy_the_hood.sql | 1 - drizzle_bk/0012_odd_fat_cobra.sql | 31 - drizzle_bk/0012_simple_bucky.sql | 1 - drizzle_bk/0013_great_nicolaos.sql | 23 - drizzle_bk/0014_bored_valkyrie.sql | 19 - drizzle_bk/0014_crm_user_role_assignments.sql | 20 - ...0015_customer_ownership_contact_shares.sql | 35 - .../0016_won_lost_lifecycle_governance.sql | 30 - drizzle_bk/0017_short_swordsman.sql | 61 - drizzle_bk/0018_report_foundation.sql | 15 - drizzle_bk/0019_sleepy_ultron.sql | 14 - drizzle_bk/0020_lead_foundation_schema.sql | 24 - drizzle_bk/0021_worried_nebula.sql | 23 - .../0022_lead_assignment_foundation.sql | 9 - drizzle_bk/0023_yellow_carlie_cooper.sql | 8 - drizzle_bk/meta/0000_snapshot.json | 331 -- drizzle_bk/meta/0001_snapshot.json | 653 --- drizzle_bk/meta/0002_snapshot.json | 978 ---- drizzle_bk/meta/0003_snapshot.json | 1290 ----- drizzle_bk/meta/0004_snapshot.json | 2133 --------- drizzle_bk/meta/0005_snapshot.json | 2500 ---------- drizzle_bk/meta/0006_snapshot.json | 2971 ------------ drizzle_bk/meta/0007_snapshot.json | 2995 ------------ drizzle_bk/meta/0008_snapshot.json | 3019 ------------ drizzle_bk/meta/0009_snapshot.json | 3192 ------------- drizzle_bk/meta/0010_snapshot.json | 3267 ------------- drizzle_bk/meta/0011_snapshot.json | 3273 ------------- drizzle_bk/meta/0012_snapshot.json | 3280 ------------- drizzle_bk/meta/0013_snapshot.json | 3440 -------------- drizzle_bk/meta/0014_snapshot.json | 3580 -------------- drizzle_bk/meta/0017_snapshot.json | 3963 ---------------- drizzle_bk/meta/0019_snapshot.json | 4062 ---------------- drizzle_bk/meta/0021_snapshot.json | 4215 ----------------- drizzle_bk/meta/_journal.json | 174 - plans/task-d.6.2.md | 124 + src/app/api/crm/opportunities/[id]/route.ts | 11 +- src/app/api/crm/opportunities/route.ts | 4 +- src/db/schema.ts | 12 + .../crm/leads/components/lead-detail.tsx | 5 +- src/features/crm/opportunities/api/types.ts | 8 + .../components/opportunity-detail.tsx | 44 +- .../components/opportunity-form-sheet.tsx | 94 +- .../schemas/opportunity.schema.ts | 15 +- .../crm/opportunities/server/service.ts | 19 +- src/features/crm/quotations/api/types.ts | 14 + .../components/quotation-detail.tsx | 1458 +++--- .../components/quotation-form-sheet.tsx | 811 ++-- .../quotations/schemas/quotation.schema.ts | 100 +- src/features/crm/quotations/server/service.ts | 77 +- src/features/crm/shared/hot-project.ts | 63 + 71 files changed, 4137 insertions(+), 51727 deletions(-) create mode 100644 docs/implementation/task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md create mode 100644 drizzle/0002_opportunity_quotation_timeline_hot_project.sql create mode 100644 drizzle/0003_curious_wild_child.sql rename drizzle_bk/meta/0023_snapshot.json => drizzle/meta/0003_snapshot.json (72%) delete mode 100644 drizzle_bk/0000_icy_lizard.sql delete mode 100644 drizzle_bk/0001_orange_mandarin.sql delete mode 100644 drizzle_bk/0002_plain_anthem.sql delete mode 100644 drizzle_bk/0003_blushing_bruce_banner.sql delete mode 100644 drizzle_bk/0004_worthless_ender_wiggin.sql delete mode 100644 drizzle_bk/0005_numerous_blob.sql delete mode 100644 drizzle_bk/0006_worried_mordo.sql delete mode 100644 drizzle_bk/0007_luxuriant_malice.sql delete mode 100644 drizzle_bk/0008_clean_justin_hammer.sql delete mode 100644 drizzle_bk/0009_lazy_shard.sql delete mode 100644 drizzle_bk/0010_calm_wendell_rand.sql delete mode 100644 drizzle_bk/0011_brief_hobgoblin.sql delete mode 100644 drizzle_bk/0011_goofy_the_hood.sql delete mode 100644 drizzle_bk/0012_odd_fat_cobra.sql delete mode 100644 drizzle_bk/0012_simple_bucky.sql delete mode 100644 drizzle_bk/0013_great_nicolaos.sql delete mode 100644 drizzle_bk/0014_bored_valkyrie.sql delete mode 100644 drizzle_bk/0014_crm_user_role_assignments.sql delete mode 100644 drizzle_bk/0015_customer_ownership_contact_shares.sql delete mode 100644 drizzle_bk/0016_won_lost_lifecycle_governance.sql delete mode 100644 drizzle_bk/0017_short_swordsman.sql delete mode 100644 drizzle_bk/0018_report_foundation.sql delete mode 100644 drizzle_bk/0019_sleepy_ultron.sql delete mode 100644 drizzle_bk/0020_lead_foundation_schema.sql delete mode 100644 drizzle_bk/0021_worried_nebula.sql delete mode 100644 drizzle_bk/0022_lead_assignment_foundation.sql delete mode 100644 drizzle_bk/0023_yellow_carlie_cooper.sql delete mode 100644 drizzle_bk/meta/0000_snapshot.json delete mode 100644 drizzle_bk/meta/0001_snapshot.json delete mode 100644 drizzle_bk/meta/0002_snapshot.json delete mode 100644 drizzle_bk/meta/0003_snapshot.json delete mode 100644 drizzle_bk/meta/0004_snapshot.json delete mode 100644 drizzle_bk/meta/0005_snapshot.json delete mode 100644 drizzle_bk/meta/0006_snapshot.json delete mode 100644 drizzle_bk/meta/0007_snapshot.json delete mode 100644 drizzle_bk/meta/0008_snapshot.json delete mode 100644 drizzle_bk/meta/0009_snapshot.json delete mode 100644 drizzle_bk/meta/0010_snapshot.json delete mode 100644 drizzle_bk/meta/0011_snapshot.json delete mode 100644 drizzle_bk/meta/0012_snapshot.json delete mode 100644 drizzle_bk/meta/0013_snapshot.json delete mode 100644 drizzle_bk/meta/0014_snapshot.json delete mode 100644 drizzle_bk/meta/0017_snapshot.json delete mode 100644 drizzle_bk/meta/0019_snapshot.json delete mode 100644 drizzle_bk/meta/0021_snapshot.json delete mode 100644 drizzle_bk/meta/_journal.json create mode 100644 plans/task-d.6.2.md create mode 100644 src/features/crm/shared/hot-project.ts diff --git a/artifacts/pdf-audit/summary.json b/artifacts/pdf-audit/summary.json index 6ce7f9d..6006806 100644 --- a/artifacts/pdf-audit/summary.json +++ b/artifacts/pdf-audit/summary.json @@ -1,5 +1,5 @@ { - "generatedAt": "2026-07-01T02:01:56.976Z", + "generatedAt": "2026-07-01T04:26:29.390Z", "overallStatus": "PASS", "quotationCode": "CRA2606-1107", "artifacts": { diff --git a/artifacts/pdf-audit/summary.md b/artifacts/pdf-audit/summary.md index 990ee17..b204169 100644 --- a/artifacts/pdf-audit/summary.md +++ b/artifacts/pdf-audit/summary.md @@ -1,6 +1,6 @@ # PDF Integrity Summary -- Generated At: 2026-07-01T02:01:56.976Z +- Generated At: 2026-07-01T04:26:29.390Z - Overall Status: PASS - Quotation Code: CRA2606-1107 diff --git a/docs/implementation/pdf-audit-report.json b/docs/implementation/pdf-audit-report.json index 243b2cf..72c5311 100644 --- a/docs/implementation/pdf-audit-report.json +++ b/docs/implementation/pdf-audit-report.json @@ -1,5 +1,5 @@ { - "generatedAt": "2026-07-01T02:01:55.746Z", + "generatedAt": "2026-07-01T04:26:26.164Z", "overallStatus": "PASS", "quotationCode": "CRA2606-1107", "expectedFixtureCode": "QT-H5-AUDIT", diff --git a/docs/implementation/pdf-audit-report.md b/docs/implementation/pdf-audit-report.md index eb898b6..6c1d64a 100644 --- a/docs/implementation/pdf-audit-report.md +++ b/docs/implementation/pdf-audit-report.md @@ -1,6 +1,6 @@ # PDF Audit Report -- Generated At: 2026-07-01T02:01:55.746Z +- Generated At: 2026-07-01T04:26:26.164Z - Overall Status: PASS - Quotation Code: CRA2606-1107 - Template: ALLA Demo Quotation Standard v1.0 diff --git a/docs/implementation/task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md b/docs/implementation/task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md new file mode 100644 index 0000000..0920a02 --- /dev/null +++ b/docs/implementation/task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md @@ -0,0 +1,60 @@ +# Task D.6.2 Implementation Report - 2026-07-01 + +## Scope +- Prefill quotation creation from opportunity detail so users do not need to reselect the same opportunity. +- Add `Project Close Date` and `Delivery Date` to both opportunity and quotation flows. +- Enforce backend-supported hot-project auto suggestion with same-session manual override support. + +## Review Summary +Reviewed before implementation: +- [AGENTS.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/AGENTS.md) +- [plans/task-d.6.2.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/plans/task-d.6.2.md) +- [docs/standards/project-foundations.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/standards/project-foundations.md) +- [docs/standards/architecture-rules.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/standards/architecture-rules.md) +- [docs/standards/ui-ux-rules.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/standards/ui-ux-rules.md) +- [docs/standards/task-review-checklist.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/standards/task-review-checklist.md) +- [docs/business/crm-terminology.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/business/crm-terminology.md) +- [docs/adr/0018-lead-enquiry-domain-separation.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/adr/0018-lead-enquiry-domain-separation.md) +- [docs/implementation/task-d.6-crm-activity-foundation-audit-log-separation-2026-07-01.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/implementation/task-d.6-crm-activity-foundation-audit-log-separation-2026-07-01.md) +- [docs/implementation/task-d.6.1-lead-create-form-ux-default-rules-2026-07-01.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/implementation/task-d.6.1-lead-create-form-ux-default-rules-2026-07-01.md) + +## Implementation Summary +- Added shared hot-project decision logic in [hot-project.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/shared/hot-project.ts) so frontend and backend use the same `projectCloseDate <= current date + 3 months` rule. +- Extended `crm_opportunities` and `crm_quotations` with `project_close_date`, `delivery_date`, `hot_project_auto_suggested`, and `hot_project_manually_overridden`, plus migration [0002_opportunity_quotation_timeline_hot_project.sql](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/drizzle/0002_opportunity_quotation_timeline_hot_project.sql). +- Updated DTOs, Zod schemas, and server services so create/update flows accept the new date fields, validate `YYYY-MM-DD`, auto-suggest hot-project state, and preserve manual override flags. +- Updated opportunity form to show calendar-based `Project Close Date` and `Delivery Date`, and to stop re-forcing the hot-project checkbox after the user manually changes it in the same session. +- Rebuilt quotation form flow to support: + - opening from opportunity detail with prefilled opportunity/customer/contact/project data + - timeline field carry-forward (`projectCloseDate`, `deliveryDate`) + - hot-project auto suggestion with manual override preservation + - touched-field protection so post-open prefills do not overwrite user edits +- Updated opportunity detail to pass quotation prefill context and display new timeline values. + +## Files Changed +- [src/db/schema.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/db/schema.ts) +- [drizzle/0002_opportunity_quotation_timeline_hot_project.sql](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/drizzle/0002_opportunity_quotation_timeline_hot_project.sql) +- [drizzle/meta/_journal.json](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/drizzle/meta/_journal.json) +- [src/features/crm/shared/hot-project.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/shared/hot-project.ts) +- [src/features/crm/opportunities/api/types.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/opportunities/api/types.ts) +- [src/features/crm/opportunities/schemas/opportunity.schema.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/opportunities/schemas/opportunity.schema.ts) +- [src/features/crm/opportunities/server/service.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/opportunities/server/service.ts) +- [src/features/crm/opportunities/components/opportunity-form-sheet.tsx](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/opportunities/components/opportunity-form-sheet.tsx) +- [src/features/crm/opportunities/components/opportunity-detail.tsx](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/opportunities/components/opportunity-detail.tsx) +- [src/app/api/crm/opportunities/route.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/app/api/crm/opportunities/route.ts) +- [src/app/api/crm/opportunities/[id]/route.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/app/api/crm/opportunities/[id]/route.ts) +- [src/features/crm/quotations/api/types.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/quotations/api/types.ts) +- [src/features/crm/quotations/schemas/quotation.schema.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/quotations/schemas/quotation.schema.ts) +- [src/features/crm/quotations/server/service.ts](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/quotations/server/service.ts) +- [src/features/crm/quotations/components/quotation-form-sheet.tsx](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/src/features/crm/quotations/components/quotation-form-sheet.tsx) + +## Verification +- `npm run typecheck` ✅ +- `npm run build` ✅ + - Existing warnings remained from Turbopack workspace-root inference and the broad local storage provider path pattern in `src/features/foundation/storage/server/local-provider.ts`. +- `npm run audit:pdf` ✅ + - Regenerated audit artifacts and reports under `artifacts/pdf-audit/` and `docs/implementation/pdf-audit-report.*`. + +## Outcome +- Opportunity detail now launches quotation creation with selected opportunity context already attached. +- Opportunity and quotation both persist project timeline dates. +- Hot-project suggestion is deterministic, backend-backed, and no longer fights the user after manual override during the same edit session. diff --git a/drizzle/0002_opportunity_quotation_timeline_hot_project.sql b/drizzle/0002_opportunity_quotation_timeline_hot_project.sql new file mode 100644 index 0000000..1d716b8 --- /dev/null +++ b/drizzle/0002_opportunity_quotation_timeline_hot_project.sql @@ -0,0 +1,11 @@ +ALTER TABLE "crm_opportunities" +ADD COLUMN "project_close_date" timestamp with time zone, +ADD COLUMN "delivery_date" timestamp with time zone, +ADD COLUMN "hot_project_auto_suggested" boolean DEFAULT false NOT NULL, +ADD COLUMN "hot_project_manually_overridden" boolean DEFAULT false NOT NULL; + +ALTER TABLE "crm_quotations" +ADD COLUMN "project_close_date" timestamp with time zone, +ADD COLUMN "delivery_date" timestamp with time zone, +ADD COLUMN "hot_project_auto_suggested" boolean DEFAULT false NOT NULL, +ADD COLUMN "hot_project_manually_overridden" boolean DEFAULT false NOT NULL; diff --git a/drizzle/0003_curious_wild_child.sql b/drizzle/0003_curious_wild_child.sql new file mode 100644 index 0000000..5fd6cd0 --- /dev/null +++ b/drizzle/0003_curious_wild_child.sql @@ -0,0 +1,10 @@ +ALTER TABLE "crm_leads" ALTER COLUMN "status" DROP DEFAULT;--> statement-breakpoint +ALTER TABLE "crm_leads" ADD COLUMN "lead_channel" text;--> statement-breakpoint +ALTER TABLE "crm_opportunities" ADD COLUMN "project_close_date" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "crm_opportunities" ADD COLUMN "delivery_date" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "crm_opportunities" ADD COLUMN "hot_project_auto_suggested" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "crm_opportunities" ADD COLUMN "hot_project_manually_overridden" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "crm_quotations" ADD COLUMN "project_close_date" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "crm_quotations" ADD COLUMN "delivery_date" timestamp with time zone;--> statement-breakpoint +ALTER TABLE "crm_quotations" ADD COLUMN "hot_project_auto_suggested" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "crm_quotations" ADD COLUMN "hot_project_manually_overridden" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/drizzle_bk/meta/0023_snapshot.json b/drizzle/meta/0003_snapshot.json similarity index 72% rename from drizzle_bk/meta/0023_snapshot.json rename to drizzle/meta/0003_snapshot.json index 775487b..dcb2414 100644 --- a/drizzle_bk/meta/0023_snapshot.json +++ b/drizzle/meta/0003_snapshot.json @@ -1,9 +1,733 @@ { - "id": "beb57e07-da33-448f-8336-d2fb88fbdf1a", - "prevId": "cf5d9384-b358-4115-8397-7d499981456f", + "id": "be860157-9371-469d-84ec-aefc991ebddc", + "prevId": "6eb8d614-2b85-48c3-919e-af8fa13f0fb6", "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", @@ -1551,596 +2987,6 @@ "checkConstraints": {}, "isRLSEnabled": false }, - "public.crm_enquiries": { - "name": "crm_enquiries", - "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 - }, - "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_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_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_attachments": { - "name": "crm_enquiry_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_leads": { "name": "crm_leads", "schema": "", @@ -2199,6 +3045,12 @@ "primaryKey": false, "notNull": false }, + "lead_channel": { + "name": "lead_channel", + "type": "text", + "primaryKey": false, + "notNull": false + }, "product_type": { "name": "product_type", "type": "text", @@ -2227,8 +3079,7 @@ "name": "status", "type": "text", "primaryKey": false, - "notNull": true, - "default": "'new_job'" + "notNull": true }, "followup_status": { "name": "followup_status", @@ -2336,6 +3187,653 @@ "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 + }, + "project_close_date": { + "name": "project_close_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "delivery_date": { + "name": "delivery_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 + }, + "hot_project_auto_suggested": { + "name": "hot_project_auto_suggested", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hot_project_manually_overridden": { + "name": "hot_project_manually_overridden", + "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": "", @@ -2908,8 +4406,8 @@ "primaryKey": false, "notNull": true }, - "enquiry_id": { - "name": "enquiry_id", + "opportunity_id": { + "name": "opportunity_id", "type": "text", "primaryKey": false, "notNull": false @@ -3059,6 +4557,18 @@ "primaryKey": false, "notNull": false }, + "project_close_date": { + "name": "project_close_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "delivery_date": { + "name": "delivery_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "is_hot_project": { "name": "is_hot_project", "type": "boolean", @@ -3066,6 +4576,20 @@ "notNull": true, "default": false }, + "hot_project_auto_suggested": { + "name": "hot_project_auto_suggested", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hot_project_manually_overridden": { + "name": "hot_project_manually_overridden", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, "competitor": { "name": "competitor", "type": "text", @@ -3623,6 +5147,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 +5186,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 +5223,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 +5232,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 +5255,6 @@ "isExpression": false, "asc": true, "nulls": "last" - }, - { - "expression": "branch_id", - "isExpression": false, - "asc": true, - "nulls": "last" } ], "isUnique": true, diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 903c277..b7ee355 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -15,6 +15,20 @@ "when": 1782896400000, "tag": "0001_lead_channel_and_status_default", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1782896500000, + "tag": "0002_opportunity_quotation_timeline_hot_project", + "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1782881325779, + "tag": "0003_curious_wild_child", + "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/drizzle_bk/0000_icy_lizard.sql b/drizzle_bk/0000_icy_lizard.sql deleted file mode 100644 index d361d7f..0000000 --- a/drizzle_bk/0000_icy_lizard.sql +++ /dev/null @@ -1,48 +0,0 @@ -CREATE TABLE "memberships" ( - "id" text PRIMARY KEY NOT NULL, - "user_id" text NOT NULL, - "organization_id" text NOT NULL, - "role" text DEFAULT 'user' NOT NULL, - "business_role" text DEFAULT 'sales_support' NOT NULL, - "permissions" text[] DEFAULT '{}' NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "organizations" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "slug" text NOT NULL, - "image_url" text, - "plan" text DEFAULT 'free' NOT NULL, - "created_by" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "products" ( - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "products_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "organization_id" text NOT NULL, - "name" text NOT NULL, - "category" text NOT NULL, - "description" text NOT NULL, - "photo_url" text NOT NULL, - "price" double precision NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "users" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "email" text NOT NULL, - "password_hash" text NOT NULL, - "system_role" text DEFAULT 'user' NOT NULL, - "image" text, - "active_organization_id" text, - "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 "organizations_slug_idx" ON "organizations" USING btree ("slug");--> statement-breakpoint -CREATE UNIQUE INDEX "users_email_idx" ON "users" USING btree ("email"); diff --git a/drizzle_bk/0001_orange_mandarin.sql b/drizzle_bk/0001_orange_mandarin.sql deleted file mode 100644 index 76abaf3..0000000 --- a/drizzle_bk/0001_orange_mandarin.sql +++ /dev/null @@ -1,46 +0,0 @@ -CREATE TABLE "document_sequences" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text DEFAULT '' 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, - "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 -); ---> statement-breakpoint -CREATE TABLE "ms_options" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "category" text NOT NULL, - "code" text NOT NULL, - "label" text NOT NULL, - "value" text, - "parent_id" text, - "sort_order" integer DEFAULT 0 NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "metadata" jsonb, - "deleted_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 "tr_audit_logs" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text, - "user_id" text NOT NULL, - "entity_type" text NOT NULL, - "entity_id" text NOT NULL, - "action" text NOT NULL, - "before_data" jsonb, - "after_data" jsonb, - "request_id" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> 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 "ms_options_org_category_code_idx" ON "ms_options" USING btree ("organization_id","category","code"); \ No newline at end of file diff --git a/drizzle_bk/0002_plain_anthem.sql b/drizzle_bk/0002_plain_anthem.sql deleted file mode 100644 index 82b8d0d..0000000 --- a/drizzle_bk/0002_plain_anthem.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE TABLE "crm_customer_contacts" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "customer_id" text NOT NULL, - "name" text NOT NULL, - "position" text, - "department" text, - "phone" text, - "mobile" text, - "email" text, - "is_primary" boolean DEFAULT false NOT NULL, - "notes" 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_customers" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text, - "code" text NOT NULL, - "name" text NOT NULL, - "abbr" text, - "tax_id" text, - "customer_type" text NOT NULL, - "customer_status" text NOT NULL, - "address" text, - "province" text, - "district" text, - "sub_district" text, - "postal_code" text, - "country" text, - "phone" text, - "fax" text, - "email" text, - "website" text, - "lead_channel" text, - "customer_group" text, - "notes" 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 UNIQUE INDEX "crm_customers_org_code_idx" ON "crm_customers" USING btree ("organization_id","code"); \ No newline at end of file diff --git a/drizzle_bk/0003_blushing_bruce_banner.sql b/drizzle_bk/0003_blushing_bruce_banner.sql deleted file mode 100644 index 9abc1cc..0000000 --- a/drizzle_bk/0003_blushing_bruce_banner.sql +++ /dev/null @@ -1,50 +0,0 @@ -CREATE TABLE "crm_enquiries" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text, - "code" text NOT NULL, - "customer_id" text NOT NULL, - "contact_id" text, - "title" text NOT NULL, - "description" text, - "requirement" text, - "project_name" text, - "project_location" text, - "product_type" text NOT NULL, - "status" text NOT NULL, - "priority" text NOT NULL, - "lead_channel" text, - "estimated_value" double precision, - "chance_percent" integer, - "expected_close_date" timestamp with time zone, - "competitor" text, - "source" text, - "notes" text, - "is_hot_project" boolean DEFAULT false 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_enquiry_followups" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "enquiry_id" text NOT NULL, - "followup_date" timestamp with time zone NOT NULL, - "followup_type" text NOT NULL, - "contact_id" text, - "outcome" text, - "notes" text, - "next_followup_date" timestamp with time zone, - "next_action" 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 UNIQUE INDEX "crm_enquiries_org_code_idx" ON "crm_enquiries" USING btree ("organization_id","code"); \ No newline at end of file diff --git a/drizzle_bk/0004_worthless_ender_wiggin.sql b/drizzle_bk/0004_worthless_ender_wiggin.sql deleted file mode 100644 index 262d52e..0000000 --- a/drizzle_bk/0004_worthless_ender_wiggin.sql +++ /dev/null @@ -1,138 +0,0 @@ -CREATE TABLE "crm_quotation_attachments" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "quotation_id" text NOT NULL, - "file_name" text NOT NULL, - "original_file_name" text NOT NULL, - "file_path" text NOT NULL, - "file_size" integer, - "file_type" text, - "description" text, - "uploaded_at" timestamp with time zone DEFAULT now() NOT NULL, - "uploaded_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 -); ---> statement-breakpoint -CREATE TABLE "crm_quotation_customers" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "quotation_id" text NOT NULL, - "customer_id" text NOT NULL, - "role" text NOT NULL, - "is_primary" boolean DEFAULT false 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 -); ---> statement-breakpoint -CREATE TABLE "crm_quotation_followups" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "quotation_id" text NOT NULL, - "followup_date" timestamp with time zone NOT NULL, - "followup_type" text NOT NULL, - "contact_id" text, - "outcome" text, - "notes" text, - "next_followup_date" timestamp with time zone, - "next_action" 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_quotation_items" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "quotation_id" text NOT NULL, - "item_number" integer NOT NULL, - "product_type" text NOT NULL, - "description" text NOT NULL, - "quantity" double precision DEFAULT 0 NOT NULL, - "unit" text, - "unit_price" double precision DEFAULT 0 NOT NULL, - "discount" double precision DEFAULT 0 NOT NULL, - "discount_type" text, - "tax_rate" double precision DEFAULT 0 NOT NULL, - "total_price" double precision DEFAULT 0 NOT NULL, - "notes" text, - "sort_order" integer DEFAULT 0 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 -); ---> statement-breakpoint -CREATE TABLE "crm_quotation_topic_items" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "topic_id" text NOT NULL, - "content" text NOT NULL, - "sort_order" integer DEFAULT 0 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 -); ---> statement-breakpoint -CREATE TABLE "crm_quotation_topics" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "quotation_id" text NOT NULL, - "topic_type" text NOT NULL, - "title" text NOT NULL, - "sort_order" integer DEFAULT 0 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 -); ---> statement-breakpoint -CREATE TABLE "crm_quotations" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text, - "code" text NOT NULL, - "enquiry_id" text, - "customer_id" text NOT NULL, - "contact_id" text, - "quotation_date" timestamp with time zone NOT NULL, - "valid_until" timestamp with time zone, - "quotation_type" text NOT NULL, - "project_name" text, - "project_location" text, - "attention" text, - "reference" text, - "notes" text, - "status" text NOT NULL, - "revision" integer DEFAULT 0 NOT NULL, - "parent_quotation_id" text, - "revision_remark" text, - "currency" text NOT NULL, - "exchange_rate" double precision DEFAULT 1 NOT NULL, - "subtotal" double precision DEFAULT 0 NOT NULL, - "discount" double precision DEFAULT 0 NOT NULL, - "discount_type" text, - "tax_rate" double precision DEFAULT 0 NOT NULL, - "tax_amount" double precision DEFAULT 0 NOT NULL, - "total_amount" double precision DEFAULT 0 NOT NULL, - "chance_percent" integer, - "is_hot_project" boolean DEFAULT false NOT NULL, - "competitor" text, - "salesman_id" text, - "is_sent" boolean DEFAULT false NOT NULL, - "sent_at" timestamp with time zone, - "sent_via" text, - "accepted_at" timestamp with time zone, - "rejected_at" timestamp with time zone, - "rejection_reason" 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 UNIQUE INDEX "crm_quotations_org_code_idx" ON "crm_quotations" USING btree ("organization_id","code"); \ No newline at end of file diff --git a/drizzle_bk/0005_numerous_blob.sql b/drizzle_bk/0005_numerous_blob.sql deleted file mode 100644 index a3282d3..0000000 --- a/drizzle_bk/0005_numerous_blob.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE TABLE "crm_approval_actions" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "approval_request_id" text NOT NULL, - "step_number" integer NOT NULL, - "action" text NOT NULL, - "remark" text, - "acted_by" text NOT NULL, - "acted_at" timestamp with time zone DEFAULT now() 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 -); ---> statement-breakpoint -CREATE TABLE "crm_approval_requests" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "workflow_id" text NOT NULL, - "entity_type" text NOT NULL, - "entity_id" text NOT NULL, - "current_step" integer DEFAULT 1 NOT NULL, - "status" text NOT NULL, - "requested_by" text NOT NULL, - "requested_at" timestamp with time zone DEFAULT now() NOT NULL, - "completed_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, - "deleted_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "crm_approval_steps" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "workflow_id" text NOT NULL, - "step_number" integer NOT NULL, - "role_code" text NOT NULL, - "role_name" text NOT NULL, - "is_required" 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 -); ---> statement-breakpoint -CREATE TABLE "crm_approval_workflows" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "entity_type" text 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 -); ---> 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"); \ No newline at end of file diff --git a/drizzle_bk/0006_worried_mordo.sql b/drizzle_bk/0006_worried_mordo.sql deleted file mode 100644 index 8822836..0000000 --- a/drizzle_bk/0006_worried_mordo.sql +++ /dev/null @@ -1,66 +0,0 @@ -CREATE TABLE "crm_document_template_mappings" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "template_version_id" text NOT NULL, - "placeholder_key" text NOT NULL, - "source_path" text NOT NULL, - "data_type" text NOT NULL, - "sheet_name" text, - "default_value" text, - "format_mask" text, - "sort_order" integer DEFAULT 0 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 -); ---> statement-breakpoint -CREATE TABLE "crm_document_template_table_columns" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "mapping_id" text NOT NULL, - "column_name" text NOT NULL, - "source_field" text NOT NULL, - "column_letter" text, - "sort_order" integer DEFAULT 0 NOT NULL, - "format_mask" 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 -); ---> statement-breakpoint -CREATE TABLE "crm_document_template_versions" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "template_id" text NOT NULL, - "version" text NOT NULL, - "file_path" text, - "schema_json" jsonb NOT NULL, - "preview_image_url" 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 -); ---> statement-breakpoint -CREATE TABLE "crm_document_templates" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "document_type" text NOT NULL, - "product_type" text NOT NULL, - "file_type" text NOT NULL, - "template_name" text NOT NULL, - "description" text, - "is_default" boolean DEFAULT false 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_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 -CREATE UNIQUE INDEX "crm_document_templates_org_doc_product_file_name_idx" ON "crm_document_templates" USING btree ("organization_id","document_type","product_type","file_type","template_name"); \ No newline at end of file diff --git a/drizzle_bk/0007_luxuriant_malice.sql b/drizzle_bk/0007_luxuriant_malice.sql deleted file mode 100644 index 9af75d3..0000000 --- a/drizzle_bk/0007_luxuriant_malice.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE "crm_quotations" ADD COLUMN "approved_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_quotations" ADD COLUMN "approved_pdf_url" text;--> statement-breakpoint -ALTER TABLE "crm_quotations" ADD COLUMN "approved_snapshot" jsonb;--> statement-breakpoint -ALTER TABLE "crm_quotations" ADD COLUMN "approved_template_version_id" text; \ No newline at end of file diff --git a/drizzle_bk/0008_clean_justin_hammer.sql b/drizzle_bk/0008_clean_justin_hammer.sql deleted file mode 100644 index b128240..0000000 --- a/drizzle_bk/0008_clean_justin_hammer.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE "crm_enquiries" ADD COLUMN "assigned_to_user_id" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "assigned_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "assigned_by" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "assignment_remark" text;--> statement-breakpoint -ALTER TABLE "memberships" ALTER COLUMN "business_role" SET DEFAULT 'sales_support'; diff --git a/drizzle_bk/0009_lazy_shard.sql b/drizzle_bk/0009_lazy_shard.sql deleted file mode 100644 index 0a38938..0000000 --- a/drizzle_bk/0009_lazy_shard.sql +++ /dev/null @@ -1,30 +0,0 @@ -CREATE TABLE "crm_document_artifacts" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "entity_type" text NOT NULL, - "entity_id" text NOT NULL, - "document_type" text NOT NULL, - "artifact_type" text NOT NULL, - "template_version_id" text, - "storage_provider" text NOT NULL, - "storage_key" text NOT NULL, - "file_name" text NOT NULL, - "content_type" text NOT NULL, - "file_size" integer, - "checksum" text, - "status" text DEFAULT 'active' NOT NULL, - "generated_by" text NOT NULL, - "generated_at" timestamp with time zone DEFAULT now() NOT NULL, - "locked_at" timestamp with time zone, - "locked_by" text, - "voided_at" timestamp with time zone, - "voided_by" text, - "void_reason" text, - "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 -); ---> statement-breakpoint -ALTER TABLE "memberships" ALTER COLUMN "business_role" SET DEFAULT 'sales_support';--> statement-breakpoint -ALTER TABLE "crm_quotations" ADD COLUMN "approved_artifact_id" text; \ No newline at end of file diff --git a/drizzle_bk/0010_calm_wendell_rand.sql b/drizzle_bk/0010_calm_wendell_rand.sql deleted file mode 100644 index e0ddad3..0000000 --- a/drizzle_bk/0010_calm_wendell_rand.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE "crm_enquiry_customers" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "enquiry_id" text NOT NULL, - "customer_id" text NOT NULL, - "role" text NOT NULL, - "remark" 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 -); ---> statement-breakpoint -ALTER TABLE "crm_quotation_customers" ADD COLUMN "remark" text; \ No newline at end of file diff --git a/drizzle_bk/0011_brief_hobgoblin.sql b/drizzle_bk/0011_brief_hobgoblin.sql deleted file mode 100644 index d3d8a9e..0000000 --- a/drizzle_bk/0011_brief_hobgoblin.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "crm_customers" -ADD COLUMN "customer_sub_group" text; diff --git a/drizzle_bk/0011_goofy_the_hood.sql b/drizzle_bk/0011_goofy_the_hood.sql deleted file mode 100644 index a4e605a..0000000 --- a/drizzle_bk/0011_goofy_the_hood.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "crm_customers" ADD COLUMN "customer_sub_group" text; \ No newline at end of file diff --git a/drizzle_bk/0012_odd_fat_cobra.sql b/drizzle_bk/0012_odd_fat_cobra.sql deleted file mode 100644 index 4f82574..0000000 --- a/drizzle_bk/0012_odd_fat_cobra.sql +++ /dev/null @@ -1,31 +0,0 @@ -ALTER TABLE "crm_enquiries" -ADD COLUMN "pipeline_stage" text; - -UPDATE "crm_enquiries" AS enquiry -SET "pipeline_stage" = CASE - WHEN EXISTS ( - SELECT 1 - FROM "ms_options" AS option - WHERE option."id" = enquiry."status" - AND option."category" = 'crm_enquiry_status' - AND option."code" IN ('closed_lost', 'cancelled') - AND option."deleted_at" IS NULL - ) THEN 'closed_lost' - WHEN enquiry."assigned_to_user_id" IS NOT NULL THEN 'enquiry' - ELSE 'lead' -END -WHERE enquiry."pipeline_stage" IS NULL; - -UPDATE "crm_enquiries" -SET "pipeline_stage" = 'lead' -WHERE "pipeline_stage" IS NULL; - -ALTER TABLE "crm_enquiries" -ALTER COLUMN "pipeline_stage" SET DEFAULT 'lead'; - -ALTER TABLE "crm_enquiries" -ALTER COLUMN "pipeline_stage" SET NOT NULL; - -ALTER TABLE "crm_enquiries" -ADD CONSTRAINT "crm_enquiries_pipeline_stage_check" -CHECK ("pipeline_stage" IN ('lead', 'enquiry', 'closed_won', 'closed_lost')); diff --git a/drizzle_bk/0012_simple_bucky.sql b/drizzle_bk/0012_simple_bucky.sql deleted file mode 100644 index cac9e64..0000000 --- a/drizzle_bk/0012_simple_bucky.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "crm_enquiries" ADD COLUMN "pipeline_stage" text DEFAULT 'lead' NOT NULL; \ No newline at end of file diff --git a/drizzle_bk/0013_great_nicolaos.sql b/drizzle_bk/0013_great_nicolaos.sql deleted file mode 100644 index a4489fc..0000000 --- a/drizzle_bk/0013_great_nicolaos.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "crm_role_profiles" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "description" text, - "permissions" text[] DEFAULT '{}' NOT NULL, - "branch_scope_mode" text DEFAULT 'assigned' NOT NULL, - "product_scope_mode" text DEFAULT 'assigned' NOT NULL, - "ownership_scope" text DEFAULT 'own' NOT NULL, - "approval_authority" text DEFAULT 'none' NOT NULL, - "is_system" boolean DEFAULT false 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 "memberships" ADD COLUMN "branch_scope_ids" text[] DEFAULT '{}' NOT NULL;--> statement-breakpoint -ALTER TABLE "memberships" ADD COLUMN "product_type_scope_ids" text[] DEFAULT '{}' NOT NULL;--> statement-breakpoint -CREATE UNIQUE INDEX "crm_role_profiles_org_code_idx" ON "crm_role_profiles" USING btree ("organization_id","code"); \ No newline at end of file diff --git a/drizzle_bk/0014_bored_valkyrie.sql b/drizzle_bk/0014_bored_valkyrie.sql deleted file mode 100644 index 74871ec..0000000 --- a/drizzle_bk/0014_bored_valkyrie.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "crm_user_role_assignments" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "role_profile_id" text NOT NULL, - "branch_scope_mode" text DEFAULT 'inherit' NOT NULL, - "branch_scope_ids" text[] DEFAULT '{}' NOT NULL, - "product_type_scope_mode" text DEFAULT 'inherit' NOT NULL, - "product_type_scope_ids" text[] DEFAULT '{}' NOT NULL, - "is_primary" boolean DEFAULT false NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "assigned_by" text NOT NULL, - "assigned_at" timestamp with time zone DEFAULT now() 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 -); ---> 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"); \ No newline at end of file diff --git a/drizzle_bk/0014_crm_user_role_assignments.sql b/drizzle_bk/0014_crm_user_role_assignments.sql deleted file mode 100644 index 7387337..0000000 --- a/drizzle_bk/0014_crm_user_role_assignments.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE IF NOT EXISTS "crm_user_role_assignments" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "role_profile_id" text NOT NULL, - "branch_scope_mode" text DEFAULT 'inherit' NOT NULL, - "branch_scope_ids" text[] DEFAULT '{}' NOT NULL, - "product_type_scope_mode" text DEFAULT 'inherit' NOT NULL, - "product_type_scope_ids" text[] DEFAULT '{}' NOT NULL, - "is_primary" boolean DEFAULT false NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "assigned_by" text NOT NULL, - "assigned_at" timestamp with time zone DEFAULT now() 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 -); - -CREATE UNIQUE INDEX IF NOT EXISTS "crm_user_role_assignments_org_user_role_idx" -ON "crm_user_role_assignments" ("organization_id", "user_id", "role_profile_id"); diff --git a/drizzle_bk/0015_customer_ownership_contact_shares.sql b/drizzle_bk/0015_customer_ownership_contact_shares.sql deleted file mode 100644 index 5bc5283..0000000 --- a/drizzle_bk/0015_customer_ownership_contact_shares.sql +++ /dev/null @@ -1,35 +0,0 @@ -ALTER TABLE "crm_customers" -ADD COLUMN IF NOT EXISTS "owner_user_id" text, -ADD COLUMN IF NOT EXISTS "owner_assigned_at" timestamp with time zone, -ADD COLUMN IF NOT EXISTS "owner_assigned_by" text; - -CREATE TABLE IF NOT EXISTS "crm_customer_owner_history" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "customer_id" text NOT NULL, - "old_owner_user_id" text, - "new_owner_user_id" text, - "changed_by" text NOT NULL, - "changed_at" timestamp with time zone DEFAULT now() NOT NULL, - "remark" 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 -); - -CREATE TABLE IF NOT EXISTS "crm_contact_shares" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "contact_id" text NOT NULL, - "shared_to_user_id" text NOT NULL, - "shared_by_user_id" text NOT NULL, - "shared_at" timestamp with time zone DEFAULT now() NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "remark" 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 -); - -CREATE UNIQUE INDEX IF NOT EXISTS "crm_contact_shares_org_contact_shared_user_idx" -ON "crm_contact_shares" ("organization_id", "contact_id", "shared_to_user_id"); diff --git a/drizzle_bk/0016_won_lost_lifecycle_governance.sql b/drizzle_bk/0016_won_lost_lifecycle_governance.sql deleted file mode 100644 index 2a9ab23..0000000 --- a/drizzle_bk/0016_won_lost_lifecycle_governance.sql +++ /dev/null @@ -1,30 +0,0 @@ -ALTER TABLE "crm_enquiries" - ADD COLUMN IF NOT EXISTS "closed_won_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "closed_lost_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "closed_by_user_id" text, - ADD COLUMN IF NOT EXISTS "po_number" text, - ADD COLUMN IF NOT EXISTS "po_date" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "po_amount" double precision, - ADD COLUMN IF NOT EXISTS "po_currency" text, - ADD COLUMN IF NOT EXISTS "lost_reason" text, - ADD COLUMN IF NOT EXISTS "lost_competitor" text, - ADD COLUMN IF NOT EXISTS "lost_remark" text; - -CREATE TABLE IF NOT EXISTS "crm_enquiry_attachments" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "enquiry_id" text NOT NULL, - "category" text NOT NULL, - "file_name" text NOT NULL, - "original_file_name" text NOT NULL, - "storage_provider" text NOT NULL, - "storage_key" text NOT NULL, - "file_size" integer, - "file_type" text, - "description" text, - "uploaded_at" timestamp with time zone DEFAULT now() NOT NULL, - "uploaded_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 -); diff --git a/drizzle_bk/0017_short_swordsman.sql b/drizzle_bk/0017_short_swordsman.sql deleted file mode 100644 index 9007356..0000000 --- a/drizzle_bk/0017_short_swordsman.sql +++ /dev/null @@ -1,61 +0,0 @@ -CREATE TABLE "crm_contact_shares" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "contact_id" text NOT NULL, - "shared_to_user_id" text NOT NULL, - "shared_by_user_id" text NOT NULL, - "shared_at" timestamp with time zone DEFAULT now() NOT NULL, - "is_active" boolean DEFAULT true NOT NULL, - "remark" 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 -); ---> statement-breakpoint -CREATE TABLE "crm_customer_owner_history" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "customer_id" text NOT NULL, - "old_owner_user_id" text, - "new_owner_user_id" text, - "changed_by" text NOT NULL, - "changed_at" timestamp with time zone DEFAULT now() NOT NULL, - "remark" 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 -); ---> statement-breakpoint -CREATE TABLE "crm_enquiry_attachments" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "enquiry_id" text NOT NULL, - "category" text NOT NULL, - "file_name" text NOT NULL, - "original_file_name" text NOT NULL, - "storage_provider" text NOT NULL, - "storage_key" text NOT NULL, - "file_size" integer, - "file_type" text, - "description" text, - "uploaded_at" timestamp with time zone DEFAULT now() NOT NULL, - "uploaded_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 -); ---> statement-breakpoint -ALTER TABLE "crm_customers" ADD COLUMN "owner_user_id" text;--> statement-breakpoint -ALTER TABLE "crm_customers" ADD COLUMN "owner_assigned_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_customers" ADD COLUMN "owner_assigned_by" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "closed_won_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "closed_lost_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "closed_by_user_id" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "po_number" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "po_date" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "po_amount" double precision;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "po_currency" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "lost_reason" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "lost_competitor" text;--> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "lost_remark" text;--> 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"); \ No newline at end of file diff --git a/drizzle_bk/0018_report_foundation.sql b/drizzle_bk/0018_report_foundation.sql deleted file mode 100644 index 1667c66..0000000 --- a/drizzle_bk/0018_report_foundation.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE IF NOT EXISTS "crm_report_definitions" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "description" text, - "category" text NOT NULL, - "is_system" boolean DEFAULT true 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 -); - -CREATE UNIQUE INDEX IF NOT EXISTS "crm_report_definitions_org_code_idx" -ON "crm_report_definitions" ("organization_id", "code"); diff --git a/drizzle_bk/0019_sleepy_ultron.sql b/drizzle_bk/0019_sleepy_ultron.sql deleted file mode 100644 index 81faa66..0000000 --- a/drizzle_bk/0019_sleepy_ultron.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE "crm_report_definitions" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "code" text NOT NULL, - "name" text NOT NULL, - "description" text, - "category" text NOT NULL, - "is_system" boolean DEFAULT true 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 -); ---> statement-breakpoint -CREATE UNIQUE INDEX "crm_report_definitions_org_code_idx" ON "crm_report_definitions" USING btree ("organization_id","code"); \ No newline at end of file diff --git a/drizzle_bk/0020_lead_foundation_schema.sql b/drizzle_bk/0020_lead_foundation_schema.sql deleted file mode 100644 index 4f26edf..0000000 --- a/drizzle_bk/0020_lead_foundation_schema.sql +++ /dev/null @@ -1,24 +0,0 @@ -CREATE TABLE IF NOT EXISTS "crm_leads" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text, - "code" text NOT NULL, - "customer_id" text, - "contact_id" text, - "project_name" text, - "project_location" text, - "awareness_id" text, - "status" text DEFAULT 'new_job' NOT NULL, - "followup_status" text, - "lost_reason" text, - "outcome" text DEFAULT 'open' NOT NULL, - "owner_marketing_user_id" text, - "created_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 -); ---> statement-breakpoint -CREATE UNIQUE INDEX IF NOT EXISTS "crm_leads_org_code_idx" ON "crm_leads" USING btree ("organization_id","code"); ---> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN IF NOT EXISTS "lead_id" text; diff --git a/drizzle_bk/0021_worried_nebula.sql b/drizzle_bk/0021_worried_nebula.sql deleted file mode 100644 index 68d9db9..0000000 --- a/drizzle_bk/0021_worried_nebula.sql +++ /dev/null @@ -1,23 +0,0 @@ -CREATE TABLE "crm_leads" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "branch_id" text, - "code" text NOT NULL, - "customer_id" text, - "contact_id" text, - "project_name" text, - "project_location" text, - "awareness_id" text, - "status" text DEFAULT 'new_job' NOT NULL, - "followup_status" text, - "lost_reason" text, - "outcome" text DEFAULT 'open' NOT NULL, - "owner_marketing_user_id" text, - "created_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 -); ---> statement-breakpoint -ALTER TABLE "crm_enquiries" ADD COLUMN "lead_id" text;--> statement-breakpoint -CREATE UNIQUE INDEX "crm_leads_org_code_idx" ON "crm_leads" USING btree ("organization_id","code"); \ No newline at end of file diff --git a/drizzle_bk/0022_lead_assignment_foundation.sql b/drizzle_bk/0022_lead_assignment_foundation.sql deleted file mode 100644 index 0a1779c..0000000 --- a/drizzle_bk/0022_lead_assignment_foundation.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE "crm_leads" - ADD COLUMN IF NOT EXISTS "description" text, - ADD COLUMN IF NOT EXISTS "product_type" text, - ADD COLUMN IF NOT EXISTS "priority" text, - ADD COLUMN IF NOT EXISTS "estimated_value" double precision, - ADD COLUMN IF NOT EXISTS "assigned_sales_owner_id" text, - ADD COLUMN IF NOT EXISTS "assigned_at" timestamp with time zone, - ADD COLUMN IF NOT EXISTS "assigned_by" text, - ADD COLUMN IF NOT EXISTS "assignment_remark" text; diff --git a/drizzle_bk/0023_yellow_carlie_cooper.sql b/drizzle_bk/0023_yellow_carlie_cooper.sql deleted file mode 100644 index 570df70..0000000 --- a/drizzle_bk/0023_yellow_carlie_cooper.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE "crm_leads" ADD COLUMN "description" text;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "product_type" text;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "priority" text;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "estimated_value" double precision;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "assigned_sales_owner_id" text;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "assigned_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "assigned_by" text;--> statement-breakpoint -ALTER TABLE "crm_leads" ADD COLUMN "assignment_remark" text; \ No newline at end of file diff --git a/drizzle_bk/meta/0000_snapshot.json b/drizzle_bk/meta/0000_snapshot.json deleted file mode 100644 index 0aeadcc..0000000 --- a/drizzle_bk/meta/0000_snapshot.json +++ /dev/null @@ -1,331 +0,0 @@ -{ - "id": "1e236d6a-ca42-4830-b230-67a7c233d87b", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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.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.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": {} - } -} diff --git a/drizzle_bk/meta/0001_snapshot.json b/drizzle_bk/meta/0001_snapshot.json deleted file mode 100644 index ef37af3..0000000 --- a/drizzle_bk/meta/0001_snapshot.json +++ /dev/null @@ -1,653 +0,0 @@ -{ - "id": "a21ab199-cb43-48b2-b810-7d4afb9baaef", - "prevId": "1e236d6a-ca42-4830-b230-67a7c233d87b", - "version": "7", - "dialect": "postgresql", - "tables": { - "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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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": {} - } -} diff --git a/drizzle_bk/meta/0002_snapshot.json b/drizzle_bk/meta/0002_snapshot.json deleted file mode 100644 index 6d36e16..0000000 --- a/drizzle_bk/meta/0002_snapshot.json +++ /dev/null @@ -1,978 +0,0 @@ -{ - "id": "9f3af9b8-d774-40bb-8b24-29b06332b453", - "prevId": "a21ab199-cb43-48b2-b810-7d4afb9baaef", - "version": "7", - "dialect": "postgresql", - "tables": { - "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_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 - }, - "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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0003_snapshot.json b/drizzle_bk/meta/0003_snapshot.json deleted file mode 100644 index b68640c..0000000 --- a/drizzle_bk/meta/0003_snapshot.json +++ /dev/null @@ -1,1290 +0,0 @@ -{ - "id": "7f3502c2-ddb7-47cd-bc78-0510a67ceded", - "prevId": "9f3af9b8-d774-40bb-8b24-29b06332b453", - "version": "7", - "dialect": "postgresql", - "tables": { - "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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0004_snapshot.json b/drizzle_bk/meta/0004_snapshot.json deleted file mode 100644 index 56063a1..0000000 --- a/drizzle_bk/meta/0004_snapshot.json +++ /dev/null @@ -1,2133 +0,0 @@ -{ - "id": "2d07652f-ec50-4bc0-970e-b2e59784a958", - "prevId": "7f3502c2-ddb7-47cd-bc78-0510a67ceded", - "version": "7", - "dialect": "postgresql", - "tables": { - "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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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 - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0005_snapshot.json b/drizzle_bk/meta/0005_snapshot.json deleted file mode 100644 index 1ce094c..0000000 --- a/drizzle_bk/meta/0005_snapshot.json +++ /dev/null @@ -1,2500 +0,0 @@ -{ - "id": "784d3c1e-a756-471c-8400-38db2f394041", - "prevId": "2d07652f-ec50-4bc0-970e-b2e59784a958", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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 - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0006_snapshot.json b/drizzle_bk/meta/0006_snapshot.json deleted file mode 100644 index 08a20c7..0000000 --- a/drizzle_bk/meta/0006_snapshot.json +++ /dev/null @@ -1,2971 +0,0 @@ -{ - "id": "ad73f2e2-1046-414f-bcd9-32482c623e57", - "prevId": "784d3c1e-a756-471c-8400-38db2f394041", - "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_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_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 - }, - "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_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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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 - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0007_snapshot.json b/drizzle_bk/meta/0007_snapshot.json deleted file mode 100644 index 9b48bca..0000000 --- a/drizzle_bk/meta/0007_snapshot.json +++ /dev/null @@ -1,2995 +0,0 @@ -{ - "id": "dae63ce5-8077-4920-abd6-a232df70e20a", - "prevId": "ad73f2e2-1046-414f-bcd9-32482c623e57", - "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_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_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 - }, - "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_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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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 - }, - "enquiry_id": { - "name": "enquiry_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_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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0008_snapshot.json b/drizzle_bk/meta/0008_snapshot.json deleted file mode 100644 index 5ed3ebd..0000000 --- a/drizzle_bk/meta/0008_snapshot.json +++ /dev/null @@ -1,3019 +0,0 @@ -{ - "id": "0237eb23-9304-48dd-a770-8bf5013172da", - "prevId": "dae63ce5-8077-4920-abd6-a232df70e20a", - "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_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_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 - }, - "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_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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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 - }, - "enquiry_id": { - "name": "enquiry_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_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.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": "'viewer'" - }, - "permissions": { - "name": "permissions", - "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_bk/meta/0009_snapshot.json b/drizzle_bk/meta/0009_snapshot.json deleted file mode 100644 index a3b1a4c..0000000 --- a/drizzle_bk/meta/0009_snapshot.json +++ /dev/null @@ -1,3192 +0,0 @@ -{ - "id": "ef6e9c14-9f8a-42aa-bbd3-4638dccea8a4", - "prevId": "0237eb23-9304-48dd-a770-8bf5013172da", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "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 - }, - "enquiry_id": { - "name": "enquiry_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.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": "'{}'" - }, - "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_bk/meta/0010_snapshot.json b/drizzle_bk/meta/0010_snapshot.json deleted file mode 100644 index fb702b0..0000000 --- a/drizzle_bk/meta/0010_snapshot.json +++ /dev/null @@ -1,3267 +0,0 @@ -{ - "id": "2528d9c4-a324-4654-866e-e1e1fef68be4", - "prevId": "ef6e9c14-9f8a-42aa-bbd3-4638dccea8a4", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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.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": "'{}'" - }, - "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_bk/meta/0011_snapshot.json b/drizzle_bk/meta/0011_snapshot.json deleted file mode 100644 index 999bb59..0000000 --- a/drizzle_bk/meta/0011_snapshot.json +++ /dev/null @@ -1,3273 +0,0 @@ -{ - "id": "5557525b-6ce9-4689-b870-7dc8c8c902a0", - "prevId": "2528d9c4-a324-4654-866e-e1e1fef68be4", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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 - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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.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": "'{}'" - }, - "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_bk/meta/0012_snapshot.json b/drizzle_bk/meta/0012_snapshot.json deleted file mode 100644 index 799cc5b..0000000 --- a/drizzle_bk/meta/0012_snapshot.json +++ /dev/null @@ -1,3280 +0,0 @@ -{ - "id": "0295d780-7a89-4886-914b-61fa8f6c59b7", - "prevId": "5557525b-6ce9-4689-b870-7dc8c8c902a0", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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'" - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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.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": "'{}'" - }, - "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_bk/meta/0013_snapshot.json b/drizzle_bk/meta/0013_snapshot.json deleted file mode 100644 index a3b2cdc..0000000 --- a/drizzle_bk/meta/0013_snapshot.json +++ /dev/null @@ -1,3440 +0,0 @@ -{ - "id": "6f765853-49cf-4310-ba12-414adc1e05dc", - "prevId": "0295d780-7a89-4886-914b-61fa8f6c59b7", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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'" - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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_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.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_bk/meta/0014_snapshot.json b/drizzle_bk/meta/0014_snapshot.json deleted file mode 100644 index 01db1df..0000000 --- a/drizzle_bk/meta/0014_snapshot.json +++ /dev/null @@ -1,3580 +0,0 @@ -{ - "id": "0d1df50e-da6b-49f3-81ac-207230784d7d", - "prevId": "6f765853-49cf-4310-ba12-414adc1e05dc", - "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_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_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 - }, - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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'" - }, - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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_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_bk/meta/0017_snapshot.json b/drizzle_bk/meta/0017_snapshot.json deleted file mode 100644 index 2be826c..0000000 --- a/drizzle_bk/meta/0017_snapshot.json +++ /dev/null @@ -1,3963 +0,0 @@ -{ - "id": "665cc7e6-1576-4132-9f6b-cba29531e089", - "prevId": "0d1df50e-da6b-49f3-81ac-207230784d7d", - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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_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_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_attachments": { - "name": "crm_enquiry_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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_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_bk/meta/0019_snapshot.json b/drizzle_bk/meta/0019_snapshot.json deleted file mode 100644 index 76f155a..0000000 --- a/drizzle_bk/meta/0019_snapshot.json +++ /dev/null @@ -1,4062 +0,0 @@ -{ - "id": "e5c31781-e57a-4d70-b80a-94ffa916f4b0", - "prevId": "665cc7e6-1576-4132-9f6b-cba29531e089", - "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_enquiries": { - "name": "crm_enquiries", - "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": 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 - }, - "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_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_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_attachments": { - "name": "crm_enquiry_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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 - }, - "enquiry_id": { - "name": "enquiry_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_bk/meta/0021_snapshot.json b/drizzle_bk/meta/0021_snapshot.json deleted file mode 100644 index 4c4baf9..0000000 --- a/drizzle_bk/meta/0021_snapshot.json +++ /dev/null @@ -1,4215 +0,0 @@ -{ - "id": "cf5d9384-b358-4115-8397-7d499981456f", - "prevId": "e5c31781-e57a-4d70-b80a-94ffa916f4b0", - "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_enquiries": { - "name": "crm_enquiries", - "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 - }, - "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_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_competitor": { - "name": "lost_competitor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "lost_remark": { - "name": "lost_remark", - "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_enquiries_org_code_idx": { - "name": "crm_enquiries_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_enquiry_attachments": { - "name": "crm_enquiry_attachments", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_customers": { - "name": "crm_enquiry_customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_enquiry_followups": { - "name": "crm_enquiry_followups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "organization_id": { - "name": "organization_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "enquiry_id": { - "name": "enquiry_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_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 - }, - "project_name": { - "name": "project_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "project_location": { - "name": "project_location", - "type": "text", - "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 - }, - "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_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 - }, - "enquiry_id": { - "name": "enquiry_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_bk/meta/_journal.json b/drizzle_bk/meta/_journal.json deleted file mode 100644 index 1298c4a..0000000 --- a/drizzle_bk/meta/_journal.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1781148450992, - "tag": "0000_icy_lizard", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1781171200406, - "tag": "0001_orange_mandarin", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1781498575433, - "tag": "0002_plain_anthem", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1781505431077, - "tag": "0003_blushing_bruce_banner", - "breakpoints": true - }, - { - "idx": 4, - "version": "7", - "when": 1781511534267, - "tag": "0004_worthless_ender_wiggin", - "breakpoints": true - }, - { - "idx": 5, - "version": "7", - "when": 1781575976324, - "tag": "0005_numerous_blob", - "breakpoints": true - }, - { - "idx": 6, - "version": "7", - "when": 1781579746622, - "tag": "0006_worried_mordo", - "breakpoints": true - }, - { - "idx": 7, - "version": "7", - "when": 1781589458455, - "tag": "0007_luxuriant_malice", - "breakpoints": true - }, - { - "idx": 8, - "version": "7", - "when": 1781595962545, - "tag": "0008_clean_justin_hammer", - "breakpoints": true - }, - { - "idx": 9, - "version": "7", - "when": 1781603421415, - "tag": "0009_lazy_shard", - "breakpoints": true - }, - { - "idx": 10, - "version": "7", - "when": 1781675409847, - "tag": "0010_calm_wendell_rand", - "breakpoints": true - }, - { - "idx": 11, - "version": "7", - "when": 1781747812297, - "tag": "0011_goofy_the_hood", - "breakpoints": true - }, - { - "idx": 12, - "version": "7", - "when": 1781836261952, - "tag": "0012_simple_bucky", - "breakpoints": true - }, - { - "idx": 13, - "version": "7", - "when": 1782097963376, - "tag": "0013_great_nicolaos", - "breakpoints": true - }, - { - "idx": 14, - "version": "7", - "when": 1782099743528, - "tag": "0014_bored_valkyrie", - "breakpoints": true - }, - { - "idx": 15, - "version": "7", - "when": 1782549600000, - "tag": "0015_customer_ownership_contact_shares", - "breakpoints": true - }, - { - "idx": 16, - "version": "7", - "when": 1782795600000, - "tag": "0016_won_lost_lifecycle_governance", - "breakpoints": true - }, - { - "idx": 17, - "version": "7", - "when": 1782121929212, - "tag": "0017_short_swordsman", - "breakpoints": true - }, - { - "idx": 18, - "version": "7", - "when": 1782799200000, - "tag": "0018_report_foundation", - "breakpoints": true - }, - { - "idx": 19, - "version": "7", - "when": 1782137095907, - "tag": "0019_sleepy_ultron", - "breakpoints": true - }, - { - "idx": 20, - "version": "7", - "when": 1782262800000, - "tag": "0020_lead_foundation_schema", - "breakpoints": true - }, - { - "idx": 21, - "version": "7", - "when": 1782279100730, - "tag": "0021_worried_nebula", - "breakpoints": true - }, - { - "idx": 22, - "version": "7", - "when": 1782286200000, - "tag": "0022_lead_assignment_foundation", - "breakpoints": true - }, - { - "idx": 23, - "version": "7", - "when": 1782284237696, - "tag": "0023_yellow_carlie_cooper", - "breakpoints": true - } - ] -} diff --git a/plans/task-d.6.2.md b/plans/task-d.6.2.md new file mode 100644 index 0000000..75aad1f --- /dev/null +++ b/plans/task-d.6.2.md @@ -0,0 +1,124 @@ +# Task D.6.2 - Opportunity to Quotation Prefill & Project Timeline Fields + +## Objective +Improve the Opportunity -> Quotation workflow so users do not need to select the same Opportunity twice, while adding timeline fields and hot-project forecasting support. + +## Requirements + +### 1. Create Quotation from Opportunity Detail +- Clicking `Create Quotation` from Opportunity detail must open the quotation form with the current Opportunity already selected. +- Related customer/project/contact/product context should be prefilled where available. + +### 2. Add Project Timeline Fields +Add these fields to both Opportunity and Quotation: +- `Project Close Date` +- `Delivery Date` + +Rules: +- Use calendar date pickers. +- Display format must be `YYYY-MM-DD`. + +### 3. Auto Hot Project Rule +- When `Project Close Date <= current date + 3 months`, the system should auto-suggest `hotProject = true`. +- User may manually uncheck it. + +### 4. Manual Override Rule +Hot Project must support: +- `auto suggested` +- `manual override` + +Recommended persisted fields: +- `isHotProject` +- `hotProjectAutoSuggested` +- `hotProjectManuallyOverridden` + +The UI must not keep forcing the checkbox back on during the same edit session after the user manually changes it. + +### 5. Backend Enforcement +Backend must: +- accept `projectCloseDate` +- accept `deliveryDate` +- validate `YYYY-MM-DD` +- calculate hot-project suggestion +- preserve manual override +- persist all values correctly + +### 6. Quotation Prefill Rules +When creating a quotation from an Opportunity, prefill where available: +- `opportunityId` +- customer / billing customer / project parties +- project name +- product type +- branch +- contact +- `projectCloseDate` +- `deliveryDate` +- `hotProject` + +Do not overwrite user edits after the form has already been opened. + +### 7. UI Requirements +Opportunity Detail: +- `Create Quotation` must pass the current Opportunity context. +- Quotation form shows selected Opportunity already filled. + +Opportunity Form: +- `Project Close Date` +- `Delivery Date` +- `Hot Project` + +Quotation Form: +- `Project Close Date` +- `Delivery Date` +- `Hot Project` + +### 8. Testing +Run: + +```bash +npm run typecheck +npm run build +npm run audit:pdf +``` + +Test cases: +- Create quotation from Opportunity detail preselects Opportunity. +- User does not need to reselect Opportunity. +- Project Close Date within 3 months auto-checks Hot Project. +- User can uncheck Hot Project. +- Project Close Date beyond 3 months does not auto-check. +- Delivery Date saves correctly. +- Quotation receives timeline fields from Opportunity. +- Existing quotation create flow still works without Opportunity. + +## Acceptance Criteria +- Create Quotation from Opportunity detail preselects current Opportunity. +- Opportunity does not need to be selected twice. +- Opportunity has Project Close Date and Delivery Date. +- Quotation has Project Close Date and Delivery Date. +- Date fields use calendar pickers. +- Hot Project is auto-checked when Project Close Date is within 3 months. +- User can manually uncheck Hot Project. +- Manual override is preserved. +- Existing create/edit flows remain compatible. +- Typecheck, build, and PDF audit pass. + +--- + +## Implementation Result - 2026-07-01 + +Status: Completed + +Summary: +- Added `Project Close Date` and `Delivery Date` to opportunity and quotation persistence, DTOs, validation, and form UI. +- Added shared hot-project auto-suggestion logic plus persisted `hotProjectAutoSuggested` and `hotProjectManuallyOverridden`. +- Updated opportunity detail `Create Quotation` flow to pass current opportunity context into the quotation sheet, including project parties when already available. +- Updated quotation prefill logic so automatic population no longer overwrites fields the user already edited in the same open session. + +Verification: +- `npm run typecheck` passed. +- `npm run build` passed with existing Turbopack workspace-root and broad local storage path warnings. +- `npm run audit:pdf` passed and refreshed PDF audit artifacts. + +Implementation note: +- [task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md](/C:/Users/mtpphtaps/Documents/gitea/alla-allaos-fullstack/docs/implementation/task-d.6.2-opportunity-quotation-prefill-project-timeline-2026-07-01.md) diff --git a/src/app/api/crm/opportunities/[id]/route.ts b/src/app/api/crm/opportunities/[id]/route.ts index 26308fe..7a77ac1 100644 --- a/src/app/api/crm/opportunities/[id]/route.ts +++ b/src/app/api/crm/opportunities/[id]/route.ts @@ -16,10 +16,12 @@ type Params = { }; const opportunityRequestSchema = opportunitySchema.extend({ - contactId: z.string().nullable().optional(), - branchId: z.string().nullable().optional(), - leadChannel: z.string().nullable().optional(), - expectedCloseDate: z.string().nullable().optional() +contactId: z.string().nullable().optional(), +branchId: z.string().nullable().optional(), +leadChannel: z.string().nullable().optional(), +expectedCloseDate: z.string().nullable().optional(), +projectCloseDate: z.string().nullable().optional(), +deliveryDate: z.string().nullable().optional() }); export async function GET(_request: NextRequest, { params }: Params) { @@ -169,4 +171,3 @@ export async function DELETE(_request: NextRequest, { params }: Params) { return NextResponse.json({ message: 'Unable to delete opportunity' }, { status: 500 }); } } - diff --git a/src/app/api/crm/opportunities/route.ts b/src/app/api/crm/opportunities/route.ts index 0ba44f2..862eae5 100644 --- a/src/app/api/crm/opportunities/route.ts +++ b/src/app/api/crm/opportunities/route.ts @@ -12,7 +12,9 @@ const opportunityRequestSchema = opportunitySchema.extend({ assignedToUserId: z.string().nullable().optional(), branchId: z.string().nullable().optional(), leadChannel: z.string().nullable().optional(), - expectedCloseDate: z.string().nullable().optional() + expectedCloseDate: z.string().nullable().optional(), + projectCloseDate: z.string().nullable().optional(), + deliveryDate: z.string().nullable().optional() }); function buildAccessContext( diff --git a/src/db/schema.ts b/src/db/schema.ts index ae63003..f691071 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -497,10 +497,16 @@ export const crmOpportunities = pgTable( estimatedValue: doublePrecision('estimated_value'), chancePercent: integer('chance_percent'), expectedCloseDate: timestamp('expected_close_date', { withTimezone: true }), + projectCloseDate: timestamp('project_close_date', { withTimezone: true }), + deliveryDate: timestamp('delivery_date', { withTimezone: true }), competitor: text('competitor'), source: text('source'), notes: text('notes'), isHotProject: boolean('is_hot_project').default(false).notNull(), + hotProjectAutoSuggested: boolean('hot_project_auto_suggested').default(false).notNull(), + hotProjectManuallyOverridden: boolean('hot_project_manually_overridden') + .default(false) + .notNull(), isActive: boolean('is_active').default(true).notNull(), pipelineStage: text('pipeline_stage').default('lead').notNull(), closedAt: timestamp('closed_at', { withTimezone: true }), @@ -637,7 +643,13 @@ export const crmQuotations = pgTable( taxAmount: doublePrecision('tax_amount').default(0).notNull(), totalAmount: doublePrecision('total_amount').default(0).notNull(), chancePercent: integer('chance_percent'), + projectCloseDate: timestamp('project_close_date', { withTimezone: true }), + deliveryDate: timestamp('delivery_date', { withTimezone: true }), isHotProject: boolean('is_hot_project').default(false).notNull(), + hotProjectAutoSuggested: boolean('hot_project_auto_suggested').default(false).notNull(), + hotProjectManuallyOverridden: boolean('hot_project_manually_overridden') + .default(false) + .notNull(), competitor: text('competitor'), salesmanId: text('salesman_id'), isSent: boolean('is_sent').default(false).notNull(), diff --git a/src/features/crm/leads/components/lead-detail.tsx b/src/features/crm/leads/components/lead-detail.tsx index af04c5c..728b9eb 100644 --- a/src/features/crm/leads/components/lead-detail.tsx +++ b/src/features/crm/leads/components/lead-detail.tsx @@ -40,6 +40,9 @@ export function LeadDetail({ }) { const { data } = useSuspenseQuery(leadByIdOptions(leadId)); const lead = data.lead; + const priorityLabel = + referenceData.priorities.find((priority) => priority.id === lead.priority)?.label ?? + lead.priority; const [editOpen, setEditOpen] = useState(false); const [assignOpen, setAssignOpen] = useState(false); @@ -96,7 +99,7 @@ export function LeadDetail({ - + diff --git a/src/features/crm/opportunities/api/types.ts b/src/features/crm/opportunities/api/types.ts index bd29c48..cc1d19c 100644 --- a/src/features/crm/opportunities/api/types.ts +++ b/src/features/crm/opportunities/api/types.ts @@ -100,10 +100,14 @@ export interface OpportunityRecord { estimatedValue: number | null; chancePercent: number | null; expectedCloseDate: string | null; + projectCloseDate: string | null; + deliveryDate: string | null; competitor: string | null; source: string | null; notes: string | null; isHotProject: boolean; + hotProjectAutoSuggested: boolean; + hotProjectManuallyOverridden: boolean; isActive: boolean; pipelineStage: OpportunityPipelineStage; closedAt: string | null; @@ -266,9 +270,13 @@ export interface OpportunityMutationPayload { estimatedValue?: number | null; chancePercent?: number | null; expectedCloseDate?: string | null; + projectCloseDate?: string | null; + deliveryDate?: string | null; competitor?: string; source?: string; isHotProject?: boolean; + hotProjectAutoSuggested?: boolean; + hotProjectManuallyOverridden?: boolean; notes?: string; isActive?: boolean; projectParties?: OpportunityProjectPartyMutationPayload[]; diff --git a/src/features/crm/opportunities/components/opportunity-detail.tsx b/src/features/crm/opportunities/components/opportunity-detail.tsx index 21ccc49..7e4d8c2 100644 --- a/src/features/crm/opportunities/components/opportunity-detail.tsx +++ b/src/features/crm/opportunities/components/opportunity-detail.tsx @@ -110,10 +110,33 @@ export function OpportunityDetail({ () => new Map(referenceData.productTypes.map((item) => [item.id, item.label])), [referenceData] ); - const priorityMap = useMemo( - () => new Map(referenceData.priorities.map((item) => [item.id, item.label])), - [referenceData] - ); +const priorityMap = useMemo( +() => new Map(referenceData.priorities.map((item) => [item.id, item.label])), +[referenceData] +); +const quotationInitialPrefill = useMemo( +() => ({ +opportunityId: opportunity.id, +customerId: opportunity.customerId, +contactId: opportunity.contactId, +projectName: opportunity.projectName, +projectLocation: opportunity.projectLocation, +branchId: opportunity.branchId, +quotationType: opportunity.productType, +projectCloseDate: opportunity.projectCloseDate ? opportunity.projectCloseDate.slice(0, 10) : null, +deliveryDate: opportunity.deliveryDate ? opportunity.deliveryDate.slice(0, 10) : null, +isHotProject: opportunity.isHotProject, +hotProjectAutoSuggested: opportunity.hotProjectAutoSuggested, +hotProjectManuallyOverridden: opportunity.hotProjectManuallyOverridden, +projectParties: projectPartiesData.items.map((item) => ({ +key: item.id, +customerId: item.customerId, +role: item.role, +remark: item.remark ?? '' +})) +}), +[opportunity, projectPartiesData.items] +); const customer = customerMap.get(opportunity.customerId); const contact = opportunity.contactId ? contactMap.get(opportunity.contactId) : null; @@ -143,6 +166,7 @@ export function OpportunityDetail({ open={quotationOpen} onOpenChange={setQuotationOpen} referenceData={quotationReferenceData} + initialPrefill={quotationInitialPrefill} /> ) : null} @@ -208,6 +232,18 @@ export function OpportunityDetail({ : null } /> + + item.customerId && item.role) @@ -196,7 +206,25 @@ export function OpportunityFormSheet({ referenceData.customers.find((customer) => customer.id === selectedCustomerId)?.ownerUserId ?? ''; form.setFieldValue('assignedToUserId', ownerUserId); - }, [form, isEdit, open, referenceData.customers, selectedCustomerId]); +}, [form, isEdit, open, referenceData.customers, selectedCustomerId]); + +useEffect(() => { +if (!open) { +return; +} + +const projectCloseDate = form.getFieldValue('projectCloseDate'); +const manuallyOverridden = form.getFieldValue('hotProjectManuallyOverridden'); + +if (manuallyOverridden) { +form.setFieldValue('hotProjectAutoSuggested', isHotProjectSuggested(projectCloseDate)); +return; +} + +const suggested = isHotProjectSuggested(projectCloseDate); +form.setFieldValue('hotProjectAutoSuggested', suggested); +form.setFieldValue('isHotProject', suggested); +}, [form, open, form.state.values.projectCloseDate, form.state.values.hotProjectManuallyOverridden]); const isPending = createMutation.isPending || updateMutation.isPending; @@ -376,6 +404,14 @@ export function OpportunityFormSheet({ name='expectedCloseDate' label='วันที่คาดว่าจะปิดการขาย' /> + +
- ( + + +
+ โครงการด่วน + + ใช้สำหรับงานเร่งด่วนหรือโครงการสำคัญเชิงกลยุทธ์ + +
+ { + field.handleChange(checked); + field.handleBlur(); + form.setFieldValue('hotProjectManuallyOverridden', true); + form.setFieldValue( + 'hotProjectAutoSuggested', + isHotProjectSuggested(form.getFieldValue('projectCloseDate')) + ); + }} + /> +
+ +
+ )} /> ); } - diff --git a/src/features/crm/opportunities/schemas/opportunity.schema.ts b/src/features/crm/opportunities/schemas/opportunity.schema.ts index 781d6fb..d59d14c 100644 --- a/src/features/crm/opportunities/schemas/opportunity.schema.ts +++ b/src/features/crm/opportunities/schemas/opportunity.schema.ts @@ -1,4 +1,5 @@ import * as z from 'zod'; +import { isValidDateOnlyString } from '@/features/crm/shared/hot-project'; export { opportunityMarkCancelledSchema, @@ -36,6 +37,14 @@ function coerceOptionalNumber(message: string) { }, z.number().refine((value) => !Number.isNaN(value), message).optional()); } +function optionalDateOnly(message: string) { + return z + .string() + .optional() + .nullable() + .refine((value) => !value || isValidDateOnlyString(value), message); +} + export const opportunitySchema = z.object({ customerId: z.string().min(1, 'Please select customer'), contactId: z.string().optional().nullable(), @@ -58,10 +67,14 @@ export const opportunitySchema = z.object({ (value) => value === undefined || (value >= 0 && value <= 100), 'Chance percent must be between 0 and 100' ), - expectedCloseDate: z.string().optional().nullable(), + expectedCloseDate: optionalDateOnly('Expected close date must be YYYY-MM-DD'), + projectCloseDate: optionalDateOnly('Project close date must be YYYY-MM-DD'), + deliveryDate: optionalDateOnly('Delivery date must be YYYY-MM-DD'), competitor: z.string().optional(), source: z.string().optional(), isHotProject: z.boolean().default(false), + hotProjectAutoSuggested: z.boolean().default(false), + hotProjectManuallyOverridden: z.boolean().default(false), notes: z.string().optional(), isActive: z.boolean().default(true), projectParties: z diff --git a/src/features/crm/opportunities/server/service.ts b/src/features/crm/opportunities/server/service.ts index 98d11eb..bb16e9e 100644 --- a/src/features/crm/opportunities/server/service.ts +++ b/src/features/crm/opportunities/server/service.ts @@ -43,6 +43,7 @@ import type { OpportunityRecord, OpportunityReferenceData } from '../api/types'; +import { resolveHotProjectState } from '@/features/crm/shared/hot-project'; import { buildProjectPartyKey, PROJECT_PARTY_OPTION_CATEGORY, @@ -148,10 +149,14 @@ function mapOpportunityRecord( estimatedValue: row.estimatedValue, chancePercent: row.chancePercent, expectedCloseDate: row.expectedCloseDate?.toISOString() ?? null, + projectCloseDate: row.projectCloseDate?.toISOString() ?? null, + deliveryDate: row.deliveryDate?.toISOString() ?? null, competitor: row.competitor, source: row.source, notes: row.notes, isHotProject: row.isHotProject, + hotProjectAutoSuggested: row.hotProjectAutoSuggested, + hotProjectManuallyOverridden: row.hotProjectManuallyOverridden, isActive: row.isActive, pipelineStage: row.pipelineStage as OpportunityPipelineStage, closedAt: row.closedAt?.toISOString() ?? null, @@ -1150,6 +1155,7 @@ export async function createOpportunity( payload: OpportunityMutationPayload ) { await validateOpportunityPayload(organizationId, payload, accessContext); + const hotProjectState = resolveHotProjectState(payload); const pipelineStage = await resolvePipelineStageForCreate(accessContext.businessRole); const documentCode = await generateNextDocumentCode({ @@ -1180,10 +1186,14 @@ export async function createOpportunity( estimatedValue: payload.estimatedValue ?? null, chancePercent: payload.chancePercent ?? null, expectedCloseDate: payload.expectedCloseDate ? new Date(payload.expectedCloseDate) : null, + projectCloseDate: payload.projectCloseDate ? new Date(payload.projectCloseDate) : null, + deliveryDate: payload.deliveryDate ? new Date(payload.deliveryDate) : null, competitor: payload.competitor?.trim() || null, source: payload.source?.trim() || null, notes: payload.notes?.trim() || null, - isHotProject: payload.isHotProject ?? false, + isHotProject: hotProjectState.isHotProject, + hotProjectAutoSuggested: hotProjectState.hotProjectAutoSuggested, + hotProjectManuallyOverridden: hotProjectState.hotProjectManuallyOverridden, isActive: payload.isActive ?? true, pipelineStage, assignedToUserId: payload.assignedToUserId ?? null, @@ -1215,6 +1225,7 @@ export async function updateOpportunity( accessContext?: OpportunityAccessContext ) { await validateOpportunityPayload(organizationId, payload, accessContext); + const hotProjectState = resolveHotProjectState(payload); const current = await assertOpportunityBelongsToOrganization(id, organizationId, accessContext); assertOpportunityOpenForEditing(current); const pipelineStage = await resolvePipelineStageForUpdate(current); @@ -1238,10 +1249,14 @@ export async function updateOpportunity( estimatedValue: payload.estimatedValue ?? null, chancePercent: payload.chancePercent ?? null, expectedCloseDate: payload.expectedCloseDate ? new Date(payload.expectedCloseDate) : null, + projectCloseDate: payload.projectCloseDate ? new Date(payload.projectCloseDate) : null, + deliveryDate: payload.deliveryDate ? new Date(payload.deliveryDate) : null, competitor: payload.competitor?.trim() || null, source: payload.source?.trim() || null, notes: payload.notes?.trim() || null, - isHotProject: payload.isHotProject ?? false, + isHotProject: hotProjectState.isHotProject, + hotProjectAutoSuggested: hotProjectState.hotProjectAutoSuggested, + hotProjectManuallyOverridden: hotProjectState.hotProjectManuallyOverridden, isActive: payload.isActive ?? true, pipelineStage, updatedBy: userId, diff --git a/src/features/crm/quotations/api/types.ts b/src/features/crm/quotations/api/types.ts index 1727277..5f327e1 100644 --- a/src/features/crm/quotations/api/types.ts +++ b/src/features/crm/quotations/api/types.ts @@ -37,6 +37,12 @@ export interface QuotationOpportunityLookup { projectName: string | null; projectLocation: string | null; branchId: string | null; + productType: string; + projectCloseDate: string | null; + deliveryDate: string | null; + isHotProject: boolean; + hotProjectAutoSuggested: boolean; + hotProjectManuallyOverridden: boolean; } export interface QuotationSalesmanLookup { @@ -121,7 +127,11 @@ export interface QuotationRecord { taxAmount: number; totalAmount: number; chancePercent: number | null; + projectCloseDate: string | null; + deliveryDate: string | null; isHotProject: boolean; + hotProjectAutoSuggested: boolean; + hotProjectManuallyOverridden: boolean; competitor: string | null; salesmanId: string | null; salesmanName: string | null; @@ -381,7 +391,11 @@ export interface QuotationMutationPayload { exchangeRate?: number | null; status: string; chancePercent?: number | null; + projectCloseDate?: string | null; + deliveryDate?: string | null; isHotProject?: boolean; + hotProjectAutoSuggested?: boolean; + hotProjectManuallyOverridden?: boolean; competitor?: string; reference?: string; notes?: string; diff --git a/src/features/crm/quotations/components/quotation-detail.tsx b/src/features/crm/quotations/components/quotation-detail.tsx index 735e336..45f9040 100644 --- a/src/features/crm/quotations/components/quotation-detail.tsx +++ b/src/features/crm/quotations/components/quotation-detail.tsx @@ -1,42 +1,48 @@ -'use client'; +"use client"; -import Link from 'next/link'; -import { useMemo, useState } from 'react'; -import { useMutation, useSuspenseQuery } from '@tanstack/react-query'; -import { toast } from 'sonner'; -import { AlertModal } from '@/components/modal/alert-modal'; -import { Icons } from '@/components/icons'; -import { Badge } from '@/components/ui/badge'; -import { Button } from '@/components/ui/button'; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; +import Link from "next/link"; +import { useMemo, useState } from "react"; +import { useMutation, useSuspenseQuery } from "@tanstack/react-query"; +import { toast } from "sonner"; +import { AlertModal } from "@/components/modal/alert-modal"; +import { Icons } from "@/components/icons"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, - DialogTitle -} from '@/components/ui/dialog'; -import { Input } from '@/components/ui/input'; -import { Separator } from '@/components/ui/separator'; + DialogTitle, +} from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Separator } from "@/components/ui/separator"; import { Select, SelectContent, SelectItem, SelectTrigger, - SelectValue -} from '@/components/ui/select'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; -import { AuditLogTab } from '@/features/crm/components/audit-log-tab'; -import { formatDate, formatDateTime } from '@/lib/date-format'; -import { formatNumber } from '@/lib/number-format'; + SelectValue, +} from "@/components/ui/select"; +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { AuditLogTab } from "@/features/crm/components/audit-log-tab"; +import { formatDate, formatDateTime } from "@/lib/date-format"; +import { formatNumber } from "@/lib/number-format"; import { CrmCurrencyInput, CrmDateInput, CrmNumberInput, CrmPercentageInput, - CrmTextarea -} from '@/features/crm/components/crm-form-controls'; + CrmTextarea, +} from "@/features/crm/components/crm-form-controls"; import { createQuotationAttachmentMutation, createQuotationCustomerMutation, @@ -54,8 +60,8 @@ import { updateQuotationCustomerMutation, updateQuotationFollowupMutation, updateQuotationItemMutation, - updateQuotationTopicMutation -} from '../api/mutations'; + updateQuotationTopicMutation, +} from "../api/mutations"; import { quotationAttachmentsOptions, quotationByIdOptions, @@ -64,12 +70,12 @@ import { quotationItemsOptions, quotationKeys, quotationRevisionsOptions, - quotationTopicsOptions -} from '../api/queries'; + quotationTopicsOptions, +} from "../api/queries"; import { downloadApprovedQuotationPdf, - downloadQuotationCustomerPackage -} from '../api/service'; + downloadQuotationCustomerPackage, +} from "../api/service"; import type { QuotationAttachmentMutationPayload, QuotationAttachmentRecord, @@ -82,33 +88,39 @@ import type { QuotationItemRecord, QuotationReferenceData, QuotationTopicMutationPayload, - QuotationTopicRecord -} from '../api/types'; -import { submitQuotationApprovalMutation } from '@/features/foundation/approval/mutations'; -import { quotationDocumentKeys } from '@/features/crm/quotations/document/queries'; + QuotationTopicRecord, +} from "../api/types"; +import { submitQuotationApprovalMutation } from "@/features/foundation/approval/mutations"; +import { quotationDocumentKeys } from "@/features/crm/quotations/document/queries"; import { getCustomerPackageRoleLabel, getCustomerPackageUiStatus, - mapCustomerPackageErrorMessage -} from '../customer-package'; -import { QuotationDocumentPreview } from './quotation-document-preview'; -import { QuotationFormSheet } from './quotation-form-sheet'; -import { QuotationApprovalTab } from './quotation-approval-tab'; -import { QuotationStatusBadge } from './quotation-status-badge'; -import { getQueryClient } from '@/lib/query-client'; + mapCustomerPackageErrorMessage, +} from "../customer-package"; +import { QuotationDocumentPreview } from "./quotation-document-preview"; +import { QuotationFormSheet } from "./quotation-form-sheet"; +import { QuotationApprovalTab } from "./quotation-approval-tab"; +import { QuotationStatusBadge } from "./quotation-status-badge"; +import { getQueryClient } from "@/lib/query-client"; -function FieldItem({ label, value }: { label: string; value: string | null | undefined }) { +function FieldItem({ + label, + value, +}: { + label: string; + value: string | null | undefined; +}) { return ( -
-
{label}
-
{value ?? '-'}
+
+
{label}
+
{value ?? "-"}
); } function EmptyState({ message }: { message: string }) { return ( -
+
{message}
); @@ -116,7 +128,7 @@ function EmptyState({ message }: { message: string }) { function downloadBlobFile(blob: Blob, fileName: string) { const url = URL.createObjectURL(blob); - const anchor = document.createElement('a'); + const anchor = document.createElement("a"); anchor.href = url; anchor.download = fileName; document.body.append(anchor); @@ -126,21 +138,27 @@ function downloadBlobFile(blob: Blob, fileName: string) { } function CustomerPackageSourceItem({ - item + item, }: { item: QuotationCustomerPackageSource; }) { return ( -
-
- {getCustomerPackageRoleLabel(item.role)} - {item.sourceType === 'generated' ? 'Generated' : 'Library'} +
+
+ + {getCustomerPackageRoleLabel(item.role)} + + + {item.sourceType === "generated" ? "Generated" : "Library"} +
-
{item.fileName}
-
- {item.pageCount ? `${formatNumber(item.pageCount)} page(s)` : 'Page count unavailable'} - {item.fileSize ? ` • ${formatNumber(item.fileSize)} bytes` : ''} - {item.checksum ? ` • ${item.checksum.slice(0, 16)}` : ''} +
{item.fileName}
+
+ {item.pageCount + ? `${formatNumber(item.pageCount)} page(s)` + : "Page count unavailable"} + {item.fileSize ? ` • ${formatNumber(item.fileSize)} bytes` : ""} + {item.checksum ? ` • ${item.checksum.slice(0, 16)}` : ""}
); @@ -152,7 +170,7 @@ function ItemDialog({ onSubmit, pending, referenceData, - item + item, }: { open: boolean; onOpenChange: (open: boolean) => void; @@ -162,31 +180,35 @@ function ItemDialog({ item?: QuotationItemRecord; }) { const [values, setValues] = useState({ - productType: item?.productType ?? referenceData.productTypes[0]?.id ?? '', - description: item?.description ?? '', + productType: item?.productType ?? referenceData.productTypes[0]?.id ?? "", + description: item?.description ?? "", quantity: String(item?.quantity ?? 1), - unit: item?.unit ?? '', + unit: item?.unit ?? "", unitPrice: String(item?.unitPrice ?? 0), discount: String(item?.discount ?? 0), - discountType: item?.discountType ?? '', + discountType: item?.discountType ?? "", taxRate: String(item?.taxRate ?? 0), - notes: item?.notes ?? '' + notes: item?.notes ?? "", }); return ( - {item ? 'Edit Item' : 'Add Item'} - Line items drive quotation totals from the server. + {item ? "Edit Item" : "Add Item"} + + Line items drive quotation totals from the server. + -
+
setValues((s) => ({ ...s, description: e.target.value }))} - placeholder='Description' + onChange={(e) => + setValues((s) => ({ ...s, description: e.target.value })) + } + placeholder="Description" /> -
+
setValues((s) => ({ ...s, quantity: value }))} - placeholder='Quantity' + onChange={(value) => + setValues((s) => ({ ...s, quantity: value })) + } + placeholder="Quantity" />
-
+
setValues((s) => ({ ...s, unitPrice: value }))} - placeholder='Unit price' - currencyLabel='THB' + onChange={(value) => + setValues((s) => ({ ...s, unitPrice: value })) + } + placeholder="Unit price" + currencyLabel="THB" /> setValues((s) => ({ ...s, discount: value }))} - placeholder='Discount' - currencyLabel='THB' + onChange={(value) => + setValues((s) => ({ ...s, discount: value })) + } + placeholder="Discount" + currencyLabel="THB" />
-
+
- + {referenceData.customers.map((item) => ( @@ -352,7 +388,7 @@ function CustomerDialog({ setRemark(event.target.value)} - placeholder='Remark' + placeholder="Remark" />
-
-
-
-
- - {quotation.code} - + + {quotation.code} + + {quotation.isHotProject ? Hot : null}
-

- {quotation.projectName || 'Untitled quotation'} +

+ {quotation.projectName || "Untitled quotation"}

-

- {customer?.name ?? 'Unknown customer'} - {contact ? ` - ${contact.name}` : ''} +

+ {customer?.name ?? "Unknown customer"} + {contact ? ` - ${contact.name}` : ""}

-
+
{canSubmitCurrentQuotation ? ( ) : null} {canCreateRevision && canReviseByStatus ? ( ) : null} {canUpdate ? ( - ) : null}
-
-
+
+
- - - - Overview - Documents - Customer Package - Items - ผู้เกี่ยวข้องในโครงการ - Topics - Follow-ups - Attachments - Audit Log - Approval - + + + + Overview + Documents + + Customer Package + + Items + + ผู้เกี่ยวข้องในโครงการ + + Topics + Follow-ups + Attachments + Audit Log + Approval - + Overview @@ -1245,92 +1406,125 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( Commercial header data and quotation summary. - - - + - + + + - + - - - + + + -
-
-
ผู้เกี่ยวข้องในโครงการ
+
+
+
+ ผู้เกี่ยวข้องในโครงการ +
{!customersData.items.length ? ( -
+
No project parties have been added yet.
) : ( -
+
{customersData.items.map((item) => ( -
-
{item.customerName}
-
+
+
+ {item.customerName} +
+
Role: {item.roleLabel ?? item.roleCode}
- {item.remark ?
{item.remark}
: null} + {item.remark ? ( +
{item.remark}
+ ) : null}
))}
)}
-
+
-
+
-
- +
+
- + - +
Items @@ -1344,45 +1538,48 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( setItemOpen(true); }} > - Add Item + Add Item ) : null} - + {!itemsData.items.length ? ( - + ) : ( itemsData.items.map((item) => ( -
-
-
-
{item.description}
-
- Qty {item.quantity} {item.unit || ''} x{' '} +
+
+
+
+ {item.description} +
+
+ Qty {item.quantity} {item.unit || ""} x{" "} {formatNumber(item.unitPrice)}
-
+
Total {formatNumber(item.totalPrice)}
{canManageItems ? ( -
+
) : null} @@ -1394,13 +1591,14 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( - + - +
ผู้เกี่ยวข้องในโครงการ - Related companies for this quotation, each with a visible role. + Related companies for this quotation, each with a + visible role.
{canManageCustomers ? ( @@ -1410,48 +1608,51 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( setCustomerOpen(true); }} > - Add Party + Add Party ) : null}
- + {!customersData.items.length ? ( - + ) : ( customersData.items.map((item) => (
-
{item.customerName}
-
+
+ {item.customerName} +
+
Role: {item.roleLabel ?? item.roleCode}
{item.remark ? ( -
+
{item.remark}
) : null}
{canManageCustomers ? ( -
+
) : null} @@ -1462,13 +1663,14 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( - + - +
Topics - Scope, exclusions, payment terms, and other document sections. + Scope, exclusions, payment terms, and other document + sections.
{canManageTopics ? ( @@ -1478,46 +1680,48 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( setTopicOpen(true); }} > - Add Topic + Add Topic ) : null}
- + {!topicsData.items.length ? ( - + ) : ( topicsData.items.map((topic) => ( -
-
+
+
-
{topic.title}
-
- {topicTypeMap.get(topic.topicType)?.label ?? topic.topicType} +
{topic.title}
+
+ {topicTypeMap.get(topic.topicType)?.label ?? + topic.topicType}
{canManageTopics ? ( -
+
) : null}
-
    +
      {topic.items.map((item) => (
    • {item.content}
    • ))} @@ -1529,12 +1733,14 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( - + - +
      Follow-ups - Commercial chasing and response history. + + Commercial chasing and response history. +
      {canManageFollowups ? ( ) : null}
      - + {!followupsData.items.length ? ( - + ) : ( followupsData.items.map((item) => ( -
      -
      -
      -
      - {followupTypeMap.get(item.followupType)?.label ?? - item.followupType} +
      +
      +
      +
      + {followupTypeMap.get(item.followupType) + ?.label ?? item.followupType}
      -
      +
      {formatDate(item.followupDate)} - {item.outcome ? ` - ${item.outcome}` : ''} + {item.outcome ? ` - ${item.outcome}` : ""} +
      +
      + {item.notes || "-"}
      -
      {item.notes || '-'}
      {canManageFollowups ? ( -
      +
      ) : null} @@ -1594,13 +1803,14 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( - + - +
      Attachments - Metadata only in Task E, ready for storage integration later. + Metadata only in Task E, ready for storage integration + later.
      {canManageAttachments ? ( @@ -1610,44 +1820,49 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( setAttachmentOpen(true); }} > - Add Attachment + Add Attachment ) : null}
      - + {!attachmentsData.items.length ? ( - + ) : ( attachmentsData.items.map((item) => (
      -
      {item.originalFileName}
      -
      - {item.fileType || 'Unknown type'} - {item.fileSize ? ` - ${formatNumber(item.fileSize)} bytes` : ''} +
      + {item.originalFileName} +
      +
      + {item.fileType || "Unknown type"} + {item.fileSize + ? ` - ${formatNumber(item.fileSize)} bytes` + : ""}
      {canManageAttachments ? ( -
      +
      ) : null} @@ -1658,15 +1873,15 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( - + - + - -
      + +
      Documents - Working documents, official documents, and customer package follow the quotation lifecycle. + Working documents, official documents, and customer + package follow the quotation lifecycle. - - + + {/* Working Documents @@ -1727,9 +1943,9 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( )}
      - + */} - + {/* Official Documents @@ -1772,81 +1988,104 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( ) : null}
      - + */} - Customer Package + PDF - Customer-deliverable package assembled from the approved PDF plus active document library appendices. + Customer-deliverable package assembled from the + approved PDF plus active document library + appendices. - - + + -
      +
      {customerPackageStatusDescription}
      -
      - {customerPackage?.includedDocuments.map((item) => ( - - {getCustomerPackageRoleLabel(item.role)} - - ))} +
      + {customerPackage?.includedDocuments.map( + (item) => ( + + {getCustomerPackageRoleLabel(item.role)} + + ), + )}
      -
      +
      {canGenerateCustomerPackage ? ( ) : null} {canPreviewCustomerPackage && customerPackage ? ( - ) : ( - )} {canDownloadCustomerPackage ? ( ) : null} -
      @@ -1855,7 +2094,10 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( {canPreviewDocument ? ( -
      +
      ) : ( @@ -1863,73 +2105,88 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( Working Document Preview - Preview permission is required to load working document data. + Preview permission is required to load working + document data. - + )}
      - + - +
      Customer Package - Operational detail for the assembled customer-deliverable package. + Operational detail for the assembled + customer-deliverable package.
      -
      +
      {canGenerateCustomerPackage ? ( ) : null} {canPreviewCustomerPackage && customerPackage ? ( - ) : ( - )} {canDownloadCustomerPackage ? ( ) : null}
      - - {!canGenerateCustomerPackage && !canDownloadCustomerPackage && !canPreviewCustomerPackage ? ( - + + {!canGenerateCustomerPackage && + !canDownloadCustomerPackage && + !canPreviewCustomerPackage ? ( + ) : ( <> -
      - +
      + - +
      -
      +
      {customerPackageStatusDescription}
      {customerPackage?.warnings.length ? ( -
      -
      Warnings
      +
      +
      + Warnings +
      {customerPackage.warnings.map((warning) => ( -
      +
      {warning.message}
      ))}
      ) : null} -
      -
      Included Documents
      +
      +
      + Included Documents +
      {!customerPackage?.includedDocuments.length ? ( - + ) : ( -
      - {customerPackage.includedDocuments.map((item) => ( - - ))} +
      + {customerPackage.includedDocuments.map( + (item) => ( + + ), + )}
      )}
      @@ -2004,12 +2282,13 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( )} - + +
      -
      +
      Revision Chain @@ -2017,24 +2296,24 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( Family of quotations copied from the same parent record. - + {!revisionsData.items.length ? ( - + ) : ( revisionsData.items.map((item) => ( -
      +
      -
      {item.code}
      -
      +
      {item.code}
      +
      {formatNumber(item.totalAmount)}
      - +
      )) @@ -2045,39 +2324,49 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes( Record Snapshot - Operational metadata for this quotation row. + + Operational metadata for this quotation row. + - - - + + + -
      -
      Artifact Status
      -
      +
      +
      + Artifact Status +
      +
      {quotation.approvedArtifact ? ( {quotation.approvedArtifact.status} ) : ( - - + - )} {quotation.approvedArtifact?.lockedAt ? ( - - Locked {formatDateTime(quotation.approvedArtifact.lockedAt)} + + Locked{" "} + {formatDateTime(quotation.approvedArtifact.lockedAt)} ) : null}
      {quotation.hasLegacyApprovedPdf ? ( -
      -
      Legacy approved PDF detected
      -
      - This quotation still points to the old `public/generated` storage path and has - not been migrated into the artifact storage model yet. +
      +
      + Legacy approved PDF detected +
      +
      + This quotation still points to the old `public/generated` + storage path and has not been migrated into the artifact + storage model yet.
      ) : null} @@ -2133,8 +2432,3 @@ const canReviseByStatus = ['accepted', 'rejected', 'sent', 'approved'].includes(
      ); } - - - - - diff --git a/src/features/crm/quotations/components/quotation-form-sheet.tsx b/src/features/crm/quotations/components/quotation-form-sheet.tsx index 09445f6..815647a 100644 --- a/src/features/crm/quotations/components/quotation-form-sheet.tsx +++ b/src/features/crm/quotations/components/quotation-form-sheet.tsx @@ -6,10 +6,11 @@ import { useMutation, useQuery } from '@tanstack/react-query'; import { toast } from 'sonner'; import { Icons } from '@/components/icons'; import { Button } from '@/components/ui/button'; -import { - ProjectPartiesEditor, - type ProjectPartyEditorItem -} from '@/features/crm/components/project-parties-editor'; +import { Input } from '@/components/ui/input'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; +import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from '@/components/ui/sheet'; +import { Switch } from '@/components/ui/switch'; +import { ProjectPartiesEditor, type ProjectPartyEditorItem } from '@/features/crm/components/project-parties-editor'; import { CrmCurrencyInput, CrmDateInput, @@ -17,26 +18,16 @@ import { CrmPercentageInput, CrmTextarea } from '@/features/crm/components/crm-form-controls'; -import { Input } from '@/components/ui/input'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue -} from '@/components/ui/select'; -import { - Sheet, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle -} from '@/components/ui/sheet'; -import { Switch } from '@/components/ui/switch'; -import { quotationCustomersOptions } from '../api/queries'; +import { isHotProjectSuggested } from '@/features/crm/shared/hot-project'; import { createQuotationMutation, updateQuotationMutation } from '../api/mutations'; -import type { QuotationMutationPayload, QuotationRecord, QuotationReferenceData } from '../api/types'; +import { quotationCustomersOptions } from '../api/queries'; +import type { + QuotationMutationPayload, + QuotationOpportunityLookup, + QuotationRecord, + QuotationReferenceData +} from '../api/types'; +import { quotationSchema } from '../schemas/quotation.schema'; type FormState = { opportunityId: string; @@ -53,6 +44,8 @@ type FormState = { exchangeRate: string; status: string; chancePercent: string; + projectCloseDate: string; + deliveryDate: string; competitor: string; reference: string; notes: string; @@ -63,32 +56,105 @@ type FormState = { sentVia: string; revisionRemark: string; isHotProject: boolean; + hotProjectAutoSuggested: boolean; + hotProjectManuallyOverridden: boolean; isActive: boolean; }; +export interface QuotationCreatePrefill { + opportunityId?: string | null; + customerId?: string | null; + contactId?: string | null; + projectName?: string | null; + projectLocation?: string | null; + branchId?: string | null; + quotationType?: string | null; + projectCloseDate?: string | null; + deliveryDate?: string | null; + isHotProject?: boolean | null; + hotProjectAutoSuggested?: boolean | null; + hotProjectManuallyOverridden?: boolean | null; + projectParties?: ProjectPartyEditorItem[]; +} + +type PrefillFieldKey = + | 'customerId' + | 'contactId' + | 'projectName' + | 'projectLocation' + | 'branchId' + | 'quotationType' + | 'projectCloseDate' + | 'deliveryDate' + | 'isHotProject' + | 'hotProjectAutoSuggested' + | 'hotProjectManuallyOverridden'; + +const PREFILL_FIELD_KEYS: PrefillFieldKey[] = [ + 'customerId', + 'contactId', + 'projectName', + 'projectLocation', + 'branchId', + 'quotationType', + 'projectCloseDate', + 'deliveryDate', + 'isHotProject', + 'hotProjectAutoSuggested', + 'hotProjectManuallyOverridden' +]; + +function toOpportunityPrefill( + opportunity: QuotationOpportunityLookup | undefined, + referenceData: QuotationReferenceData +): QuotationCreatePrefill | null { + if (!opportunity) { + return null; + } + + const quotationType = referenceData.quotationTypes.some((item) => item.id === opportunity.productType) + ? opportunity.productType + : null; + + return { + opportunityId: opportunity.id, + customerId: opportunity.customerId, + contactId: opportunity.contactId, + projectName: opportunity.projectName, + projectLocation: opportunity.projectLocation, + branchId: opportunity.branchId, + quotationType, + projectCloseDate: opportunity.projectCloseDate ? opportunity.projectCloseDate.slice(0, 10) : null, + deliveryDate: opportunity.deliveryDate ? opportunity.deliveryDate.slice(0, 10) : null, + isHotProject: opportunity.isHotProject, + hotProjectAutoSuggested: opportunity.hotProjectAutoSuggested, + hotProjectManuallyOverridden: opportunity.hotProjectManuallyOverridden + }; +} + function toFormState( quotation: QuotationRecord | undefined, - referenceData: QuotationReferenceData + referenceData: QuotationReferenceData, + initialPrefill?: QuotationCreatePrefill | null ): FormState { return { - opportunityId: quotation?.opportunityId ?? '', - customerId: quotation?.customerId ?? referenceData.customers[0]?.id ?? '', - contactId: quotation?.contactId ?? '', - quotationDate: - quotation?.quotationDate?.slice(0, 10) ?? new Date().toISOString().slice(0, 10), + opportunityId: quotation?.opportunityId ?? initialPrefill?.opportunityId ?? '', + customerId: quotation?.customerId ?? initialPrefill?.customerId ?? referenceData.customers[0]?.id ?? '', + contactId: quotation?.contactId ?? initialPrefill?.contactId ?? '', + quotationDate: quotation?.quotationDate?.slice(0, 10) ?? new Date().toISOString().slice(0, 10), validUntil: quotation?.validUntil?.slice(0, 10) ?? '', - quotationType: quotation?.quotationType ?? referenceData.quotationTypes[0]?.id ?? '', - projectName: quotation?.projectName ?? '', - projectLocation: quotation?.projectLocation ?? '', + quotationType: + quotation?.quotationType ?? initialPrefill?.quotationType ?? referenceData.quotationTypes[0]?.id ?? '', + projectName: quotation?.projectName ?? initialPrefill?.projectName ?? '', + projectLocation: quotation?.projectLocation ?? initialPrefill?.projectLocation ?? '', attention: quotation?.attention ?? '', - branchId: quotation?.branchId ?? '', + branchId: quotation?.branchId ?? initialPrefill?.branchId ?? '', currency: quotation?.currency ?? referenceData.currencies[0]?.id ?? '', exchangeRate: String(quotation?.exchangeRate ?? 1), status: quotation?.status ?? referenceData.statuses[0]?.id ?? '', - chancePercent: - quotation?.chancePercent === null || quotation?.chancePercent === undefined - ? '' - : String(quotation.chancePercent), + chancePercent: quotation?.chancePercent !== null && quotation?.chancePercent !== undefined ? String(quotation.chancePercent) : '', + projectCloseDate: quotation?.projectCloseDate?.slice(0, 10) ?? initialPrefill?.projectCloseDate ?? '', + deliveryDate: quotation?.deliveryDate?.slice(0, 10) ?? initialPrefill?.deliveryDate ?? '', competitor: quotation?.competitor ?? '', reference: quotation?.reference ?? '', notes: quotation?.notes ?? '', @@ -98,25 +164,23 @@ function toFormState( taxRate: String(quotation?.taxRate ?? 0), sentVia: quotation?.sentVia ?? '', revisionRemark: quotation?.revisionRemark ?? '', - isHotProject: quotation?.isHotProject ?? false, + isHotProject: quotation?.isHotProject ?? initialPrefill?.isHotProject ?? false, + hotProjectAutoSuggested: + quotation?.hotProjectAutoSuggested ?? initialPrefill?.hotProjectAutoSuggested ?? false, + hotProjectManuallyOverridden: + quotation?.hotProjectManuallyOverridden ?? initialPrefill?.hotProjectManuallyOverridden ?? false, isActive: quotation?.isActive ?? true }; } function Field({ label, - required = false, - children, - className -}: { - label: string; - required?: boolean; - children: React.ReactNode; - className?: string; -}) { + required, + children +}: React.PropsWithChildren<{ label: string; required?: boolean }>) { return ( -
      -
      +
      +
      {label} {required ? ' *' : ''}
      @@ -129,20 +193,28 @@ export function QuotationFormSheet({ quotation, open, onOpenChange, - referenceData + referenceData, + initialPrefill }: { quotation?: QuotationRecord; open: boolean; onOpenChange: (open: boolean) => void; referenceData: QuotationReferenceData; + initialPrefill?: QuotationCreatePrefill | null; }) { - const isEdit = !!quotation; - const defaultState = useMemo(() => toFormState(quotation, referenceData), [quotation, referenceData]); + const isEdit = Boolean(quotation); + const defaultState = useMemo( + () => toFormState(quotation, referenceData, initialPrefill), + [quotation, referenceData, initialPrefill] + ); const [state, setState] = useState(defaultState); const [projectParties, setProjectParties] = useState([]); + const [dirtyFields, setDirtyFields] = useState>(new Set()); + const [projectPartiesDirty, setProjectPartiesDirty] = useState(false); + const projectPartiesQuery = useQuery({ ...quotationCustomersOptions(quotation?.id ?? ''), - enabled: open && !!quotation?.id + enabled: open && Boolean(quotation?.id) }); const createMutation = useMutation({ @@ -151,8 +223,9 @@ export function QuotationFormSheet({ toast.success('Quotation created successfully'); onOpenChange(false); }, - onError: (error) => - toast.error(error instanceof Error ? error.message : 'Failed to create quotation') + onError: (error) => { + toast.error(error instanceof Error ? error.message : 'Failed to create quotation'); + } }); const updateMutation = useMutation({ @@ -161,46 +234,127 @@ export function QuotationFormSheet({ toast.success('Quotation updated successfully'); onOpenChange(false); }, - onError: (error) => - toast.error(error instanceof Error ? error.message : 'Failed to update quotation') + onError: (error) => { + toast.error(error instanceof Error ? error.message : 'Failed to update quotation'); + } }); useEffect(() => { - if (open) { - setState(defaultState); - setProjectParties( - quotation - ? (projectPartiesQuery.data?.items ?? []).map((item) => ({ - key: item.id, - customerId: item.customerId, - role: item.role, - remark: item.remark ?? '' - })) - : [] - ); + if (!open) { + return; } - }, [defaultState, open, projectPartiesQuery.data?.items, quotation]); + + setState(defaultState); + setDirtyFields(new Set()); + setProjectPartiesDirty(false); + + if (quotation) { + setProjectParties( + (projectPartiesQuery.data?.items ?? []).map((item) => ({ + key: item.id, + customerId: item.customerId, + role: item.role, + remark: item.remark ?? '' + })) + ); + return; + } + + setProjectParties(initialPrefill?.projectParties ?? []); + }, [defaultState, initialPrefill, open, projectPartiesQuery.data?.items, quotation]); + + useEffect(() => { + if (!open) { + return; + } + + const suggested = isHotProjectSuggested(state.projectCloseDate); + + setState((current) => { + if (current.hotProjectManuallyOverridden) { + if (current.hotProjectAutoSuggested === suggested) { + return current; + } + + return { ...current, hotProjectAutoSuggested: suggested }; + } + + if (current.hotProjectAutoSuggested === suggested && current.isHotProject === suggested) { + return current; + } + + return { + ...current, + isHotProject: suggested, + hotProjectAutoSuggested: suggested + }; + }); + }, [open, state.projectCloseDate, state.hotProjectManuallyOverridden]); const contacts = useMemo( () => referenceData.contacts.filter((item) => item.customerId === state.customerId), [referenceData.contacts, state.customerId] ); - function setField(key: K, value: FormState[K]) { + function markDirty(key: string) { + setDirtyFields((current) => { + const next = new Set(current); + next.add(key); + return next; + }); + } + + function setField(key: K, value: FormState[K], dirty = true) { setState((current) => ({ ...current, [key]: value })); + + if (dirty) { + markDirty(key); + } + } + + function applyPrefill(prefill: QuotationCreatePrefill | null) { + if (!prefill) { + return; + } + + setState((current) => { + const next = { ...current }; + + if (prefill.opportunityId !== undefined) { + next.opportunityId = prefill.opportunityId ?? ''; + } + + for (const key of PREFILL_FIELD_KEYS) { + if (dirtyFields.has(key)) { + continue; + } + + const value = prefill[key]; + + if (value === undefined) { + continue; + } + + (next[key] as FormState[typeof key]) = + typeof next[key] === 'boolean' ? Boolean(value) : ((value ?? '') as FormState[typeof key]); + } + + return next; + }); + + if (!projectPartiesDirty && prefill.projectParties) { + setProjectParties(prefill.projectParties); + } } function handleOpportunityChange(value: string) { - const opportunity = referenceData.opportunities.find((item) => item.id === value); - setState((current) => ({ - ...current, - opportunityId: value === '__none__' ? '' : value, - customerId: opportunity?.customerId ?? current.customerId, - contactId: opportunity?.contactId ?? '', - projectName: opportunity?.projectName ?? current.projectName, - projectLocation: opportunity?.projectLocation ?? current.projectLocation, - branchId: opportunity?.branchId ?? current.branchId - })); + const nextOpportunityId = value === '__none__' ? '' : value; + const opportunity = referenceData.opportunities.find((item) => item.id === nextOpportunityId); + markDirty('opportunityId'); + applyPrefill({ + ...toOpportunityPrefill(opportunity, referenceData), + opportunityId: nextOpportunityId + }); } async function onSubmit(event: React.FormEvent) { @@ -221,7 +375,11 @@ export function QuotationFormSheet({ exchangeRate: state.exchangeRate ? Number(state.exchangeRate) : 1, status: state.status, chancePercent: state.chancePercent ? Number(state.chancePercent) : null, + projectCloseDate: state.projectCloseDate || null, + deliveryDate: state.deliveryDate || null, isHotProject: state.isHotProject, + hotProjectAutoSuggested: state.hotProjectAutoSuggested, + hotProjectManuallyOverridden: state.hotProjectManuallyOverridden, competitor: state.competitor, reference: state.reference, notes: state.notes, @@ -237,10 +395,18 @@ export function QuotationFormSheet({ .map((item) => ({ customerId: item.customerId, role: item.role, + isPrimary: false, remark: item.remark || null })) }; + const parsed = quotationSchema.safeParse(payload); + + if (!parsed.success) { + toast.error(parsed.error.issues[0]?.message ?? 'Invalid quotation payload'); + return; + } + if (isEdit && quotation) { await updateMutation.mutateAsync({ id: quotation.id, values: payload }); return; @@ -261,253 +427,290 @@ export function QuotationFormSheet({ -
      -
      - - - + + + + - - - + + + - - - + + + - - - + + + - - setField('quotationDate', value)} /> - + + setField('quotationDate', value)} /> + - - setField('validUntil', value)} /> - + + setField('validUntil', value)} /> + - - - + + setField('projectCloseDate', value)} /> + - - - + + setField('deliveryDate', value)} /> + - - - + + + - - setField('exchangeRate', value)} step='0.0001' /> - + + + - - setField('projectName', e.target.value)} placeholder='Project name' /> - + + + - - setField('projectLocation', e.target.value)} placeholder='Project location' /> - + + setField('exchangeRate', value)} step='0.0001' /> + - - setField('attention', e.target.value)} placeholder='Attention line' /> - + + setField('projectName', e.target.value)} placeholder='Project name' /> + - - setField('reference', e.target.value)} placeholder='Reference note' /> - + + setField('projectLocation', e.target.value)} placeholder='Project location' /> + - - - + + setField('attention', e.target.value)} placeholder='Attention line' /> + - - setField('chancePercent', value)} /> - + + setField('reference', e.target.value)} placeholder='Reference note' /> + - - setField('discount', value)} currencyLabel='THB' /> - + + + - - - + + setField('chancePercent', value)} /> + - - setField('taxRate', value)} /> - + + setField('discount', value)} currencyLabel='THB' /> + - - - + + + - - setField('competitor', e.target.value)} placeholder='Competitor' /> - + + setField('taxRate', value)} /> + -
      - + + + + + setField('competitor', e.target.value)} placeholder='Competitor' /> + + +
      + { + setProjectParties(items); + setProjectPartiesDirty(true); + }} + /> +
      + +
      + + setField('notes', e.target.value)} placeholder='Internal notes' size='md' /> + +
      + +
      + + setField('revisionRemark', e.target.value)} + placeholder='Revision note or approval context' + size='md' /> -
      + +
      -
      - - setField('notes', e.target.value)} placeholder='Internal notes' size='md' /> - +
      +
      +
      Hot Project
      +
      Auto-suggested when project close date is within 3 months.
      + { + setState((current) => ({ + ...current, + isHotProject: checked, + hotProjectManuallyOverridden: true, + hotProjectAutoSuggested: isHotProjectSuggested(current.projectCloseDate) + })); + markDirty('isHotProject'); + }} + /> +
      -
      - - setField('revisionRemark', e.target.value)} placeholder='Revision note or approval context' size='md' /> - -
      - -
      -
      -
      Hot Project
      -
      Highlight urgent or strategic deals.
      -
      - setField('isHotProject', checked)} /> -
      - -
      -
      -
      Active Record
      -
      Inactive quotations stay as history only.
      -
      - setField('isActive', checked)} /> +
      +
      +
      Active Record
      +
      Inactive quotations stay as history only.
      + setField('isActive', checked)} />
      @@ -535,10 +738,10 @@ export function QuotationFormSheetTrigger({ return ( <> ); } - diff --git a/src/features/crm/quotations/schemas/quotation.schema.ts b/src/features/crm/quotations/schemas/quotation.schema.ts index a7aaec0..66e0e98 100644 --- a/src/features/crm/quotations/schemas/quotation.schema.ts +++ b/src/features/crm/quotations/schemas/quotation.schema.ts @@ -1,4 +1,5 @@ import * as z from 'zod'; +import { isValidDateOnlyString } from '@/features/crm/shared/hot-project'; function coerceOptionalNumber(message: string) { return z.preprocess((value) => { @@ -38,41 +39,65 @@ function coerceRequiredNumber(message: string) { }, z.number().refine((value) => !Number.isNaN(value), message)); } +function optionalDateOnly(message: string) { + return z + .string() + .optional() + .nullable() + .refine((value) => !value || isValidDateOnlyString(value), message); +} + +function requiredDateOnly(message: string) { + return z + .string() + .min(1, message) + .refine((value) => isValidDateOnlyString(value), message); +} + export const quotationSchema = z.object({ opportunityId: z.string().optional().nullable(), - customerId: z.string().min(1, 'Please select a customer'), + customerId: z.string().min(1, 'Please select customer'), contactId: z.string().optional().nullable(), - quotationDate: z.string().min(1, 'Quotation date is required'), - validUntil: z.string().optional().nullable(), - quotationType: z.string().min(1, 'Please select a quotation type'), + quotationDate: requiredDateOnly('Quotation date must be YYYY-MM-DD'), + validUntil: optionalDateOnly('Valid until date must be YYYY-MM-DD'), + quotationType: z.string().min(1, 'Please select quotation type'), projectName: z.string().optional(), projectLocation: z.string().optional(), attention: z.string().optional(), branchId: z.string().optional().nullable(), - currency: z.string().min(1, 'Please select a currency'), - exchangeRate: coerceOptionalNumber('Exchange rate must be a number'), - status: z.string().min(1, 'Please select a status'), - chancePercent: coerceOptionalNumber('Chance percent must be a number') - .refine( - (value) => value === undefined || (value >= 0 && value <= 100), - 'Chance percent must be between 0 and 100' - ), + currency: z.string().min(1, 'Please select currency'), + exchangeRate: coerceOptionalNumber('Exchange rate must be number'), + status: z.string().min(1, 'Please select status'), + chancePercent: coerceOptionalNumber('Chance percent must be number').refine( + (value) => value === undefined || (value >= 0 && value <= 100), + 'Chance percent must be between 0 and 100' + ), + projectCloseDate: optionalDateOnly('Project close date must be YYYY-MM-DD'), + deliveryDate: optionalDateOnly('Delivery date must be YYYY-MM-DD'), isHotProject: z.boolean().default(false), + hotProjectAutoSuggested: z.boolean().default(false), + hotProjectManuallyOverridden: z.boolean().default(false), competitor: z.string().optional(), reference: z.string().optional(), notes: z.string().optional(), salesmanId: z.string().optional().nullable(), - discount: coerceOptionalNumber('Discount must be a number'), + discount: coerceOptionalNumber('Discount must be number').refine( + (value) => value === undefined || value >= 0, + 'Discount must be 0 or greater' + ), discountType: z.string().optional().nullable(), - taxRate: coerceOptionalNumber('Tax rate must be a number'), - isActive: z.boolean().default(true), + taxRate: coerceOptionalNumber('Tax rate must be number').refine( + (value) => value === undefined || value >= 0, + 'Tax rate must be 0 or greater' + ), sentVia: z.string().optional().nullable(), revisionRemark: z.string().optional().nullable(), + isActive: z.boolean().default(true), projectParties: z .array( z.object({ - customerId: z.string().min(1, 'Please select a customer'), - role: z.string().min(1, 'Please select a role'), + customerId: z.string().min(1, 'Please select customer'), + role: z.string().min(1, 'Please select role'), isPrimary: z.boolean().default(false).optional(), remark: z.string().nullable().optional() }) @@ -81,70 +106,70 @@ export const quotationSchema = z.object({ }); export const quotationItemSchema = z.object({ - productType: z.string().min(1, 'Please select a product type'), + productType: z.string().min(1, 'Please select product type'), description: z.string().min(2, 'Description must be at least 2 characters'), - quantity: coerceRequiredNumber('Quantity must be a number').refine( + quantity: coerceRequiredNumber('Quantity must be number').refine( (value) => value > 0, 'Quantity must be greater than 0' ), unit: z.string().optional(), - unitPrice: coerceRequiredNumber('Unit price must be a number').refine( + unitPrice: coerceRequiredNumber('Unit price must be number').refine( (value) => value >= 0, 'Unit price must be 0 or greater' ), - discount: coerceOptionalNumber('Discount must be a number').refine( + discount: coerceOptionalNumber('Discount must be number').refine( (value) => value === undefined || value >= 0, 'Discount must be 0 or greater' ), discountType: z.string().nullable().optional(), - taxRate: coerceOptionalNumber('Tax rate must be a number').refine( + taxRate: coerceOptionalNumber('Tax rate must be number').refine( (value) => value === undefined || value >= 0, 'Tax rate must be 0 or greater' ), notes: z.string().optional(), - sortOrder: coerceOptionalNumber('Sort order must be a number') + sortOrder: coerceOptionalNumber('Sort order must be number') }); export const quotationCustomerSchema = z.object({ - customerId: z.string().min(1, 'Please select a customer'), - role: z.string().min(1, 'Please select a role'), + customerId: z.string().min(1, 'Please select customer'), + role: z.string().min(1, 'Please select role'), isPrimary: z.boolean().default(false), remark: z.string().nullable().optional() }); export const quotationTopicSchema = z.object({ id: z.string().optional(), - topicType: z.string().min(1, 'Please select a topic type'), + topicType: z.string().min(1, 'Please select topic type'), title: z.string().min(2, 'Title must be at least 2 characters'), - sortOrder: coerceOptionalNumber('Sort order must be a number'), + sortOrder: coerceOptionalNumber('Sort order must be number'), items: z .array( z.object({ id: z.string().optional(), - content: z.string().min(1, 'Topic item content is required'), - sortOrder: coerceOptionalNumber('Sort order must be a number') + content: z.string().min(1, 'Topic item content required'), + sortOrder: coerceOptionalNumber('Sort order must be number') }) ) - .min(1, 'At least one topic item is required') + .min(1, 'At least one topic item required') }); export const quotationFollowupSchema = z.object({ id: z.string().optional(), - followupDate: z.string().min(1, 'Follow-up date is required'), - followupType: z.string().min(1, 'Please select a follow-up type'), + followupDate: requiredDateOnly('Follow-up date must be YYYY-MM-DD'), + followupType: z.string().min(1, 'Please select follow-up type'), contactId: z.string().optional().nullable(), outcome: z.string().optional(), notes: z.string().optional(), - nextFollowupDate: z.string().optional().nullable(), + nextFollowupDate: optionalDateOnly('Next follow-up date must be YYYY-MM-DD'), nextAction: z.string().optional() }); export const quotationAttachmentSchema = z.object({ id: z.string().optional(), - fileName: z.string().min(1, 'Stored file name is required'), - originalFileName: z.string().min(1, 'Original file name is required'), - filePath: z.string().min(1, 'File path is required'), - fileSize: coerceOptionalNumber('File size must be a number'), + fileName: z.string().min(1, 'Stored file name required'), + originalFileName: z.string().min(1, 'Original file name required'), + filePath: z.string().min(1, 'File path required'), + fileSize: coerceOptionalNumber('File size must be number'), fileType: z.string().nullable().optional(), description: z.string().optional() }); @@ -159,4 +184,3 @@ export type QuotationCustomerFormValues = z.input; export type QuotationFollowupFormValues = z.input; export type QuotationAttachmentFormValues = z.input; - diff --git a/src/features/crm/quotations/server/service.ts b/src/features/crm/quotations/server/service.ts index 395de8a..4c4909c 100644 --- a/src/features/crm/quotations/server/service.ts +++ b/src/features/crm/quotations/server/service.ts @@ -80,6 +80,7 @@ import { PROJECT_PARTY_OPTION_CATEGORY, resolveProjectPartyRole } from '@/features/crm/shared/project-party'; +import { resolveHotProjectState } from '@/features/crm/shared/hot-project'; const QUOTATION_OPTION_CATEGORIES = { status: 'crm_quotation_status', @@ -271,7 +272,11 @@ function mapQuotationRecord( taxAmount: row.taxAmount, totalAmount: row.totalAmount, chancePercent: row.chancePercent, + projectCloseDate: row.projectCloseDate?.toISOString() ?? null, + deliveryDate: row.deliveryDate?.toISOString() ?? null, isHotProject: row.isHotProject, + hotProjectAutoSuggested: row.hotProjectAutoSuggested, + hotProjectManuallyOverridden: row.hotProjectManuallyOverridden, competitor: row.competitor, salesmanId: row.salesmanId, salesmanName: options?.salesmanName ?? null, @@ -1242,7 +1247,13 @@ export async function getQuotationReferenceData( title: opportunity.title, projectName: opportunity.projectName, projectLocation: opportunity.projectLocation, - branchId: opportunity.branchId + branchId: opportunity.branchId, + productType: opportunity.productType, + projectCloseDate: opportunity.projectCloseDate?.toISOString() ?? null, + deliveryDate: opportunity.deliveryDate?.toISOString() ?? null, + isHotProject: opportunity.isHotProject, + hotProjectAutoSuggested: opportunity.hotProjectAutoSuggested, + hotProjectManuallyOverridden: opportunity.hotProjectManuallyOverridden })), salesmen: salesmen.map((salesman) => ({ id: salesman.id, @@ -1464,11 +1475,17 @@ export async function createQuotation( payload.status ); - const opportunity = await assertOpportunityLinkIntegrity({ - organizationId, - opportunityId: payload.opportunityId, - customerId: payload.customerId - }); +const opportunity = await assertOpportunityLinkIntegrity({ +organizationId, +opportunityId: payload.opportunityId, +customerId: payload.customerId +}); +const hotProjectState = resolveHotProjectState({ +projectCloseDate: payload.projectCloseDate ?? opportunity?.projectCloseDate?.toISOString().slice(0, 10) ?? null, +isHotProject: payload.isHotProject ?? opportunity?.isHotProject ?? false, +hotProjectManuallyOverridden: +payload.hotProjectManuallyOverridden ?? opportunity?.hotProjectManuallyOverridden ?? false +}); const documentCode = await generateNextDocumentCode({ organizationId, documentType: 'quotation', @@ -1503,10 +1520,16 @@ const documentCode = await generateNextDocumentCode({ exchangeRate: payload.exchangeRate ?? 1, discount: payload.discount ?? 0, discountType: payload.discountType ?? null, - taxRate: payload.taxRate ?? 0, - chancePercent: payload.chancePercent ?? opportunity?.chancePercent ?? null, - isHotProject: payload.isHotProject ?? opportunity?.isHotProject ?? false, - competitor: payload.competitor?.trim() || opportunity?.competitor || null, +taxRate: payload.taxRate ?? 0, +chancePercent: payload.chancePercent ?? opportunity?.chancePercent ?? null, +projectCloseDate: payload.projectCloseDate +? new Date(payload.projectCloseDate) +: opportunity?.projectCloseDate ?? null, +deliveryDate: payload.deliveryDate ? new Date(payload.deliveryDate) : opportunity?.deliveryDate ?? null, +isHotProject: hotProjectState.isHotProject, +hotProjectAutoSuggested: hotProjectState.hotProjectAutoSuggested, +hotProjectManuallyOverridden: hotProjectState.hotProjectManuallyOverridden, +competitor: payload.competitor?.trim() || opportunity?.competitor || null, salesmanId: payload.salesmanId ?? null, isSent: false, sentVia: payload.sentVia ?? null, @@ -1567,14 +1590,20 @@ export async function updateQuotation( QUOTATION_OPTION_CATEGORIES.status, payload.status ); - const existing = await assertQuotationBelongsToOrganization(id, organizationId, accessContext); - const opportunity = await assertOpportunityLinkIntegrity({ - organizationId, - opportunityId: payload.opportunityId, - customerId: payload.customerId - }); +const existing = await assertQuotationBelongsToOrganization(id, organizationId, accessContext); +const opportunity = await assertOpportunityLinkIntegrity({ +organizationId, +opportunityId: payload.opportunityId, +customerId: payload.customerId +}); +const hotProjectState = resolveHotProjectState({ +projectCloseDate: payload.projectCloseDate ?? opportunity?.projectCloseDate?.toISOString().slice(0, 10) ?? null, +isHotProject: payload.isHotProject ?? existing.isHotProject, +hotProjectManuallyOverridden: +payload.hotProjectManuallyOverridden ?? existing.hotProjectManuallyOverridden +}); - const updated = await db.transaction(async (tx) => { +const updated = await db.transaction(async (tx) => { const [row] = await tx .update(crmQuotations) .set({ @@ -1596,10 +1625,16 @@ export async function updateQuotation( exchangeRate: payload.exchangeRate ?? 1, discount: payload.discount ?? 0, discountType: payload.discountType ?? null, - taxRate: payload.taxRate ?? 0, - chancePercent: payload.chancePercent ?? opportunity?.chancePercent ?? null, - isHotProject: payload.isHotProject ?? false, - competitor: payload.competitor?.trim() || opportunity?.competitor || null, +taxRate: payload.taxRate ?? 0, +chancePercent: payload.chancePercent ?? opportunity?.chancePercent ?? null, +projectCloseDate: payload.projectCloseDate +? new Date(payload.projectCloseDate) +: opportunity?.projectCloseDate ?? null, +deliveryDate: payload.deliveryDate ? new Date(payload.deliveryDate) : opportunity?.deliveryDate ?? null, +isHotProject: hotProjectState.isHotProject, +hotProjectAutoSuggested: hotProjectState.hotProjectAutoSuggested, +hotProjectManuallyOverridden: hotProjectState.hotProjectManuallyOverridden, +competitor: payload.competitor?.trim() || opportunity?.competitor || null, salesmanId: payload.salesmanId ?? null, sentVia: payload.sentVia ?? null, isActive: payload.isActive ?? true, diff --git a/src/features/crm/shared/hot-project.ts b/src/features/crm/shared/hot-project.ts new file mode 100644 index 0000000..9e6c8bd --- /dev/null +++ b/src/features/crm/shared/hot-project.ts @@ -0,0 +1,63 @@ +import { addMonths, endOfDay, isValid, parse } from 'date-fns'; + +const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/; + +export interface HotProjectResolutionInput { + projectCloseDate?: string | null; + isHotProject?: boolean | null; + hotProjectManuallyOverridden?: boolean | null; +} + +export interface HotProjectResolution { + isHotProject: boolean; + hotProjectAutoSuggested: boolean; + hotProjectManuallyOverridden: boolean; +} + +export function isValidDateOnlyString(value: string | null | undefined): value is string { + if (!value || !DATE_ONLY_PATTERN.test(value)) { + return false; + } + + const parsed = parse(value, 'yyyy-MM-dd', new Date()); + return isValid(parsed); +} + +export function isHotProjectSuggested(projectCloseDate: string | null | undefined, now = new Date()) { + if (!isValidDateOnlyString(projectCloseDate)) { + return false; + } + + const parsed = parse(projectCloseDate, 'yyyy-MM-dd', now); + return parsed.getTime() <= endOfDay(addMonths(now, 3)).getTime(); +} + +export function resolveHotProjectState( + input: HotProjectResolutionInput, + now = new Date() +): HotProjectResolution { + const hotProjectAutoSuggested = isHotProjectSuggested(input.projectCloseDate, now); + const hotProjectManuallyOverridden = Boolean(input.hotProjectManuallyOverridden); + + if (hotProjectManuallyOverridden) { + return { + isHotProject: Boolean(input.isHotProject), + hotProjectAutoSuggested, + hotProjectManuallyOverridden: true + }; + } + + if (hotProjectAutoSuggested) { + return { + isHotProject: true, + hotProjectAutoSuggested: true, + hotProjectManuallyOverridden: false + }; + } + + return { + isHotProject: Boolean(input.isHotProject), + hotProjectAutoSuggested: false, + hotProjectManuallyOverridden: false + }; +}