import { pgTable, uuid, text, jsonb, timestamp, integer, uniqueIndex, boolean } 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(''),
  brainstorm_count: integer('brainstorm_count').notNull().default(100),
  media_type: text('media_type').notNull().default('tv_show'),
  use_web_search: boolean('use_web_search').notNull().default(false),
  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(),
    item_name: text('item_name').notNull(),
    stars: integer('stars').notNull(),
    feedback: text('feedback').notNull().default(''),
    created_at: timestamp('created_at').defaultNow().notNull(),
  },
  (table) => [uniqueIndex('feedback_item_name_idx').on(table.item_name)],
);
