Files
Kordant/web/src/server/db/schema/enums.ts
Michael Freno bc20aeaeb6 feat: migrate full Prisma schema to Drizzle ORM (29 tables, 28 enums, 25 relations)
- Install drizzle-orm, drizzle-kit, pg, @types/pg in web/
- Create split schema directory with domain files:
  - auth (users, accounts, sessions, deviceTokens)
  - subscription (familyGroups, familyGroupMembers, subscriptions)
  - darkwatch (watchlistItems, exposures)
  - alerts
  - voiceprint (voiceEnrollments, voiceAnalyses, analysisJobs, analysisResults)
  - spamshield (spamFeedback, spamRules)
  - audit (auditLogs, kpiSnapshots)
  - correlation (normalizedAlerts, correlationGroups)
  - reports (securityReports)
  - marketing (waitlistEntries, blogPosts)
  - hometitle (propertyWatchlistItems, propertySnapshots, propertyChanges)
  - removebrokers (infoBrokers, removalRequests, brokerListings)
- Define all 28 PostgreSQL enums via pgEnum()
- Define all indexes, unique constraints, and foreign keys
- Define all 25 relation definitions via relations() helper
- Update drizzle.config.ts for PostgreSQL dialect
- Update db/index.ts for node-postgres connection
- Replace old placeholder schema.ts with barrel re-export
- Add 38 comprehensive schema tests
2026-05-25 15:35:10 -04:00

32 lines
3.3 KiB
TypeScript

import { pgEnum } from "drizzle-orm/pg-core";
export const userRole = pgEnum("user_role", ["user", "family_admin", "family_member", "support"]);
export const deviceType = pgEnum("device_type", ["mobile", "web", "desktop"]);
export const platform = pgEnum("platform", ["ios", "android", "web"]);
export const familyMemberRole = pgEnum("family_member_role", ["owner", "admin", "member"]);
export const subscriptionTier = pgEnum("subscription_tier", ["basic", "plus", "premium"]);
export const subscriptionStatus = pgEnum("subscription_status", ["active", "past_due", "canceled", "unpaid", "trialing"]);
export const watchlistType = pgEnum("watchlist_type", ["email", "phoneNumber", "ssn", "address", "domain"]);
export const exposureSource = pgEnum("exposure_source", ["hibp", "securityTrails", "censys", "darkWebForum", "shodan", "honeypot"]);
export const exposureSeverity = pgEnum("exposure_severity", ["info", "warning", "critical"]);
export const alertType = pgEnum("alert_type", ["exposure_detected", "exposure_resolved", "scan_complete", "subscription_changed", "system_warning"]);
export const alertSeverity = pgEnum("alert_severity", ["info", "warning", "critical"]);
export const alertChannel = pgEnum("alert_channel", ["email", "push", "sms"]);
export const detectionVerdict = pgEnum("detection_verdict", ["NATURAL", "SYNTHETIC", "UNCERTAIN"]);
export const analysisType = pgEnum("analysis_type", ["SYNTHETIC_DETECTION", "VOICE_MATCH", "BATCH"]);
export const analysisJobStatus = pgEnum("analysis_job_status", ["PENDING", "RUNNING", "COMPLETED", "FAILED"]);
export const feedbackType = pgEnum("feedback_type", ["initial_detection", "user_confirmation", "user_rejection", "auto_learned"]);
export const ruleType = pgEnum("rule_type", ["phoneNumber", "areaCode", "prefix", "pattern", "reputation"]);
export const ruleAction = pgEnum("rule_action", ["block", "flag", "allow", "challenge"]);
export const alertSource = pgEnum("alert_source", ["DARKWATCH", "SPAMSHIELD", "VOICEPRINT", "CALL_ANALYSIS", "HOME_TITLE", "INFO_BROKER"]);
export const alertCategory = pgEnum("alert_category", ["BREACH_EXPOSURE", "SPAM_CALL", "SPAM_SMS", "SYNTHETIC_VOICE", "VOICE_MISMATCH", "CALL_ANOMALY", "CALL_QUALITY", "CALL_EVENT", "HOME_TITLE", "INFO_BROKER_LISTING", "INFO_BROKER_REMOVAL"]);
export const normalizedAlertSeverity = pgEnum("normalized_alert_severity", ["LOW", "INFO", "MEDIUM", "WARNING", "HIGH", "CRITICAL"]);
export const correlationStatus = pgEnum("correlation_status", ["ACTIVE", "RESOLVED", "FALSE_POSITIVE"]);
export const reportType = pgEnum("report_type", ["MONTHLY_PLUS", "ANNUAL_PREMIUM", "WEEKLY_DIGEST"]);
export const reportStatus = pgEnum("report_status", ["PENDING", "GENERATING", "COMPLETED", "FAILED", "DELIVERED"]);
export const propertyChangeType = pgEnum("property_change_type", ["tax_change", "deed_change", "ownership_transfer", "lien_filing", "metadata_change"]);
export const propertyChangeSeverity = pgEnum("property_change_severity", ["info", "warning", "critical"]);
export const brokerCategory = pgEnum("broker_category", ["PEOPLE_SEARCH", "BACKGROUND_CHECK", "PUBLIC_RECORDS", "REVERSE_LOOKUP", "SOCIAL_MEDIA"]);
export const removalMethod = pgEnum("removal_method", ["AUTOMATED", "MANUAL_FORM", "EMAIL", "PHONE", "MAIL", "NONE"]);
export const removalStatus = pgEnum("removal_status", ["PENDING", "SUBMITTED", "IN_PROGRESS", "COMPLETED", "FAILED", "REJECTED", "CANCELLED"]);