import { customType, numeric, timestamp, text, jsonb } from 'drizzle-orm/pg-core'; import { sql } from 'drizzle-orm'; /** NUMERIC(18,4) mapped to JS number (values above 2^53 are not expected for collectibles). */ export const money = (name: string) => numeric(name, { precision: 18, scale: 4, mode: 'number' }); export const ratio = (name: string) => numeric(name, { precision: 8, scale: 6, mode: 'number' }); export const ts = (name: string) => timestamp(name, { withTimezone: true, mode: 'date' }); export const createdAt = () => ts('created_at').notNull().defaultNow(); export const updatedAt = () => ts('updated_at').notNull().defaultNow(); export const tsvector = customType<{ data: string }>({ dataType() { return 'tsvector'; }, }); export const textArray = (name: string) => text(name).array().notNull().default(sql`'{}'::text[]`); export const jsonObject = >(name: string) => jsonb(name).$type().notNull().default(sql`'{}'::jsonb`); export const jsonArray = (name: string) => jsonb(name).$type().notNull().default(sql`'[]'::jsonb`);