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

// ----- PEOPLE (base table for actors, directors, crew, etc.) -----
export const people = sqliteTable(
	"people",
	{
		id: text("id")
			.primaryKey()
			.$defaultFn(() => crypto.randomUUID()),
		name: text("name").notNull(),
		biography: text("biography"),
		birthday: text("birthday"), // "YYYY-MM-DD"
		deathday: text("deathday"), // "YYYY-MM-DD"
		placeOfBirth: text("place_of_birth"),
		profilePicture: text("profile_picture"),
		createdAt: integer("created_at", { mode: "timestamp" })
			.$defaultFn(() => new Date())
			.notNull(),
		updatedAt: integer("updated_at", { mode: "timestamp" })
			.$defaultFn(() => new Date())
			.$onUpdate(() => new Date())
			.notNull(),
	},
	(t) => [index("idx_people_name").on(t.name)],
);
