11import { sql } from "drizzle-orm" ;
22import {
33 boolean ,
4+ check ,
45 foreignKey ,
6+ index ,
57 integer ,
68 jsonb ,
79 pgTable ,
@@ -49,9 +51,7 @@ export const verification = pgTable("verification", {
4951export const sites = pgTable (
5052 "sites" ,
5153 {
52- id : text ( "id" )
53- . notNull ( )
54- . $defaultFn ( ( ) => sql `encode(gen_random_bytes(6), 'hex')` ) ,
54+ id : text ( "id" ) . $defaultFn ( ( ) => sql `encode(gen_random_bytes(6), 'hex')` ) ,
5555 // deprecated - keeping as primary key for backwards compatibility
5656 siteId : serial ( "site_id" ) . primaryKey ( ) . notNull ( ) ,
5757 name : text ( "name" ) . notNull ( ) ,
@@ -358,7 +358,7 @@ export const uptimeMonitors = pgTable(
358358 . notNull ( )
359359 . references ( ( ) => user . id ) ,
360360 } ,
361- ( table ) => [
361+ table => [
362362 foreignKey ( {
363363 columns : [ table . organizationId ] ,
364364 foreignColumns : [ organization . id ] ,
@@ -369,7 +369,7 @@ export const uptimeMonitors = pgTable(
369369 foreignColumns : [ user . id ] ,
370370 name : "uptime_monitors_created_by_user_id_fk" ,
371371 } ) ,
372- ] ,
372+ ]
373373) ;
374374
375375// Monitor status tracking
@@ -391,7 +391,7 @@ export const uptimeMonitorStatus = pgTable(
391391 averageResponseTime24h : real ( "average_response_time_24h" ) ,
392392 updatedAt : timestamp ( "updated_at" , { mode : "string" } ) . defaultNow ( ) ,
393393 } ,
394- ( table ) => [
394+ table => [
395395 foreignKey ( {
396396 columns : [ table . monitorId ] ,
397397 foreignColumns : [ uptimeMonitors . id ] ,
@@ -402,7 +402,7 @@ export const uptimeMonitorStatus = pgTable(
402402 check ( "uptime_monitor_status_uptime_7d_check" , sql `uptime_percentage_7d >= 0 AND uptime_percentage_7d <= 100` ) ,
403403 check ( "uptime_monitor_status_uptime_30d_check" , sql `uptime_percentage_30d >= 0 AND uptime_percentage_30d <= 100` ) ,
404404 index ( "uptime_monitor_status_updated_at_idx" ) . on ( table . updatedAt ) ,
405- ] ,
405+ ]
406406) ;
407407
408408// Alert configuration (scaffolding)
@@ -423,13 +423,13 @@ export const uptimeAlerts = pgTable(
423423 enabled : boolean ( "enabled" ) . default ( true ) ,
424424 createdAt : timestamp ( "created_at" , { mode : "string" } ) . defaultNow ( ) ,
425425 } ,
426- ( table ) => [
426+ table => [
427427 foreignKey ( {
428428 columns : [ table . monitorId ] ,
429429 foreignColumns : [ uptimeMonitors . id ] ,
430430 name : "uptime_alerts_monitor_id_uptime_monitors_id_fk" ,
431431 } ) ,
432- ] ,
432+ ]
433433) ;
434434
435435// Alert history (scaffolding)
@@ -447,7 +447,7 @@ export const uptimeAlertHistory = pgTable(
447447 resolvedAt : timestamp ( "resolved_at" , { mode : "string" } ) ,
448448 alertData : jsonb ( "alert_data" ) , // Context about what triggered the alert
449449 } ,
450- ( table ) => [
450+ table => [
451451 foreignKey ( {
452452 columns : [ table . alertId ] ,
453453 foreignColumns : [ uptimeAlerts . id ] ,
@@ -458,7 +458,7 @@ export const uptimeAlertHistory = pgTable(
458458 foreignColumns : [ uptimeMonitors . id ] ,
459459 name : "uptime_alert_history_monitor_id_uptime_monitors_id_fk" ,
460460 } ) ,
461- ] ,
461+ ]
462462) ;
463463
464464// Agent regions for VPS-based monitoring
@@ -506,7 +506,7 @@ export const uptimeIncidents = pgTable(
506506 createdAt : timestamp ( "created_at" , { mode : "string" } ) . defaultNow ( ) ,
507507 updatedAt : timestamp ( "updated_at" , { mode : "string" } ) . defaultNow ( ) ,
508508 } ,
509- ( table ) => [
509+ table => [
510510 foreignKey ( {
511511 columns : [ table . organizationId ] ,
512512 foreignColumns : [ organization . id ] ,
@@ -527,7 +527,7 @@ export const uptimeIncidents = pgTable(
527527 foreignColumns : [ user . id ] ,
528528 name : "uptime_incidents_resolved_by_user_id_fk" ,
529529 } ) ,
530- ] ,
530+ ]
531531) ;
532532
533533// Notification channels table
@@ -571,7 +571,7 @@ export const notificationChannels = pgTable(
571571 . notNull ( )
572572 . references ( ( ) => user . id ) ,
573573 } ,
574- ( table ) => [
574+ table => [
575575 foreignKey ( {
576576 columns : [ table . organizationId ] ,
577577 foreignColumns : [ organization . id ] ,
@@ -582,5 +582,5 @@ export const notificationChannels = pgTable(
582582 foreignColumns : [ user . id ] ,
583583 name : "notification_channels_created_by_user_id_fk" ,
584584 } ) ,
585- ] ,
585+ ]
586586) ;
0 commit comments