import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
import { projects } from "./projects";

export const scripts = sqliteTable("scripts", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  projectId: integer("project_id")
    .notNull()
    .references(() => projects.id),
  title: text("title").notNull(),
  slug: text("slug").notNull().unique(),
  genre: text("genre"),
  logline: text("logline"),
  status: text("status", { enum: ["draft", "revision", "final", "published"] }).notNull().default("draft"),
  currentVersion: integer("current_version").notNull().default(1),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull().default(new Date()),
  updatedAt: integer("updated_at", { mode: "timestamp" }).notNull().default(new Date()),
});

export type Script = typeof scripts.$inferSelect;
export type NewScript = typeof scripts.$inferInsert;
