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

export const genres = sqliteTable(
	"genres",
	{
		id: text("id")
			.primaryKey()
			.$defaultFn(() => {
				return Bun.randomUUIDv7();
			}),
		name: text("name").notNull().unique(),
		description: text("description"),
		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_genres_name").on(t.name)],
);
