import { pgTable, text, timestamp } from 'drizzle-orm/pg-core'
import { relations } from 'drizzle-orm'
import { user } from './auth'

export const customers = pgTable('customers', {
  id: text('id').primaryKey(), // Stripe Customer ID
  userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
  createdAt: timestamp('created_at').defaultNow(),
  updatedAt: timestamp('updated_at').defaultNow()
})

export const customersRelations = relations(customers, ({ one }) => ({
  user: one(user, {
    fields: [customers.userId],
    references: [user.id]
  })
}))
