-- ncue_stt 테이블 생성 (PostgreSQL)
-- 주의: 테이블명은 .env의 TABLE 값과 동일해야 합니다.

CREATE TABLE IF NOT EXISTS ncue_stt (
  id BIGSERIAL PRIMARY KEY,
  author_id TEXT NOT NULL,
  filename TEXT,
  language_requested TEXT,
  detected_language TEXT,
  language_probability DOUBLE PRECISION,
  duration_sec DOUBLE PRECISION,
  status TEXT NOT NULL DEFAULT 'completed',
  text TEXT NOT NULL DEFAULT '',
  segments JSONB NOT NULL DEFAULT '[]'::jsonb,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS ncue_stt_author_id_idx ON ncue_stt(author_id);
CREATE INDEX IF NOT EXISTS ncue_stt_created_at_idx ON ncue_stt(created_at DESC);

