{
  "version": "6",
  "dialect": "sqlite",
  "id": "4fd42845-4a08-4f34-8a20-7e3d595896d5",
  "prevId": "c0aaa110-7e55-4302-950c-e5ed7308bd48",
  "tables": {
    "agent_access_rules": {
      "name": "agent_access_rules",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "subject_type": {
          "name": "subject_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "subject_id": {
          "name": "subject_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "can_view": {
          "name": "can_view",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "can_edit": {
          "name": "can_edit",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "can_test": {
          "name": "can_test",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "can_publish": {
          "name": "can_publish",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_access_subject": {
          "name": "idx_agent_access_subject",
          "columns": [
            "agent_id",
            "subject_type",
            "subject_id"
          ],
          "isUnique": true
        },
        "idx_agent_access_workspace": {
          "name": "idx_agent_access_workspace",
          "columns": [
            "workspace_id",
            "agent_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_access_rules_workspace_id_workspaces_id_fk": {
          "name": "agent_access_rules_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_access_rules",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_access_rules_agent_id_agents_id_fk": {
          "name": "agent_access_rules_agent_id_agents_id_fk",
          "tableFrom": "agent_access_rules",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_actions": {
      "name": "agent_actions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "action_key": {
          "name": "action_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "approval_mode": {
          "name": "approval_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'disabled'"
        },
        "enabled": {
          "name": "enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "config_json": {
          "name": "config_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        }
      },
      "indexes": {
        "idx_agent_actions_agent_key": {
          "name": "idx_agent_actions_agent_key",
          "columns": [
            "agent_id",
            "action_key"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "agent_actions_agent_id_agents_id_fk": {
          "name": "agent_actions_agent_id_agents_id_fk",
          "tableFrom": "agent_actions",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_activity_logs": {
      "name": "agent_activity_logs",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "event_type": {
          "name": "event_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "summary": {
          "name": "summary",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "metadata_json": {
          "name": "metadata_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_activity_workspace_agent": {
          "name": "idx_agent_activity_workspace_agent",
          "columns": [
            "workspace_id",
            "agent_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_activity_logs_workspace_id_workspaces_id_fk": {
          "name": "agent_activity_logs_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_activity_logs",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_activity_logs_agent_id_agents_id_fk": {
          "name": "agent_activity_logs_agent_id_agents_id_fk",
          "tableFrom": "agent_activity_logs",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_channel_assignments": {
      "name": "agent_channel_assignments",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "channel_id": {
          "name": "channel_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'assigned'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_channel_assignment": {
          "name": "idx_agent_channel_assignment",
          "columns": [
            "agent_id",
            "channel_id"
          ],
          "isUnique": true
        },
        "idx_agent_channels_workspace": {
          "name": "idx_agent_channels_workspace",
          "columns": [
            "workspace_id",
            "agent_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_channel_assignments_workspace_id_workspaces_id_fk": {
          "name": "agent_channel_assignments_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_channel_assignments",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_channel_assignments_agent_id_agents_id_fk": {
          "name": "agent_channel_assignments_agent_id_agents_id_fk",
          "tableFrom": "agent_channel_assignments",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_channel_assignments_channel_id_channels_id_fk": {
          "name": "agent_channel_assignments_channel_id_channels_id_fk",
          "tableFrom": "agent_channel_assignments",
          "tableTo": "channels",
          "columnsFrom": [
            "channel_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_errors": {
      "name": "agent_errors",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "category": {
          "name": "category",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "summary": {
          "name": "summary",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "resolution_hint": {
          "name": "resolution_hint",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'open'"
        },
        "occurred_at": {
          "name": "occurred_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "resolved_at": {
          "name": "resolved_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_agent_errors_agent_status": {
          "name": "idx_agent_errors_agent_status",
          "columns": [
            "workspace_id",
            "agent_id",
            "status",
            "occurred_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_errors_workspace_id_workspaces_id_fk": {
          "name": "agent_errors_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_errors",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_errors_agent_id_agents_id_fk": {
          "name": "agent_errors_agent_id_agents_id_fk",
          "tableFrom": "agent_errors",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_guardrails": {
      "name": "agent_guardrails",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "allowed_topics_json": {
          "name": "allowed_topics_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "restricted_topics_json": {
          "name": "restricted_topics_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "escalation_rules_json": {
          "name": "escalation_rules_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "confidence_threshold": {
          "name": "confidence_threshold",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 55
        },
        "unknown_answer_behavior": {
          "name": "unknown_answer_behavior",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'handoff'"
        },
        "business_hours_json": {
          "name": "business_hours_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{\"mode\":\"always\"}'"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_guardrails_agent": {
          "name": "idx_agent_guardrails_agent",
          "columns": [
            "agent_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "agent_guardrails_agent_id_agents_id_fk": {
          "name": "agent_guardrails_agent_id_agents_id_fk",
          "tableFrom": "agent_guardrails",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_knowledge_links": {
      "name": "agent_knowledge_links",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "enabled": {
          "name": "enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        }
      },
      "indexes": {
        "idx_agent_knowledge_pair": {
          "name": "idx_agent_knowledge_pair",
          "columns": [
            "agent_id",
            "source_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "agent_knowledge_links_agent_id_agents_id_fk": {
          "name": "agent_knowledge_links_agent_id_agents_id_fk",
          "tableFrom": "agent_knowledge_links",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_knowledge_links_source_id_knowledge_sources_id_fk": {
          "name": "agent_knowledge_links_source_id_knowledge_sources_id_fk",
          "tableFrom": "agent_knowledge_links",
          "tableTo": "knowledge_sources",
          "columnsFrom": [
            "source_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_onboarding_sessions": {
      "name": "agent_onboarding_sessions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "current_step": {
          "name": "current_step",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'company'"
        },
        "completed_steps_json": {
          "name": "completed_steps_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[\"account\"]'"
        },
        "industry": {
          "name": "industry",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "goal": {
          "name": "goal",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "template_id": {
          "name": "template_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "draft_json": {
          "name": "draft_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'in_progress'"
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_onboarding_idempotency": {
          "name": "idx_agent_onboarding_idempotency",
          "columns": [
            "idempotency_key"
          ],
          "isUnique": true
        },
        "idx_agent_onboarding_user_status": {
          "name": "idx_agent_onboarding_user_status",
          "columns": [
            "user_id",
            "status",
            "updated_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_onboarding_sessions_workspace_id_workspaces_id_fk": {
          "name": "agent_onboarding_sessions_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_onboarding_sessions",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_onboarding_sessions_agent_id_agents_id_fk": {
          "name": "agent_onboarding_sessions_agent_id_agents_id_fk",
          "tableFrom": "agent_onboarding_sessions",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "agent_onboarding_sessions_template_id_agent_templates_id_fk": {
          "name": "agent_onboarding_sessions_template_id_agent_templates_id_fk",
          "tableFrom": "agent_onboarding_sessions",
          "tableTo": "agent_templates",
          "columnsFrom": [
            "template_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_templates": {
      "name": "agent_templates",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "slug": {
          "name": "slug",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "industry": {
          "name": "industry",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "goal": {
          "name": "goal",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description_ar": {
          "name": "description_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description_en": {
          "name": "description_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "default_instructions_ar": {
          "name": "default_instructions_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "default_instructions_en": {
          "name": "default_instructions_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "questions_json": {
          "name": "questions_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "suggested_knowledge_json": {
          "name": "suggested_knowledge_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "actions_json": {
          "name": "actions_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "handoff_rules_json": {
          "name": "handoff_rules_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "channels_json": {
          "name": "channels_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[\"webchat\"]'"
        },
        "required_features_json": {
          "name": "required_features_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "minimum_plan": {
          "name": "minimum_plan",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'draft'"
        },
        "featured": {
          "name": "featured",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_templates_slug": {
          "name": "idx_agent_templates_slug",
          "columns": [
            "slug"
          ],
          "isUnique": true
        },
        "idx_agent_templates_industry_goal": {
          "name": "idx_agent_templates_industry_goal",
          "columns": [
            "industry",
            "goal",
            "status"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_test_cases": {
      "name": "agent_test_cases",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "input": {
          "name": "input",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "expected_behavior": {
          "name": "expected_behavior",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "expected_action": {
          "name": "expected_action",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "expected_handoff": {
          "name": "expected_handoff",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "expected_source_id": {
          "name": "expected_source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_status": {
          "name": "last_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'not_run'"
        },
        "last_run_at": {
          "name": "last_run_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_by": {
          "name": "created_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_test_cases_agent": {
          "name": "idx_agent_test_cases_agent",
          "columns": [
            "workspace_id",
            "agent_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_test_cases_workspace_id_workspaces_id_fk": {
          "name": "agent_test_cases_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_test_cases",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_test_cases_agent_id_agents_id_fk": {
          "name": "agent_test_cases_agent_id_agents_id_fk",
          "tableFrom": "agent_test_cases",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_test_cases_expected_source_id_knowledge_sources_id_fk": {
          "name": "agent_test_cases_expected_source_id_knowledge_sources_id_fk",
          "tableFrom": "agent_test_cases",
          "tableTo": "knowledge_sources",
          "columnsFrom": [
            "expected_source_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_test_runs": {
      "name": "agent_test_runs",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "scenario": {
          "name": "scenario",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'custom'"
        },
        "user_message": {
          "name": "user_message",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "response": {
          "name": "response",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "intent": {
          "name": "intent",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "sources_json": {
          "name": "sources_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "actions_json": {
          "name": "actions_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "handoff_decision": {
          "name": "handoff_decision",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'none'"
        },
        "latency_ms": {
          "name": "latency_ms",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "credits_used": {
          "name": "credits_used",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_test_runs_agent": {
          "name": "idx_agent_test_runs_agent",
          "columns": [
            "agent_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_test_runs_workspace_id_workspaces_id_fk": {
          "name": "agent_test_runs_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_test_runs",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_test_runs_agent_id_agents_id_fk": {
          "name": "agent_test_runs_agent_id_agents_id_fk",
          "tableFrom": "agent_test_runs",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_usage_budgets": {
      "name": "agent_usage_budgets",
      "columns": {
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "monthly_credits": {
          "name": "monthly_credits",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "alert_threshold": {
          "name": "alert_threshold",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 80
        },
        "limit_policy": {
          "name": "limit_policy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'notify'"
        },
        "updated_by": {
          "name": "updated_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_usage_budget_workspace": {
          "name": "idx_agent_usage_budget_workspace",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_usage_budgets_agent_id_agents_id_fk": {
          "name": "agent_usage_budgets_agent_id_agents_id_fk",
          "tableFrom": "agent_usage_budgets",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_usage_budgets_workspace_id_workspaces_id_fk": {
          "name": "agent_usage_budgets_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_usage_budgets",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agent_versions": {
      "name": "agent_versions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'draft'"
        },
        "config_json": {
          "name": "config_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "change_summary": {
          "name": "change_summary",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "updated_by": {
          "name": "updated_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agent_versions_agent_version": {
          "name": "idx_agent_versions_agent_version",
          "columns": [
            "agent_id",
            "version"
          ],
          "isUnique": true
        },
        "idx_agent_versions_state": {
          "name": "idx_agent_versions_state",
          "columns": [
            "agent_id",
            "state"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agent_versions_workspace_id_workspaces_id_fk": {
          "name": "agent_versions_workspace_id_workspaces_id_fk",
          "tableFrom": "agent_versions",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "agent_versions_agent_id_agents_id_fk": {
          "name": "agent_versions_agent_id_agents_id_fk",
          "tableFrom": "agent_versions",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "agents": {
      "name": "agents",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "instructions": {
          "name": "instructions",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "tone": {
          "name": "tone",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ودود واحترافي'"
        },
        "language": {
          "name": "language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'العربية'"
        },
        "welcome_message": {
          "name": "welcome_message",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'أهلًا بك، كيف يمكنني مساعدتك؟'"
        },
        "handoff_threshold": {
          "name": "handoff_threshold",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 45
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "channel": {
          "name": "channel",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'واتساب'"
        },
        "autonomy": {
          "name": "autonomy",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 70
        },
        "knowledge_count": {
          "name": "knowledge_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_agents_workspace_id": {
          "name": "idx_agents_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        },
        "idx_agents_workspace_status": {
          "name": "idx_agents_workspace_status",
          "columns": [
            "workspace_id",
            "status"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "agents_workspace_id_workspaces_id_fk": {
          "name": "agents_workspace_id_workspaces_id_fk",
          "tableFrom": "agents",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "audit_logs": {
      "name": "audit_logs",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "target_label": {
          "name": "target_label",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_audit_logs_workspace_id": {
          "name": "idx_audit_logs_workspace_id",
          "columns": [
            "workspace_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "audit_logs_workspace_id_workspaces_id_fk": {
          "name": "audit_logs_workspace_id_workspaces_id_fk",
          "tableFrom": "audit_logs",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "automation_runs": {
      "name": "automation_runs",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "workflow_id": {
          "name": "workflow_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "affected_type": {
          "name": "affected_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "affected_id": {
          "name": "affected_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "error_code": {
          "name": "error_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "started_at": {
          "name": "started_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "completed_at": {
          "name": "completed_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_automation_runs_workspace_status": {
          "name": "idx_automation_runs_workspace_status",
          "columns": [
            "workspace_id",
            "status",
            "started_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "automation_runs_workspace_id_workspaces_id_fk": {
          "name": "automation_runs_workspace_id_workspaces_id_fk",
          "tableFrom": "automation_runs",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "automation_runs_workflow_id_workflows_id_fk": {
          "name": "automation_runs_workflow_id_workflows_id_fk",
          "tableFrom": "automation_runs",
          "tableTo": "workflows",
          "columnsFrom": [
            "workflow_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_addon_plans": {
      "name": "billing_addon_plans",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "addon_id": {
          "name": "addon_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "plan_id": {
          "name": "plan_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_addon_plans_pair": {
          "name": "idx_addon_plans_pair",
          "columns": [
            "addon_id",
            "plan_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "billing_addon_plans_addon_id_billing_addons_id_fk": {
          "name": "billing_addon_plans_addon_id_billing_addons_id_fk",
          "tableFrom": "billing_addon_plans",
          "tableTo": "billing_addons",
          "columnsFrom": [
            "addon_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "billing_addon_plans_plan_id_billing_plans_id_fk": {
          "name": "billing_addon_plans_plan_id_billing_plans_id_fk",
          "tableFrom": "billing_addon_plans",
          "tableTo": "billing_plans",
          "columnsFrom": [
            "plan_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_addons": {
      "name": "billing_addons",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "slug": {
          "name": "slug",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description_ar": {
          "name": "description_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "description_en": {
          "name": "description_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "price_minor": {
          "name": "price_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'SAR'"
        },
        "billing_type": {
          "name": "billing_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "quantity_unit": {
          "name": "quantity_unit",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'inactive'"
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        }
      },
      "indexes": {
        "idx_billing_addons_slug": {
          "name": "idx_billing_addons_slug",
          "columns": [
            "slug"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_audit_logs": {
      "name": "billing_audit_logs",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_type": {
          "name": "entity_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_id": {
          "name": "entity_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "old_value_json": {
          "name": "old_value_json",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "new_value_json": {
          "name": "new_value_json",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_billing_audit_entity": {
          "name": "idx_billing_audit_entity",
          "columns": [
            "entity_type",
            "entity_id",
            "created_at"
          ],
          "isUnique": false
        },
        "idx_billing_audit_workspace": {
          "name": "idx_billing_audit_workspace",
          "columns": [
            "workspace_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_features": {
      "name": "billing_features",
      "columns": {
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description_ar": {
          "name": "description_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "description_en": {
          "name": "description_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "tooltip_ar": {
          "name": "tooltip_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "tooltip_en": {
          "name": "tooltip_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "category": {
          "name": "category",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'platform'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_notifications": {
      "name": "billing_notifications",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "threshold": {
          "name": "threshold",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "message_ar": {
          "name": "message_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "message_en": {
          "name": "message_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "email_enabled": {
          "name": "email_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "read_at": {
          "name": "read_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_billing_notifications_workspace": {
          "name": "idx_billing_notifications_workspace",
          "columns": [
            "workspace_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "billing_notifications_workspace_id_workspaces_id_fk": {
          "name": "billing_notifications_workspace_id_workspaces_id_fk",
          "tableFrom": "billing_notifications",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_plan_entitlements": {
      "name": "billing_plan_entitlements",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "plan_id": {
          "name": "plan_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "feature_key": {
          "name": "feature_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "enabled": {
          "name": "enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "limit_value": {
          "name": "limit_value",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "limit_unit": {
          "name": "limit_unit",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "note_ar": {
          "name": "note_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "note_en": {
          "name": "note_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        }
      },
      "indexes": {
        "idx_plan_entitlements_plan_feature": {
          "name": "idx_plan_entitlements_plan_feature",
          "columns": [
            "plan_id",
            "feature_key"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "billing_plan_entitlements_plan_id_billing_plans_id_fk": {
          "name": "billing_plan_entitlements_plan_id_billing_plans_id_fk",
          "tableFrom": "billing_plan_entitlements",
          "tableTo": "billing_plans",
          "columnsFrom": [
            "plan_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "billing_plan_entitlements_feature_key_billing_features_key_fk": {
          "name": "billing_plan_entitlements_feature_key_billing_features_key_fk",
          "tableFrom": "billing_plan_entitlements",
          "tableTo": "billing_features",
          "columnsFrom": [
            "feature_key"
          ],
          "columnsTo": [
            "key"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_plan_versions": {
      "name": "billing_plan_versions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "plan_id": {
          "name": "plan_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "version": {
          "name": "version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "monthly_price_minor": {
          "name": "monthly_price_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "yearly_price_minor": {
          "name": "yearly_price_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "effective_at": {
          "name": "effective_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "created_by": {
          "name": "created_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_plan_versions_plan_version": {
          "name": "idx_plan_versions_plan_version",
          "columns": [
            "plan_id",
            "version"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "billing_plan_versions_plan_id_billing_plans_id_fk": {
          "name": "billing_plan_versions_plan_id_billing_plans_id_fk",
          "tableFrom": "billing_plan_versions",
          "tableTo": "billing_plans",
          "columnsFrom": [
            "plan_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_plans": {
      "name": "billing_plans",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "slug": {
          "name": "slug",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description_ar": {
          "name": "description_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "description_en": {
          "name": "description_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "monthly_price_minor": {
          "name": "monthly_price_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "yearly_price_minor": {
          "name": "yearly_price_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'SAR'"
        },
        "pricing_mode": {
          "name": "pricing_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'fixed'"
        },
        "cta_kind": {
          "name": "cta_kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'contact_sales'"
        },
        "popular": {
          "name": "popular",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "trial_enabled": {
          "name": "trial_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'hidden'"
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "current_version": {
          "name": "current_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_billing_plans_slug": {
          "name": "idx_billing_plans_slug",
          "columns": [
            "slug"
          ],
          "isUnique": true
        },
        "idx_billing_plans_status_sort": {
          "name": "idx_billing_plans_status_sort",
          "columns": [
            "status",
            "sort_order"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "billing_rate_limits": {
      "name": "billing_rate_limits",
      "columns": {
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "window_start": {
          "name": "window_start",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_count": {
          "name": "request_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "channels": {
      "name": "channels",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'setup'"
        },
        "config_label": {
          "name": "config_label",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'جاهز للإعداد'"
        },
        "public_key": {
          "name": "public_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "allowed_domains_json": {
          "name": "allowed_domains_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_channels_workspace_id": {
          "name": "idx_channels_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        },
        "idx_channels_workspace_provider": {
          "name": "idx_channels_workspace_provider",
          "columns": [
            "workspace_id",
            "provider"
          ],
          "isUnique": true
        },
        "idx_channels_public_key": {
          "name": "idx_channels_public_key",
          "columns": [
            "public_key"
          ],
          "isUnique": true,
          "where": "\"channels\".\"public_key\" IS NOT NULL"
        }
      },
      "foreignKeys": {
        "channels_workspace_id_workspaces_id_fk": {
          "name": "channels_workspace_id_workspaces_id_fk",
          "tableFrom": "channels",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_analytics_events": {
      "name": "contact_analytics_events",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "event_name": {
          "name": "event_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_type": {
          "name": "request_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "path": {
          "name": "path",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "session_hash": {
          "name": "session_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_contact_analytics_event": {
          "name": "idx_contact_analytics_event",
          "columns": [
            "event_name",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_attachments": {
      "name": "contact_attachments",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "object_key": {
          "name": "object_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "original_name": {
          "name": "original_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "mime_type": {
          "name": "mime_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "size_bytes": {
          "name": "size_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "scan_status": {
          "name": "scan_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'pending_scan'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_contact_attachments_request": {
          "name": "idx_contact_attachments_request",
          "columns": [
            "request_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "contact_attachments_request_id_contact_requests_id_fk": {
          "name": "contact_attachments_request_id_contact_requests_id_fk",
          "tableFrom": "contact_attachments",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_audit_logs": {
      "name": "contact_audit_logs",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "action": {
          "name": "action",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "old_value_json": {
          "name": "old_value_json",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "new_value_json": {
          "name": "new_value_json",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_contact_audit_request": {
          "name": "idx_contact_audit_request",
          "columns": [
            "request_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "contact_audit_logs_request_id_contact_requests_id_fk": {
          "name": "contact_audit_logs_request_id_contact_requests_id_fk",
          "tableFrom": "contact_audit_logs",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_interactions": {
      "name": "contact_interactions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "contact_id": {
          "name": "contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "visibility": {
          "name": "visibility",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'internal'"
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_contact_interactions_contact": {
          "name": "idx_contact_interactions_contact",
          "columns": [
            "contact_id",
            "created_at"
          ],
          "isUnique": false
        },
        "idx_contact_interactions_request": {
          "name": "idx_contact_interactions_request",
          "columns": [
            "request_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "contact_interactions_contact_id_crm_contacts_id_fk": {
          "name": "contact_interactions_contact_id_crm_contacts_id_fk",
          "tableFrom": "contact_interactions",
          "tableTo": "crm_contacts",
          "columnsFrom": [
            "contact_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "contact_interactions_request_id_contact_requests_id_fk": {
          "name": "contact_interactions_request_id_contact_requests_id_fk",
          "tableFrom": "contact_interactions",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_notifications": {
      "name": "contact_notifications",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "team": {
          "name": "team",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "body": {
          "name": "body",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "action_url": {
          "name": "action_url",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "read_at": {
          "name": "read_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_contact_notifications_team": {
          "name": "idx_contact_notifications_team",
          "columns": [
            "team",
            "read_at",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "contact_notifications_request_id_contact_requests_id_fk": {
          "name": "contact_notifications_request_id_contact_requests_id_fk",
          "tableFrom": "contact_notifications",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_permissions": {
      "name": "contact_permissions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "permission": {
          "name": "permission",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "granted": {
          "name": "granted",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        }
      },
      "indexes": {
        "idx_contact_permissions_user_permission": {
          "name": "idx_contact_permissions_user_permission",
          "columns": [
            "user_id",
            "permission",
            "workspace_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "contact_permissions_workspace_id_workspaces_id_fk": {
          "name": "contact_permissions_workspace_id_workspaces_id_fk",
          "tableFrom": "contact_permissions",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_rate_limits": {
      "name": "contact_rate_limits",
      "columns": {
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "window_start": {
          "name": "window_start",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_count": {
          "name": "request_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_requests": {
      "name": "contact_requests",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "reference": {
          "name": "reference",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "contact_id": {
          "name": "contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "type": {
          "name": "type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "subject": {
          "name": "subject",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "message": {
          "name": "message",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'new'"
        },
        "priority": {
          "name": "priority",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'normal'"
        },
        "assigned_team": {
          "name": "assigned_team",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "assigned_user_id": {
          "name": "assigned_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'direct'"
        },
        "industry": {
          "name": "industry",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "company_size": {
          "name": "company_size",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "country": {
          "name": "country",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "goals_json": {
          "name": "goals_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "details_json": {
          "name": "details_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "utm_json": {
          "name": "utm_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "lead_score": {
          "name": "lead_score",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "fingerprint_hash": {
          "name": "fingerprint_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_contact_requests_reference": {
          "name": "idx_contact_requests_reference",
          "columns": [
            "reference"
          ],
          "isUnique": true
        },
        "idx_contact_requests_idempotency": {
          "name": "idx_contact_requests_idempotency",
          "columns": [
            "idempotency_key"
          ],
          "isUnique": true
        },
        "idx_contact_requests_type_status": {
          "name": "idx_contact_requests_type_status",
          "columns": [
            "type",
            "status",
            "created_at"
          ],
          "isUnique": false
        },
        "idx_contact_requests_contact": {
          "name": "idx_contact_requests_contact",
          "columns": [
            "contact_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "contact_requests_contact_id_crm_contacts_id_fk": {
          "name": "contact_requests_contact_id_crm_contacts_id_fk",
          "tableFrom": "contact_requests",
          "tableTo": "crm_contacts",
          "columnsFrom": [
            "contact_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "contact_requests_workspace_id_workspaces_id_fk": {
          "name": "contact_requests_workspace_id_workspaces_id_fk",
          "tableFrom": "contact_requests",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_routing_rules": {
      "name": "contact_routing_rules",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_type": {
          "name": "request_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "country": {
          "name": "country",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "industry": {
          "name": "industry",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "company_size": {
          "name": "company_size",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "minimum_score": {
          "name": "minimum_score",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "strategy": {
          "name": "strategy",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'team'"
        },
        "team": {
          "name": "team",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "active": {
          "name": "active",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        }
      },
      "indexes": {
        "idx_contact_routing_rules_type": {
          "name": "idx_contact_routing_rules_type",
          "columns": [
            "request_type",
            "active",
            "sort_order"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_settings": {
      "name": "contact_settings",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "sales_email": {
          "name": "sales_email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "support_email": {
          "name": "support_email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "partnership_email": {
          "name": "partnership_email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "general_email": {
          "name": "general_email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "phone": {
          "name": "phone",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "whatsapp": {
          "name": "whatsapp",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "business_hours_json": {
          "name": "business_hours_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "office_json": {
          "name": "office_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "social_json": {
          "name": "social_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "calendar_provider": {
          "name": "calendar_provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "email_provider": {
          "name": "email_provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "demo_duration_minutes": {
          "name": "demo_duration_minutes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 30
        },
        "max_files": {
          "name": "max_files",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 3
        },
        "max_file_bytes": {
          "name": "max_file_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 5242880
        },
        "allowed_file_types_json": {
          "name": "allowed_file_types_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[\"application/pdf\",\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"image/jpeg\",\"image/png\",\"image/webp\"]'"
        },
        "privacy_url": {
          "name": "privacy_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "terms_url": {
          "name": "terms_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "contact_webhook_events": {
      "name": "contact_webhook_events",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "event_type": {
          "name": "event_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'pending'"
        },
        "attempts": {
          "name": "attempts",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "next_attempt_at": {
          "name": "next_attempt_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_error": {
          "name": "last_error",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "processed_at": {
          "name": "processed_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_contact_webhooks_status": {
          "name": "idx_contact_webhooks_status",
          "columns": [
            "status",
            "next_attempt_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "contact_webhook_events_request_id_contact_requests_id_fk": {
          "name": "contact_webhook_events_request_id_contact_requests_id_fk",
          "tableFrom": "contact_webhook_events",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "conversation_assignments": {
      "name": "conversation_assignments",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "from_user_id": {
          "name": "from_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "to_user_id": {
          "name": "to_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "from_mode": {
          "name": "from_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "to_mode": {
          "name": "to_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "reason": {
          "name": "reason",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "actor_user_id": {
          "name": "actor_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_conversation_assignments_thread": {
          "name": "idx_conversation_assignments_thread",
          "columns": [
            "workspace_id",
            "conversation_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "conversation_internal_notes": {
      "name": "conversation_internal_notes",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "author_name": {
          "name": "author_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_conversation_notes_thread": {
          "name": "idx_conversation_notes_thread",
          "columns": [
            "workspace_id",
            "conversation_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "conversation_messages": {
      "name": "conversation_messages",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "sender_type": {
          "name": "sender_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "sender_name": {
          "name": "sender_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "message_type": {
          "name": "message_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'text'"
        },
        "external_message_id": {
          "name": "external_message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "channel_id": {
          "name": "channel_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'sent'"
        },
        "original_content": {
          "name": "original_content",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "translated_content": {
          "name": "translated_content",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "metadata_json": {
          "name": "metadata_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_conversation_messages_conversation_id": {
          "name": "idx_conversation_messages_conversation_id",
          "columns": [
            "conversation_id",
            "created_at"
          ],
          "isUnique": false
        },
        "idx_conversation_messages_workspace_id": {
          "name": "idx_conversation_messages_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        },
        "idx_conversation_message_idempotency": {
          "name": "idx_conversation_message_idempotency",
          "columns": [
            "workspace_id",
            "idempotency_key"
          ],
          "isUnique": true,
          "where": "\"conversation_messages\".\"idempotency_key\" IS NOT NULL"
        }
      },
      "foreignKeys": {
        "conversation_messages_workspace_id_workspaces_id_fk": {
          "name": "conversation_messages_workspace_id_workspaces_id_fk",
          "tableFrom": "conversation_messages",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "conversation_messages_conversation_id_conversations_id_fk": {
          "name": "conversation_messages_conversation_id_conversations_id_fk",
          "tableFrom": "conversation_messages",
          "tableTo": "conversations",
          "columnsFrom": [
            "conversation_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "conversation_sla_events": {
      "name": "conversation_sla_events",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "target_type": {
          "name": "target_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "target_at": {
          "name": "target_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "breached_at": {
          "name": "breached_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "cleared_at": {
          "name": "cleared_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_conversation_sla_open": {
          "name": "idx_conversation_sla_open",
          "columns": [
            "workspace_id",
            "target_at",
            "cleared_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "conversations": {
      "name": "conversations",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "agent_version_id": {
          "name": "agent_version_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "customer_name": {
          "name": "customer_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "channel": {
          "name": "channel",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "preview": {
          "name": "preview",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "state": {
          "name": "state",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'open'"
        },
        "priority": {
          "name": "priority",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'normal'"
        },
        "assigned_to": {
          "name": "assigned_to",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "customer_phone": {
          "name": "customer_phone",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "customer_email": {
          "name": "customer_email",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "last_intent": {
          "name": "last_intent",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "satisfaction": {
          "name": "satisfaction",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "unread_count": {
          "name": "unread_count",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "contact_id": {
          "name": "contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "assigned_user_id": {
          "name": "assigned_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "assigned_team_id": {
          "name": "assigned_team_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "owner_mode": {
          "name": "owner_mode",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ai'"
        },
        "queue_key": {
          "name": "queue_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'general'"
        },
        "tags_json": {
          "name": "tags_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "language": {
          "name": "language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ar'"
        },
        "handoff_reason": {
          "name": "handoff_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "summary": {
          "name": "summary",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "snoozed_until": {
          "name": "snoozed_until",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "resolved_at": {
          "name": "resolved_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_message_at": {
          "name": "last_message_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "lock_version": {
          "name": "lock_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_conversations_workspace_id": {
          "name": "idx_conversations_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        },
        "idx_conversations_workspace_state": {
          "name": "idx_conversations_workspace_state",
          "columns": [
            "workspace_id",
            "state"
          ],
          "isUnique": false
        },
        "idx_conversations_workspace_agent": {
          "name": "idx_conversations_workspace_agent",
          "columns": [
            "workspace_id",
            "agent_id",
            "updated_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "conversations_workspace_id_workspaces_id_fk": {
          "name": "conversations_workspace_id_workspaces_id_fk",
          "tableFrom": "conversations",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "conversations_agent_id_agents_id_fk": {
          "name": "conversations_agent_id_agents_id_fk",
          "tableFrom": "conversations",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "coupon_plans": {
      "name": "coupon_plans",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "coupon_id": {
          "name": "coupon_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "plan_id": {
          "name": "plan_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_coupon_plans_pair": {
          "name": "idx_coupon_plans_pair",
          "columns": [
            "coupon_id",
            "plan_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "coupon_plans_coupon_id_coupons_id_fk": {
          "name": "coupon_plans_coupon_id_coupons_id_fk",
          "tableFrom": "coupon_plans",
          "tableTo": "coupons",
          "columnsFrom": [
            "coupon_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "coupon_plans_plan_id_billing_plans_id_fk": {
          "name": "coupon_plans_plan_id_billing_plans_id_fk",
          "tableFrom": "coupon_plans",
          "tableTo": "billing_plans",
          "columnsFrom": [
            "plan_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "coupon_redemptions": {
      "name": "coupon_redemptions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "coupon_id": {
          "name": "coupon_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "subscription_id": {
          "name": "subscription_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "discount_minor": {
          "name": "discount_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_coupon_redemptions_coupon_workspace": {
          "name": "idx_coupon_redemptions_coupon_workspace",
          "columns": [
            "coupon_id",
            "workspace_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "coupon_redemptions_coupon_id_coupons_id_fk": {
          "name": "coupon_redemptions_coupon_id_coupons_id_fk",
          "tableFrom": "coupon_redemptions",
          "tableTo": "coupons",
          "columnsFrom": [
            "coupon_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "coupon_redemptions_workspace_id_workspaces_id_fk": {
          "name": "coupon_redemptions_workspace_id_workspaces_id_fk",
          "tableFrom": "coupon_redemptions",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "coupon_redemptions_subscription_id_subscriptions_id_fk": {
          "name": "coupon_redemptions_subscription_id_subscriptions_id_fk",
          "tableFrom": "coupon_redemptions",
          "tableTo": "subscriptions",
          "columnsFrom": [
            "subscription_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "coupons": {
      "name": "coupons",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "code": {
          "name": "code",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "discount_type": {
          "name": "discount_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "discount_value": {
          "name": "discount_value",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "starts_at": {
          "name": "starts_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "expires_at": {
          "name": "expires_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "usage_limit": {
          "name": "usage_limit",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "per_customer_limit": {
          "name": "per_customer_limit",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "billing_cycles_json": {
          "name": "billing_cycles_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "minimum_amount_minor": {
          "name": "minimum_amount_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "active": {
          "name": "active",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_coupons_code": {
          "name": "idx_coupons_code",
          "columns": [
            "code"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_activities": {
      "name": "crm_activities",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_type": {
          "name": "entity_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_id": {
          "name": "entity_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "details_json": {
          "name": "details_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "actor_type": {
          "name": "actor_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'user'"
        },
        "actor_id": {
          "name": "actor_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "agent_version_id": {
          "name": "agent_version_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_activities_entity": {
          "name": "idx_crm_activities_entity",
          "columns": [
            "workspace_id",
            "entity_type",
            "entity_id",
            "created_at"
          ],
          "isUnique": false
        },
        "idx_crm_activities_workspace": {
          "name": "idx_crm_activities_workspace",
          "columns": [
            "workspace_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_contact_merges": {
      "name": "crm_contact_merges",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "primary_contact_id": {
          "name": "primary_contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "secondary_contact_id": {
          "name": "secondary_contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "snapshot_json": {
          "name": "snapshot_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "merged_by": {
          "name": "merged_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_contact_merges_workspace": {
          "name": "idx_crm_contact_merges_workspace",
          "columns": [
            "workspace_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_contacts": {
      "name": "crm_contacts",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "full_name": {
          "name": "full_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "normalized_email": {
          "name": "normalized_email",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "phone": {
          "name": "phone",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "normalized_phone": {
          "name": "normalized_phone",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "country": {
          "name": "country",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "company": {
          "name": "company",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "job_title": {
          "name": "job_title",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "marketing_consent": {
          "name": "marketing_consent",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "consent_at": {
          "name": "consent_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "consent_source": {
          "name": "consent_source",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_contacts_email": {
          "name": "idx_crm_contacts_email",
          "columns": [
            "normalized_email"
          ],
          "isUnique": false
        },
        "idx_crm_contacts_phone": {
          "name": "idx_crm_contacts_phone",
          "columns": [
            "normalized_phone"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_custom_fields": {
      "name": "crm_custom_fields",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "scope": {
          "name": "scope",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "field_type": {
          "name": "field_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "options_json": {
          "name": "options_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "required": {
          "name": "required",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_custom_fields_scope_key": {
          "name": "idx_crm_custom_fields_scope_key",
          "columns": [
            "workspace_id",
            "scope",
            "key"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_notes": {
      "name": "crm_notes",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_type": {
          "name": "entity_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_id": {
          "name": "entity_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "author_user_id": {
          "name": "author_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_notes_entity": {
          "name": "idx_crm_notes_entity",
          "columns": [
            "workspace_id",
            "entity_type",
            "entity_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_saved_views": {
      "name": "crm_saved_views",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "entity_type": {
          "name": "entity_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "filters_json": {
          "name": "filters_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_saved_views_user": {
          "name": "idx_crm_saved_views_user",
          "columns": [
            "workspace_id",
            "user_id",
            "entity_type"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "crm_tags": {
      "name": "crm_tags",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "color": {
          "name": "color",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'#6366f1'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_crm_tags_workspace_name": {
          "name": "idx_crm_tags_workspace_name",
          "columns": [
            "workspace_id",
            "name"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "customer_companies": {
      "name": "customer_companies",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "industry": {
          "name": "industry",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "website": {
          "name": "website",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "country": {
          "name": "country",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "city": {
          "name": "city",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "size": {
          "name": "size",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "main_contact_id": {
          "name": "main_contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "tags_json": {
          "name": "tags_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "notes": {
          "name": "notes",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "custom_fields_json": {
          "name": "custom_fields_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "archived_at": {
          "name": "archived_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_customer_companies_workspace_name": {
          "name": "idx_customer_companies_workspace_name",
          "columns": [
            "workspace_id",
            "name"
          ],
          "isUnique": false
        },
        "idx_customer_companies_workspace_owner": {
          "name": "idx_customer_companies_workspace_owner",
          "columns": [
            "workspace_id",
            "owner_user_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "customer_companies_workspace_id_workspaces_id_fk": {
          "name": "customer_companies_workspace_id_workspaces_id_fk",
          "tableFrom": "customer_companies",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "customer_contacts": {
      "name": "customer_contacts",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "full_name": {
          "name": "full_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "phone": {
          "name": "phone",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "company": {
          "name": "company",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "company_id": {
          "name": "company_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "country": {
          "name": "country",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "language": {
          "name": "language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ar'"
        },
        "external_channel_id": {
          "name": "external_channel_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "tags_json": {
          "name": "tags_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "custom_fields_json": {
          "name": "custom_fields_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'manual'"
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "last_activity_at": {
          "name": "last_activity_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_customer_contacts_workspace_updated": {
          "name": "idx_customer_contacts_workspace_updated",
          "columns": [
            "workspace_id",
            "updated_at"
          ],
          "isUnique": false
        },
        "idx_customer_contacts_workspace_email": {
          "name": "idx_customer_contacts_workspace_email",
          "columns": [
            "workspace_id",
            "email"
          ],
          "isUnique": false
        },
        "idx_customer_contacts_workspace_phone": {
          "name": "idx_customer_contacts_workspace_phone",
          "columns": [
            "workspace_id",
            "phone"
          ],
          "isUnique": false
        },
        "idx_customer_contacts_workspace_company": {
          "name": "idx_customer_contacts_workspace_company",
          "columns": [
            "workspace_id",
            "company_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "customer_contacts_workspace_id_workspaces_id_fk": {
          "name": "customer_contacts_workspace_id_workspaces_id_fk",
          "tableFrom": "customer_contacts",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "customer_leads": {
      "name": "customer_leads",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "contact_id": {
          "name": "contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "company_id": {
          "name": "company_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_by_agent_id": {
          "name": "created_by_agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "agent_version_id": {
          "name": "agent_version_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "stage": {
          "name": "stage",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'new'"
        },
        "score": {
          "name": "score",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "priority": {
          "name": "priority",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'normal'"
        },
        "qualification_json": {
          "name": "qualification_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'manual'"
        },
        "interest": {
          "name": "interest",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "value_minor": {
          "name": "value_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'SAR'"
        },
        "next_action_at": {
          "name": "next_action_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_activity_at": {
          "name": "last_activity_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "converted_at": {
          "name": "converted_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "converted_by": {
          "name": "converted_by",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_customer_leads_workspace_stage": {
          "name": "idx_customer_leads_workspace_stage",
          "columns": [
            "workspace_id",
            "stage",
            "updated_at"
          ],
          "isUnique": false
        },
        "idx_customer_leads_workspace_owner": {
          "name": "idx_customer_leads_workspace_owner",
          "columns": [
            "workspace_id",
            "owner_user_id"
          ],
          "isUnique": false
        },
        "idx_customer_leads_workspace_agent": {
          "name": "idx_customer_leads_workspace_agent",
          "columns": [
            "workspace_id",
            "created_by_agent_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "customer_leads_workspace_id_workspaces_id_fk": {
          "name": "customer_leads_workspace_id_workspaces_id_fk",
          "tableFrom": "customer_leads",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "customer_leads_contact_id_customer_contacts_id_fk": {
          "name": "customer_leads_contact_id_customer_contacts_id_fk",
          "tableFrom": "customer_leads",
          "tableTo": "customer_contacts",
          "columnsFrom": [
            "contact_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        },
        "customer_leads_created_by_agent_id_agents_id_fk": {
          "name": "customer_leads_created_by_agent_id_agents_id_fk",
          "tableFrom": "customer_leads",
          "tableTo": "agents",
          "columnsFrom": [
            "created_by_agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "demo_requests": {
      "name": "demo_requests",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "interests_json": {
          "name": "interests_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "timezone": {
          "name": "timezone",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "requested_date": {
          "name": "requested_date",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "requested_time": {
          "name": "requested_time",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "duration_minutes": {
          "name": "duration_minutes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 30
        },
        "meeting_type": {
          "name": "meeting_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'request'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'requested'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_demo_requests_request": {
          "name": "idx_demo_requests_request",
          "columns": [
            "request_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "demo_requests_request_id_contact_requests_id_fk": {
          "name": "demo_requests_request_id_contact_requests_id_fk",
          "tableFrom": "demo_requests",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "inbox_saved_replies": {
      "name": "inbox_saved_replies",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "title_ar": {
          "name": "title_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "title_en": {
          "name": "title_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "body_ar": {
          "name": "body_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "body_en": {
          "name": "body_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "category": {
          "name": "category",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'general'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "created_by": {
          "name": "created_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_saved_replies_workspace": {
          "name": "idx_saved_replies_workspace",
          "columns": [
            "workspace_id",
            "status",
            "category"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "inbox_webhook_events": {
      "name": "inbox_webhook_events",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "channel_id": {
          "name": "channel_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "external_event_id": {
          "name": "external_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "event_type": {
          "name": "event_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "payload_hash": {
          "name": "payload_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'received'"
        },
        "processed_at": {
          "name": "processed_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_inbox_webhook_dedupe": {
          "name": "idx_inbox_webhook_dedupe",
          "columns": [
            "workspace_id",
            "channel_id",
            "external_event_id"
          ],
          "isUnique": true
        },
        "idx_inbox_webhook_status": {
          "name": "idx_inbox_webhook_status",
          "columns": [
            "status",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "invoice_items": {
      "name": "invoice_items",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "invoice_id": {
          "name": "invoice_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "description": {
          "name": "description",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "quantity": {
          "name": "quantity",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "unit_price_minor": {
          "name": "unit_price_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "total_minor": {
          "name": "total_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        }
      },
      "indexes": {},
      "foreignKeys": {
        "invoice_items_invoice_id_invoices_id_fk": {
          "name": "invoice_items_invoice_id_invoices_id_fk",
          "tableFrom": "invoice_items",
          "tableTo": "invoices",
          "columnsFrom": [
            "invoice_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "invoices": {
      "name": "invoices",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "subscription_id": {
          "name": "subscription_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "invoice_number": {
          "name": "invoice_number",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "company_name": {
          "name": "company_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "vat_number": {
          "name": "vat_number",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "issued_at": {
          "name": "issued_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "period_start": {
          "name": "period_start",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "period_end": {
          "name": "period_end",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "subtotal_minor": {
          "name": "subtotal_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "vat_minor": {
          "name": "vat_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "total_minor": {
          "name": "total_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "payment_method_label": {
          "name": "payment_method_label",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_invoices_number": {
          "name": "idx_invoices_number",
          "columns": [
            "invoice_number"
          ],
          "isUnique": true
        },
        "idx_invoices_workspace": {
          "name": "idx_invoices_workspace",
          "columns": [
            "workspace_id",
            "issued_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "invoices_workspace_id_workspaces_id_fk": {
          "name": "invoices_workspace_id_workspaces_id_fk",
          "tableFrom": "invoices",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "invoices_subscription_id_subscriptions_id_fk": {
          "name": "invoices_subscription_id_subscriptions_id_fk",
          "tableFrom": "invoices",
          "tableTo": "subscriptions",
          "columnsFrom": [
            "subscription_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "knowledge_entries": {
      "name": "knowledge_entries",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "source_id": {
          "name": "source_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_knowledge_entries_workspace_source": {
          "name": "idx_knowledge_entries_workspace_source",
          "columns": [
            "workspace_id",
            "source_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "knowledge_entries_workspace_id_workspaces_id_fk": {
          "name": "knowledge_entries_workspace_id_workspaces_id_fk",
          "tableFrom": "knowledge_entries",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "knowledge_entries_source_id_knowledge_sources_id_fk": {
          "name": "knowledge_entries_source_id_knowledge_sources_id_fk",
          "tableFrom": "knowledge_entries",
          "tableTo": "knowledge_sources",
          "columnsFrom": [
            "source_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "knowledge_sources": {
      "name": "knowledge_sources",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "source_type": {
          "name": "source_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "object_key": {
          "name": "object_key",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "source_url": {
          "name": "source_url",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "mime_type": {
          "name": "mime_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "size_bytes": {
          "name": "size_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ready'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_knowledge_sources_workspace_id": {
          "name": "idx_knowledge_sources_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "knowledge_sources_workspace_id_workspaces_id_fk": {
          "name": "knowledge_sources_workspace_id_workspaces_id_fk",
          "tableFrom": "knowledge_sources",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "lead_scoring_rules": {
      "name": "lead_scoring_rules",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "label_ar": {
          "name": "label_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "label_en": {
          "name": "label_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "field": {
          "name": "field",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "operator": {
          "name": "operator",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "value_json": {
          "name": "value_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "points": {
          "name": "points",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "active": {
          "name": "active",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        }
      },
      "indexes": {
        "idx_lead_scoring_rules_key": {
          "name": "idx_lead_scoring_rules_key",
          "columns": [
            "key"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "message_attachments": {
      "name": "message_attachments",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "message_id": {
          "name": "message_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "object_key": {
          "name": "object_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "original_name": {
          "name": "original_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "mime_type": {
          "name": "mime_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "size_bytes": {
          "name": "size_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "scan_status": {
          "name": "scan_status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'pending'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_message_attachments_thread": {
          "name": "idx_message_attachments_thread",
          "columns": [
            "workspace_id",
            "conversation_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "onboarding_analytics_events": {
      "name": "onboarding_analytics_events",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "session_hash": {
          "name": "session_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "event_name": {
          "name": "event_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "step": {
          "name": "step",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_onboarding_events_name": {
          "name": "idx_onboarding_events_name",
          "columns": [
            "event_name",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "onboarding_settings": {
      "name": "onboarding_settings",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "signup_enabled": {
          "name": "signup_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "free_agent_enabled": {
          "name": "free_agent_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "require_company_name": {
          "name": "require_company_name",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": true
        },
        "default_country": {
          "name": "default_country",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'SA'"
        },
        "default_language": {
          "name": "default_language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ar'"
        },
        "available_industries_json": {
          "name": "available_industries_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[]'"
        },
        "available_channels_json": {
          "name": "available_channels_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[\"webchat\"]'"
        },
        "skip_rules_json": {
          "name": "skip_rules_json",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'{}'"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "partnership_requests": {
      "name": "partnership_requests",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "partnership_type": {
          "name": "partnership_type",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "company_description": {
          "name": "company_description",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "proposal": {
          "name": "proposal",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_partnership_requests_request": {
          "name": "idx_partnership_requests_request",
          "columns": [
            "request_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "partnership_requests_request_id_contact_requests_id_fk": {
          "name": "partnership_requests_request_id_contact_requests_id_fk",
          "tableFrom": "partnership_requests",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "payment_webhook_events": {
      "name": "payment_webhook_events",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "provider_event_id": {
          "name": "provider_event_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'pending'"
        },
        "payload_hash": {
          "name": "payload_hash",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "error_message": {
          "name": "error_message",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "received_at": {
          "name": "received_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "processed_at": {
          "name": "processed_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        }
      },
      "indexes": {
        "idx_webhook_provider_event": {
          "name": "idx_webhook_provider_event",
          "columns": [
            "provider",
            "provider_event_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "payments": {
      "name": "payments",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "invoice_id": {
          "name": "invoice_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "provider": {
          "name": "provider",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "provider_payment_id": {
          "name": "provider_payment_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "amount_minor": {
          "name": "amount_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "idempotency_key": {
          "name": "idempotency_key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "failure_code": {
          "name": "failure_code",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_payments_idempotency": {
          "name": "idx_payments_idempotency",
          "columns": [
            "idempotency_key"
          ],
          "isUnique": true
        },
        "idx_payments_provider_id": {
          "name": "idx_payments_provider_id",
          "columns": [
            "provider",
            "provider_payment_id"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "payments_workspace_id_workspaces_id_fk": {
          "name": "payments_workspace_id_workspaces_id_fk",
          "tableFrom": "payments",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "payments_invoice_id_invoices_id_fk": {
          "name": "payments_invoice_id_invoices_id_fk",
          "tableFrom": "payments",
          "tableTo": "invoices",
          "columnsFrom": [
            "invoice_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "pricing_settings": {
      "name": "pricing_settings",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "base_currency": {
          "name": "base_currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'SAR'"
        },
        "vat_enabled": {
          "name": "vat_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "vat_rate_basis_points": {
          "name": "vat_rate_basis_points",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "price_includes_vat": {
          "name": "price_includes_vat",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "trial_enabled": {
          "name": "trial_enabled",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "trial_days": {
          "name": "trial_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "trial_requires_payment_method": {
          "name": "trial_requires_payment_method",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "trial_auto_convert": {
          "name": "trial_auto_convert",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "warning_thresholds": {
          "name": "warning_thresholds",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'[80,90,100]'"
        },
        "grace_period_days": {
          "name": "grace_period_days",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "retention_policy_ar": {
          "name": "retention_policy_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'تحدد سياسة الاحتفاظ بالبيانات في العقد المطبق.'"
        },
        "retention_policy_en": {
          "name": "retention_policy_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'Data retention follows the applicable contract.'"
        },
        "payment_provider": {
          "name": "payment_provider",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "sales_deals": {
      "name": "sales_deals",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "contact_id": {
          "name": "contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "company_id": {
          "name": "company_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "source_lead_id": {
          "name": "source_lead_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "conversation_id": {
          "name": "conversation_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "pipeline_id": {
          "name": "pipeline_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "stage_id": {
          "name": "stage_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "value_minor": {
          "name": "value_minor",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "currency": {
          "name": "currency",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'SAR'"
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "probability": {
          "name": "probability",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "expected_close_at": {
          "name": "expected_close_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'manual'"
        },
        "next_action": {
          "name": "next_action",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "lost_reason": {
          "name": "lost_reason",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "won_at": {
          "name": "won_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "lost_at": {
          "name": "lost_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "last_activity_at": {
          "name": "last_activity_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "lock_version": {
          "name": "lock_version",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_sales_deals_pipeline_stage": {
          "name": "idx_sales_deals_pipeline_stage",
          "columns": [
            "workspace_id",
            "pipeline_id",
            "stage_id"
          ],
          "isUnique": false
        },
        "idx_sales_deals_owner": {
          "name": "idx_sales_deals_owner",
          "columns": [
            "workspace_id",
            "owner_user_id"
          ],
          "isUnique": false
        },
        "idx_sales_deals_contact": {
          "name": "idx_sales_deals_contact",
          "columns": [
            "workspace_id",
            "contact_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "sales_deals_workspace_id_workspaces_id_fk": {
          "name": "sales_deals_workspace_id_workspaces_id_fk",
          "tableFrom": "sales_deals",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "sales_leads": {
      "name": "sales_leads",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "contact_id": {
          "name": "contact_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "stage": {
          "name": "stage",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'new'"
        },
        "score": {
          "name": "score",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "source": {
          "name": "source",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'website'"
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "next_follow_up_at": {
          "name": "next_follow_up_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_sales_leads_request": {
          "name": "idx_sales_leads_request",
          "columns": [
            "request_id"
          ],
          "isUnique": true
        },
        "idx_sales_leads_stage_score": {
          "name": "idx_sales_leads_stage_score",
          "columns": [
            "stage",
            "score"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "sales_leads_contact_id_crm_contacts_id_fk": {
          "name": "sales_leads_contact_id_crm_contacts_id_fk",
          "tableFrom": "sales_leads",
          "tableTo": "crm_contacts",
          "columnsFrom": [
            "contact_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "sales_leads_request_id_contact_requests_id_fk": {
          "name": "sales_leads_request_id_contact_requests_id_fk",
          "tableFrom": "sales_leads",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "sales_pipeline_stages": {
      "name": "sales_pipeline_stages",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "pipeline_id": {
          "name": "pipeline_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "key": {
          "name": "key",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "color": {
          "name": "color",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'#6366f1'"
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "probability": {
          "name": "probability",
          "type": "integer",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "is_won": {
          "name": "is_won",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "is_lost": {
          "name": "is_lost",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_pipeline_stage_key": {
          "name": "idx_pipeline_stage_key",
          "columns": [
            "pipeline_id",
            "key"
          ],
          "isUnique": true
        },
        "idx_pipeline_stages_order": {
          "name": "idx_pipeline_stages_order",
          "columns": [
            "workspace_id",
            "pipeline_id",
            "sort_order"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "sales_pipeline_stages_workspace_id_workspaces_id_fk": {
          "name": "sales_pipeline_stages_workspace_id_workspaces_id_fk",
          "tableFrom": "sales_pipeline_stages",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "sales_pipeline_stages_pipeline_id_sales_pipelines_id_fk": {
          "name": "sales_pipeline_stages_pipeline_id_sales_pipelines_id_fk",
          "tableFrom": "sales_pipeline_stages",
          "tableTo": "sales_pipelines",
          "columnsFrom": [
            "pipeline_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "sales_pipelines": {
      "name": "sales_pipelines",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_ar": {
          "name": "name_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name_en": {
          "name": "name_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "is_default": {
          "name": "is_default",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "sort_order": {
          "name": "sort_order",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_sales_pipelines_workspace": {
          "name": "idx_sales_pipelines_workspace",
          "columns": [
            "workspace_id",
            "status",
            "sort_order"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "sales_pipelines_workspace_id_workspaces_id_fk": {
          "name": "sales_pipelines_workspace_id_workspaces_id_fk",
          "tableFrom": "sales_pipelines",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "simulation_messages": {
      "name": "simulation_messages",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "content": {
          "name": "content",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "intent": {
          "name": "intent",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_simulation_messages_agent_id": {
          "name": "idx_simulation_messages_agent_id",
          "columns": [
            "agent_id",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "simulation_messages_workspace_id_workspaces_id_fk": {
          "name": "simulation_messages_workspace_id_workspaces_id_fk",
          "tableFrom": "simulation_messages",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "simulation_messages_agent_id_agents_id_fk": {
          "name": "simulation_messages_agent_id_agents_id_fk",
          "tableFrom": "simulation_messages",
          "tableTo": "agents",
          "columnsFrom": [
            "agent_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "subscription_addons": {
      "name": "subscription_addons",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "subscription_id": {
          "name": "subscription_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "addon_id": {
          "name": "addon_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "quantity": {
          "name": "quantity",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 1
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "subscription_addons_subscription_id_subscriptions_id_fk": {
          "name": "subscription_addons_subscription_id_subscriptions_id_fk",
          "tableFrom": "subscription_addons",
          "tableTo": "subscriptions",
          "columnsFrom": [
            "subscription_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "subscription_addons_addon_id_billing_addons_id_fk": {
          "name": "subscription_addons_addon_id_billing_addons_id_fk",
          "tableFrom": "subscription_addons",
          "tableTo": "billing_addons",
          "columnsFrom": [
            "addon_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "subscriptions": {
      "name": "subscriptions",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "plan_id": {
          "name": "plan_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "plan_version_id": {
          "name": "plan_version_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "billing_cycle": {
          "name": "billing_cycle",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'pending'"
        },
        "current_period_start": {
          "name": "current_period_start",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "current_period_end": {
          "name": "current_period_end",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "trial_ends_at": {
          "name": "trial_ends_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "cancel_at_period_end": {
          "name": "cancel_at_period_end",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": false
        },
        "cancelled_at": {
          "name": "cancelled_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "provider_customer_id": {
          "name": "provider_customer_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "provider_subscription_id": {
          "name": "provider_subscription_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "custom_limits_json": {
          "name": "custom_limits_json",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_subscriptions_workspace_status": {
          "name": "idx_subscriptions_workspace_status",
          "columns": [
            "workspace_id",
            "status"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "subscriptions_workspace_id_workspaces_id_fk": {
          "name": "subscriptions_workspace_id_workspaces_id_fk",
          "tableFrom": "subscriptions",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "subscriptions_plan_id_billing_plans_id_fk": {
          "name": "subscriptions_plan_id_billing_plans_id_fk",
          "tableFrom": "subscriptions",
          "tableTo": "billing_plans",
          "columnsFrom": [
            "plan_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        },
        "subscriptions_plan_version_id_billing_plan_versions_id_fk": {
          "name": "subscriptions_plan_version_id_billing_plan_versions_id_fk",
          "tableFrom": "subscriptions",
          "tableTo": "billing_plan_versions",
          "columnsFrom": [
            "plan_version_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "no action",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "support_tickets": {
      "name": "support_tickets",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "request_id": {
          "name": "request_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "category": {
          "name": "category",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "module": {
          "name": "module",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'new'"
        },
        "priority": {
          "name": "priority",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'normal'"
        },
        "assigned_team": {
          "name": "assigned_team",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'support'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_support_tickets_request": {
          "name": "idx_support_tickets_request",
          "columns": [
            "request_id"
          ],
          "isUnique": true
        },
        "idx_support_tickets_workspace_status": {
          "name": "idx_support_tickets_workspace_status",
          "columns": [
            "workspace_id",
            "status"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "support_tickets_request_id_contact_requests_id_fk": {
          "name": "support_tickets_request_id_contact_requests_id_fk",
          "tableFrom": "support_tickets",
          "tableTo": "contact_requests",
          "columnsFrom": [
            "request_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        },
        "support_tickets_workspace_id_workspaces_id_fk": {
          "name": "support_tickets_workspace_id_workspaces_id_fk",
          "tableFrom": "support_tickets",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "team_members": {
      "name": "team_members",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "email": {
          "name": "email",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_team_members_workspace_id": {
          "name": "idx_team_members_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        },
        "idx_team_members_workspace_email": {
          "name": "idx_team_members_workspace_email",
          "columns": [
            "workspace_id",
            "email"
          ],
          "isUnique": true
        }
      },
      "foreignKeys": {
        "team_members_workspace_id_workspaces_id_fk": {
          "name": "team_members_workspace_id_workspaces_id_fk",
          "tableFrom": "team_members",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "usage_records": {
      "name": "usage_records",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "recorded_date": {
          "name": "recorded_date",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "agent_id": {
          "name": "agent_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "model": {
          "name": "model",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "input_tokens": {
          "name": "input_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "output_tokens": {
          "name": "output_tokens",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "credits_used": {
          "name": "credits_used",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "voice_seconds": {
          "name": "voice_seconds",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "storage_bytes": {
          "name": "storage_bytes",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "messages": {
          "name": "messages",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "campaign_units": {
          "name": "campaign_units",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "api_calls": {
          "name": "api_calls",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "automation_runs": {
          "name": "automation_runs",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "metadata_json": {
          "name": "metadata_json",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_usage_workspace_date": {
          "name": "idx_usage_workspace_date",
          "columns": [
            "workspace_id",
            "recorded_date"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "usage_records_workspace_id_workspaces_id_fk": {
          "name": "usage_records_workspace_id_workspaces_id_fk",
          "tableFrom": "usage_records",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "workflows": {
      "name": "workflows",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "trigger_name": {
          "name": "trigger_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "action_name": {
          "name": "action_name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "runs": {
          "name": "runs",
          "type": "integer",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": 0
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_workflows_workspace_id": {
          "name": "idx_workflows_workspace_id",
          "columns": [
            "workspace_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "workflows_workspace_id_workspaces_id_fk": {
          "name": "workflows_workspace_id_workspaces_id_fk",
          "tableFrom": "workflows",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "workspace_memberships": {
      "name": "workspace_memberships",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "role": {
          "name": "role",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'member'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'active'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_workspace_membership_user_workspace": {
          "name": "idx_workspace_membership_user_workspace",
          "columns": [
            "user_id",
            "workspace_id"
          ],
          "isUnique": true
        },
        "idx_workspace_membership_user": {
          "name": "idx_workspace_membership_user",
          "columns": [
            "user_id",
            "status"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "workspace_memberships_workspace_id_workspaces_id_fk": {
          "name": "workspace_memberships_workspace_id_workspaces_id_fk",
          "tableFrom": "workspace_memberships",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "workspace_notifications": {
      "name": "workspace_notifications",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "category": {
          "name": "category",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "priority": {
          "name": "priority",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'medium'"
        },
        "title_ar": {
          "name": "title_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "title_en": {
          "name": "title_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "body_ar": {
          "name": "body_ar",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "body_en": {
          "name": "body_en",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "''"
        },
        "href": {
          "name": "href",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "read_at": {
          "name": "read_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "archived_at": {
          "name": "archived_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_workspace_notifications_scope": {
          "name": "idx_workspace_notifications_scope",
          "columns": [
            "workspace_id",
            "user_id",
            "read_at",
            "created_at"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "workspace_notifications_workspace_id_workspaces_id_fk": {
          "name": "workspace_notifications_workspace_id_workspaces_id_fk",
          "tableFrom": "workspace_notifications",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "workspace_tasks": {
      "name": "workspace_tasks",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "workspace_id": {
          "name": "workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "title": {
          "name": "title",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "kind": {
          "name": "kind",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'task'"
        },
        "status": {
          "name": "status",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'open'"
        },
        "priority": {
          "name": "priority",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'medium'"
        },
        "assigned_user_id": {
          "name": "assigned_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "related_type": {
          "name": "related_type",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "related_id": {
          "name": "related_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "due_at": {
          "name": "due_at",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "created_by": {
          "name": "created_by",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_workspace_tasks_workspace_status_due": {
          "name": "idx_workspace_tasks_workspace_status_due",
          "columns": [
            "workspace_id",
            "status",
            "due_at"
          ],
          "isUnique": false
        },
        "idx_workspace_tasks_assignee": {
          "name": "idx_workspace_tasks_assignee",
          "columns": [
            "workspace_id",
            "assigned_user_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {
        "workspace_tasks_workspace_id_workspaces_id_fk": {
          "name": "workspace_tasks_workspace_id_workspaces_id_fk",
          "tableFrom": "workspace_tasks",
          "tableTo": "workspaces",
          "columnsFrom": [
            "workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "cascade",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "workspace_user_preferences": {
      "name": "workspace_user_preferences",
      "columns": {
        "user_id": {
          "name": "user_id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "current_workspace_id": {
          "name": "current_workspace_id",
          "type": "text",
          "primaryKey": false,
          "notNull": false,
          "autoincrement": false
        },
        "language": {
          "name": "language",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'ar'"
        },
        "timezone": {
          "name": "timezone",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'Asia/Riyadh'"
        },
        "default_range": {
          "name": "default_range",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'7d'"
        },
        "agents_view": {
          "name": "agents_view",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'grid'"
        },
        "updated_at": {
          "name": "updated_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {},
      "foreignKeys": {
        "workspace_user_preferences_current_workspace_id_workspaces_id_fk": {
          "name": "workspace_user_preferences_current_workspace_id_workspaces_id_fk",
          "tableFrom": "workspace_user_preferences",
          "tableTo": "workspaces",
          "columnsFrom": [
            "current_workspace_id"
          ],
          "columnsTo": [
            "id"
          ],
          "onDelete": "set null",
          "onUpdate": "no action"
        }
      },
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    },
    "workspaces": {
      "name": "workspaces",
      "columns": {
        "id": {
          "name": "id",
          "type": "text",
          "primaryKey": true,
          "notNull": true,
          "autoincrement": false
        },
        "owner_user_id": {
          "name": "owner_user_id",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "name": {
          "name": "name",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false
        },
        "industry": {
          "name": "industry",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'عام'"
        },
        "plan": {
          "name": "plan",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "'تجريبي'"
        },
        "created_at": {
          "name": "created_at",
          "type": "text",
          "primaryKey": false,
          "notNull": true,
          "autoincrement": false,
          "default": "CURRENT_TIMESTAMP"
        }
      },
      "indexes": {
        "idx_workspaces_owner_user_id": {
          "name": "idx_workspaces_owner_user_id",
          "columns": [
            "owner_user_id"
          ],
          "isUnique": false
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    }
  },
  "views": {},
  "enums": {},
  "_meta": {
    "schemas": {},
    "tables": {},
    "columns": {}
  },
  "internal": {
    "indexes": {}
  }
}