import { pgTable, text, timestamp, customType } from 'drizzle-orm/pg-core';

const bytea = customType<{ data: Buffer; driverData: Buffer }>({
  dataType: () => 'bytea',
  toDriver: (value: Buffer) => value,
  fromDriver: (value: Buffer) => value,
});

export const ledgers = pgTable('ledgers', {
  id: text('id').primaryKey(),            // UUID, client-generated
  name: text('name').notNull(),
  encryptedData: bytea('encrypted_data').notNull(),
  createdAt: timestamp('created_at').defaultNow().notNull(),
  updatedAt: timestamp('updated_at').defaultNow().notNull(),
});
