import { pgTable, uuid, text, timestamp, index } from "drizzle-orm/pg-core";

export const pushSubscriptions = pgTable(
  "push_subscriptions",
  {
    id: uuid("id").primaryKey().defaultRandom(),
    endpoint: text("endpoint").notNull(),
    p256dh: text("p256dh").notNull(),
    auth: text("auth").notNull(),
    userId: uuid("user_id"),
    companyId: uuid("company_id"),
    deviceLabel: text("device_label"),
    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
  },
  (table) => ({
    endpointIdx: index("push_sub_endpoint_idx").on(table.endpoint),
  }),
);
