11/* eslint-disable sort-keys-fix/sort-keys-fix */
22import { isNotNull } from 'drizzle-orm' ;
33import {
4+ AnyPgColumn ,
45 boolean ,
56 index ,
67 integer ,
@@ -41,7 +42,6 @@ export type GlobalFileItem = typeof globalFiles.$inferSelect;
4142/**
4243 * Documents table - Stores file content or web search results
4344 */
44- // @ts -ignore
4545export const documents = pgTable (
4646 'documents' ,
4747 {
@@ -72,15 +72,12 @@ export const documents = pgTable(
7272 source : text ( 'source' ) . notNull ( ) , // File path or web URL
7373
7474 // Associated file (optional)
75- // Forward reference to files table defined below
75+ // forward reference needs AnyPgColumn to avoid circular type inference
7676 // eslint-disable-next-line @typescript-eslint/no-use-before-define
77- // @ts -expect-error - files is defined later in this file, forward reference is valid at runtime
78- // eslint-disable-next-line @typescript-eslint/no-use-before-define
79- fileId : text ( 'file_id' ) . references ( ( ) => files . id , { onDelete : 'set null' } ) ,
77+ fileId : text ( 'file_id' ) . references ( ( ) : AnyPgColumn => files . id , { onDelete : 'set null' } ) ,
8078
8179 // Parent document (for folder hierarchy structure)
82- // @ts -ignore
83- parentId : varchar ( 'parent_id' , { length : 255 } ) . references ( ( ) => documents . id , {
80+ parentId : varchar ( 'parent_id' , { length : 255 } ) . references ( ( ) : AnyPgColumn => documents . id , {
8481 onDelete : 'set null' ,
8582 } ) ,
8683
@@ -113,7 +110,6 @@ export type NewDocument = typeof documents.$inferInsert;
113110export type DocumentItem = typeof documents . $inferSelect ;
114111export const insertDocumentSchema = createInsertSchema ( documents ) ;
115112
116- // @ts -ignore
117113export const files = pgTable (
118114 'files' ,
119115 {
@@ -140,8 +136,7 @@ export const files = pgTable(
140136 source : text ( 'source' ) . $type < FileSource > ( ) ,
141137
142138 // Parent Folder or Document
143- // @ts -ignore
144- parentId : varchar ( 'parent_id' , { length : 255 } ) . references ( ( ) => documents . id , {
139+ parentId : varchar ( 'parent_id' , { length : 255 } ) . references ( ( ) : AnyPgColumn => documents . id , {
145140 onDelete : 'set null' ,
146141 } ) ,
147142
0 commit comments