CREATE TABLE IF NOT EXISTS memory_records (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL,
  org_id TEXT,
  key TEXT NOT NULL,
  value TEXT NOT NULL,
  embedding JSONB,
  created_at TIMESTAMP DEFAULT NOW() NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_memory_user_id ON memory_records(user_id);
CREATE INDEX IF NOT EXISTS idx_memory_org_id ON memory_records(org_id);
