import { boolean, char, doublePrecision, integer, jsonb, pgEnum, pgTable, serial, text, timestamp, uuid, varchar, vector } from 'drizzle-orm/pg-core'; import { AreasServed, LicensedIn } from '../models/db.model'; export const PG_CONNECTION = 'PG_CONNECTION'; export const genderEnum = pgEnum('gender', ['male', 'female']); export const customerTypeEnum = pgEnum('customerType', ['buyer', 'professional']); export const customerSubTypeEnum = pgEnum('customerSubType', ['broker', 'cpa', 'attorney', 'titleCompany', 'surveyor', 'appraiser']); export const users = pgTable('users', { id: uuid('id').primaryKey().defaultRandom(), firstname: varchar('firstname', { length: 255 }).notNull(), lastname: varchar('lastname', { length: 255 }).notNull(), email: varchar('email', { length: 255 }).notNull().unique(), phoneNumber: varchar('phoneNumber', { length: 255 }), description: text('description'), companyName: varchar('companyName', { length: 255 }), companyOverview: text('companyOverview'), companyWebsite: varchar('companyWebsite', { length: 255 }), companyLocation: varchar('companyLocation', { length: 255 }), offeredServices: text('offeredServices'), areasServed: jsonb('areasServed').$type(), hasProfile: boolean('hasProfile'), hasCompanyLogo: boolean('hasCompanyLogo'), licensedIn: jsonb('licensedIn').$type(), gender: genderEnum('gender'), customerType: customerTypeEnum('customerType'), customerSubType: customerSubTypeEnum('customerSubType'), created: timestamp('created'), updated: timestamp('updated'), embedding: vector('embedding', { dimensions: 1536 }), }); export const businesses = pgTable('businesses', { id: uuid('id').primaryKey().defaultRandom(), email: varchar('email', { length: 255 }).references(() => users.email), type: integer('type'), title: varchar('title', { length: 255 }), description: text('description'), city: varchar('city', { length: 255 }), state: char('state', { length: 2 }), price: doublePrecision('price'), favoritesForUser: varchar('favoritesForUser', { length: 30 }).array(), draft: boolean('draft'), listingsCategory: varchar('listingsCategory', { length: 255 }), realEstateIncluded: boolean('realEstateIncluded'), leasedLocation: boolean('leasedLocation'), franchiseResale: boolean('franchiseResale'), salesRevenue: doublePrecision('salesRevenue'), cashFlow: doublePrecision('cashFlow'), supportAndTraining: text('supportAndTraining'), employees: integer('employees'), established: integer('established'), internalListingNumber: integer('internalListingNumber'), reasonForSale: varchar('reasonForSale', { length: 255 }), brokerLicencing: varchar('brokerLicencing', { length: 255 }), internals: text('internals'), imageName: varchar('imagePath', { length: 200 }), created: timestamp('created'), updated: timestamp('updated'), visits: integer('visits'), lastVisit: timestamp('lastVisit'), // Neue Spalte für das OpenAI Embedding embedding: vector('embedding', { dimensions: 1536 }), }); export const commercials = pgTable('commercials', { id: uuid('id').primaryKey().defaultRandom(), serialId: serial('serial_id'), email: varchar('email', { length: 255 }).references(() => users.email), type: integer('type'), title: varchar('title', { length: 255 }), description: text('description'), city: varchar('city', { length: 255 }), state: char('state', { length: 2 }), price: doublePrecision('price'), favoritesForUser: varchar('favoritesForUser', { length: 30 }).array(), listingsCategory: varchar('listingsCategory', { length: 255 }), hideImage: boolean('hideImage'), draft: boolean('draft'), zipCode: integer('zipCode'), county: varchar('county', { length: 255 }), imageOrder: varchar('imageOrder', { length: 200 }).array(), imagePath: varchar('imagePath', { length: 200 }), created: timestamp('created'), updated: timestamp('updated'), visits: integer('visits'), lastVisit: timestamp('lastVisit'), embedding: vector('embedding', { dimensions: 1536 }), });