forked from sagnik/Project_Velocity
Feat: CRM v2, Richer synthetic data, Canvas JSON Components
This commit is contained in:
@@ -50,6 +50,7 @@ CREATE TABLE IF NOT EXISTS oracle_canvas_components (
|
||||
version INTEGER NOT NULL DEFAULT 1,
|
||||
lifecycle_state TEXT NOT NULL DEFAULT 'active' CHECK (lifecycle_state IN ('draft','active','superseded','archived','revoked')),
|
||||
data_source_descriptor JSONB NOT NULL,
|
||||
data_rows JSONB NOT NULL DEFAULT '[]'::JSONB,
|
||||
visualization_parameters JSONB NOT NULL DEFAULT '{}'::JSONB,
|
||||
data_bindings JSONB NOT NULL DEFAULT '{}'::JSONB,
|
||||
provenance JSONB NOT NULL,
|
||||
@@ -63,6 +64,35 @@ CREATE TABLE IF NOT EXISTS oracle_canvas_components (
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
ALTER TABLE oracle_canvas_components
|
||||
ADD COLUMN IF NOT EXISTS data_rows JSONB NOT NULL DEFAULT '[]'::JSONB;
|
||||
|
||||
WITH latest_revisions AS (
|
||||
SELECT DISTINCT ON (page_id, tenant_id)
|
||||
page_id,
|
||||
tenant_id,
|
||||
components_snapshot
|
||||
FROM oracle_canvas_page_revisions
|
||||
ORDER BY page_id, tenant_id, revision_number DESC
|
||||
),
|
||||
snapshot_components AS (
|
||||
SELECT
|
||||
latest_revisions.page_id,
|
||||
latest_revisions.tenant_id,
|
||||
component->>'componentId' AS component_id,
|
||||
COALESCE(component->'dataRows', '[]'::jsonb) AS data_rows
|
||||
FROM latest_revisions,
|
||||
jsonb_array_elements(latest_revisions.components_snapshot) AS component
|
||||
)
|
||||
UPDATE oracle_canvas_components occ
|
||||
SET data_rows = snapshot_components.data_rows
|
||||
FROM snapshot_components
|
||||
WHERE occ.page_id = snapshot_components.page_id
|
||||
AND occ.tenant_id = snapshot_components.tenant_id
|
||||
AND occ.component_id::text = snapshot_components.component_id
|
||||
AND occ.data_rows = '[]'::jsonb
|
||||
AND snapshot_components.data_rows <> '[]'::jsonb;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS oracle_prompt_executions (
|
||||
execution_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
tenant_id TEXT NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user