File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -369,8 +369,8 @@ export type ArtistLibraryCrossreference = InferSelectModel<typeof artist_library
369369export const artist_library_crossreference = wxyc_schema . table (
370370 'artist_library_crossreference' ,
371371 {
372- artist_id : integer ( 'artist_id' ) . references ( ( ) => artists . id ) ,
373- library_id : integer ( 'library_id' ) . references ( ( ) => library . id ) ,
372+ artist_id : integer ( 'artist_id' ) . references ( ( ) => artists . id ) . notNull ( ) ,
373+ library_id : integer ( 'library_id' ) . references ( ( ) => library . id ) . notNull ( ) ,
374374 } ,
375375 ( table ) => [ uniqueIndex ( 'library_id_artist_id' ) . on ( table . artist_id , table . library_id ) ]
376376) ;
Original file line number Diff line number Diff line change 1+ import * as fs from 'fs' ;
2+ import * as path from 'path' ;
3+
4+ const schemaSource = fs . readFileSync (
5+ path . resolve ( __dirname , '../../../shared/database/src/schema.ts' ) ,
6+ 'utf-8'
7+ ) ;
8+
9+ function extractTableBlock ( source : string , tableName : string ) : string {
10+ const pattern = new RegExp (
11+ `export const ${ tableName } \\s*=\\s*wxyc_schema\\.table\\([\\s\\S]*?\\);`
12+ ) ;
13+ const match = source . match ( pattern ) ;
14+ if ( ! match ) throw new Error ( `Table "${ tableName } " not found in schema.ts` ) ;
15+ return match [ 0 ] ;
16+ }
17+
18+ describe ( 'artist_library_crossreference schema' , ( ) => {
19+ const block = extractTableBlock ( schemaSource , 'artist_library_crossreference' ) ;
20+
21+ it ( 'artist_id column has .notNull()' , ( ) => {
22+ const artistIdLine = block
23+ . split ( '\n' )
24+ . find ( ( line ) => line . includes ( "artist_id:" ) || line . includes ( "'artist_id'" ) ) ;
25+ expect ( artistIdLine ) . toBeDefined ( ) ;
26+ expect ( artistIdLine ) . toContain ( '.notNull()' ) ;
27+ } ) ;
28+
29+ it ( 'library_id column has .notNull()' , ( ) => {
30+ const libraryIdLine = block
31+ . split ( '\n' )
32+ . find ( ( line ) => line . includes ( "library_id:" ) || line . includes ( "'library_id'" ) ) ;
33+ expect ( libraryIdLine ) . toBeDefined ( ) ;
34+ expect ( libraryIdLine ) . toContain ( '.notNull()' ) ;
35+ } ) ;
36+ } ) ;
You can’t perform that action at this time.
0 commit comments