{
  "version": "6",
  "dialect": "sqlite",
  "id": "cd9c637c-cb59-4225-aeef-717130d01d80",
  "prevId": "10853773-9698-4d81-a45e-6b3ec96d19c9",
  "tables": {
    "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": {}
    },
    "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": "'جاهز للإعداد'"
        },
        "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
        }
      },
      "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": {}
    },
    "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
        },
        "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
        }
      },
      "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": {}
    },
    "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
        },
        "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
        },
        "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
        }
      },
      "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"
        }
      },
      "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": {}
    },
    "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_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": {}
    },
    "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": {}
    },
    "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": {}
    },
    "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": {}
    },
    "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": true
        }
      },
      "foreignKeys": {},
      "compositePrimaryKeys": {},
      "uniqueConstraints": {},
      "checkConstraints": {}
    }
  },
  "views": {},
  "enums": {},
  "_meta": {
    "schemas": {},
    "tables": {},
    "columns": {}
  },
  "internal": {
    "indexes": {}
  }
}