import { pgTable, uuid, text, jsonb, timestamp, integer, uniqueIndex } from 'drizzle-orm/pg-core';
import type { CuratorOutput } from '../types/agents.js';

export const recommendations = pgTable('recommendations', {
  id: uuid('id').defaultRandom().primaryKey(),
  title: text('title').notNull(),
  main_prompt: text('main_prompt').notNull(),
  liked_shows: text('liked_shows').notNull().default(''),
  disliked_shows: text('disliked_shows').notNull().default(''),
  themes: text('themes').notNull().default(''),
  recommendations: jsonb('recommendations').$type<CuratorOutput[]>(),
  status: text('status').notNull().default('pending'),
  created_at: timestamp('created_at').defaultNow().notNull(),
});

export const feedback = pgTable(
  'feedback',
  {
    id: uuid('id').defaultRandom().primaryKey(),
    tv_show_name: text('tv_show_name').notNull(),
    stars: integer('stars').notNull(),
    feedback: text('feedback').notNull().default(''),
    created_at: timestamp('created_at').defaultNow().notNull(),
  },
  (table) => [uniqueIndex('feedback_tv_show_name_idx').on(table.tv_show_name)],
);
