( table: Table, action?: 'push' | undefined, )
| 974 | }; |
| 975 | |
| 976 | export const prepareSQLiteCreateTable = ( |
| 977 | table: Table, |
| 978 | action?: 'push' | undefined, |
| 979 | ): JsonSqliteCreateTableStatement => { |
| 980 | const { name, columns, uniqueConstraints, checkConstraints } = table; |
| 981 | |
| 982 | const references: string[] = Object.values(table.foreignKeys); |
| 983 | |
| 984 | const composites: string[][] = Object.values(table.compositePrimaryKeys).map( |
| 985 | (it) => SQLiteSquasher.unsquashPK(it), |
| 986 | ); |
| 987 | |
| 988 | const fks = references.map((it) => |
| 989 | action === 'push' |
| 990 | ? SQLiteSquasher.unsquashPushFK(it) |
| 991 | : SQLiteSquasher.unsquashFK(it) |
| 992 | ); |
| 993 | |
| 994 | return { |
| 995 | type: 'sqlite_create_table', |
| 996 | tableName: name, |
| 997 | columns: Object.values(columns), |
| 998 | referenceData: fks, |
| 999 | compositePKs: composites, |
| 1000 | uniqueConstraints: Object.values(uniqueConstraints), |
| 1001 | checkConstraints: Object.values(checkConstraints), |
| 1002 | }; |
| 1003 | }; |
| 1004 | |
| 1005 | export const prepareDropTableJson = (table: Table): JsonDropTableStatement => { |
| 1006 | return { |
no test coverage detected