bmc_hub/migrations/1045_vtiger_case_hub_imports.sql
Christian 28a92eeb55 Add tests for case tree structure, timeline UI, and relation tree
- Implement tests to ensure the case tree contains parent and child branches while preventing cycles.
- Verify that the timeline UI utilizes tree filters and cursor paging.
- Confirm that the relation tree is displayed as a separate tab with appropriate search filters and inline module content.

Enhance time tracking with prepaid card usage alerts

- Create a migration to track alerts for prepaid card usage at 80% and 100%.
- Implement triggers to generate cases when usage thresholds are reached, ensuring proper notifications and case management.

Introduce audit logging for time entry edits

- Modify the sync log to include time entry updates in the audit stream without altering existing records.

Establish tracking for vTiger case imports and exports

- Create tables to track cases imported from vTiger into Hub and exports from Hub to vTiger, ensuring idempotency and proper reference management.
2026-09-24 09:12:25 +02:00

16 lines
812 B
SQL

-- Track individual Cases copied from vTiger into native Hub cases.
-- Unique source IDs make retries safe; this does not modify existing records.
CREATE TABLE IF NOT EXISTS vtiger_case_hub_imports (
vtiger_case_id VARCHAR(80) PRIMARY KEY,
ticket_number VARCHAR(80) NOT NULL,
hub_sag_id INTEGER NOT NULL UNIQUE REFERENCES sag_sager(id) ON DELETE RESTRICT,
hub_customer_id INTEGER NOT NULL REFERENCES customers(id) ON DELETE RESTRICT,
imported_by_user_id INTEGER REFERENCES users(user_id) ON DELETE SET NULL,
imported_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
vtiger_marked_at TIMESTAMP,
source_snapshot JSONB NOT NULL DEFAULT '{}'::jsonb
);
CREATE INDEX IF NOT EXISTS idx_vtiger_case_hub_imports_customer
ON vtiger_case_hub_imports(hub_customer_id, imported_at DESC);