mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:27:08 -04:00 
			
		
		
		
	* feat: support for class level composite fk * chore: clean up --------- Co-authored-by: Jason Rasmussen <jason@rasm.me>
		
			
				
	
	
		
			45 lines
		
	
	
		
			948 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			948 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { Column, DatabaseSchema, ForeignKeyConstraint, Table } from 'src/sql-tools';
 | |
| 
 | |
| class Foo {}
 | |
| 
 | |
| @Table()
 | |
| @ForeignKeyConstraint({
 | |
|   columns: ['parentId'],
 | |
|   referenceTable: () => Foo,
 | |
| })
 | |
| export class Table1 {
 | |
|   @Column()
 | |
|   parentId!: string;
 | |
| }
 | |
| 
 | |
| export const description = 'should warn against missing reference table';
 | |
| export const schema: DatabaseSchema = {
 | |
|   name: 'postgres',
 | |
|   schemaName: 'public',
 | |
|   functions: [],
 | |
|   enums: [],
 | |
|   extensions: [],
 | |
|   parameters: [],
 | |
|   tables: [
 | |
|     {
 | |
|       name: 'table1',
 | |
|       columns: [
 | |
|         {
 | |
|           name: 'parentId',
 | |
|           tableName: 'table1',
 | |
|           type: 'character varying',
 | |
|           nullable: false,
 | |
|           isArray: false,
 | |
|           primary: false,
 | |
|           synchronize: true,
 | |
|         },
 | |
|       ],
 | |
|       indexes: [],
 | |
|       triggers: [],
 | |
|       constraints: [],
 | |
|       synchronize: true,
 | |
|     },
 | |
|   ],
 | |
|   warnings: ['[@ForeignKeyConstraint.referenceTable] Unable to find table (Foo)'],
 | |
| };
 |