import { pgTable, serial, integer, text, timestamp } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { z } from "zod/v4";
import { profilesTable } from "./profiles";

export const profilePhotosTable = pgTable("profile_photos", {
  id: serial("id").primaryKey(),
  profileId: integer("profile_id").notNull().references(() => profilesTable.id),
  url: text("url").notNull(),
  sortOrder: integer("sort_order").notNull().default(0),
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
});

export const insertProfilePhotoSchema = createInsertSchema(profilePhotosTable).omit({ id: true, createdAt: true });
export type InsertProfilePhoto = z.infer<typeof insertProfilePhotoSchema>;
export type ProfilePhoto = typeof profilePhotosTable.$inferSelect;
