-- CDP Edge — Migration v2
-- Adiciona tabela device_graph para Cross-Device Matching
-- Gerado em: 2026-03-28

CREATE TABLE IF NOT EXISTS device_graph (
  id                INTEGER PRIMARY KEY AUTOINCREMENT,
  created_at        TEXT    NOT NULL DEFAULT (datetime('now')),
  primary_user_id   TEXT    NOT NULL,
  secondary_user_id TEXT    NOT NULL,
  match_type        TEXT    NOT NULL,
  match_confidence  REAL    NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_device_graph_pair
  ON device_graph(primary_user_id, secondary_user_id);
CREATE INDEX IF NOT EXISTS idx_device_graph_primary   ON device_graph(primary_user_id);
CREATE INDEX IF NOT EXISTS idx_device_graph_secondary ON device_graph(secondary_user_id);
