(
json1: SQLiteSchemaSquashed,
json2: SQLiteSchemaSquashed,
tablesResolver: (
input: ResolverInput<Table>,
) => Promise<ResolverOutputWithMoved<Table>>,
columnsResolver: (
input: ColumnsResolverInput<Column>,
) => Promise<ColumnsResolverOutput<Column>>,
viewsResolver: (
input: ResolverInput<SqliteView & { schema: '' }>,
) => Promise<ResolverOutputWithMoved<SqliteView>>,
prevFull: SQLiteSchema,
curFull: SQLiteSchema,
action?: 'push' | undefined,
)
| 3237 | }; |
| 3238 | |
| 3239 | export const applySqliteSnapshotsDiff = async ( |
| 3240 | json1: SQLiteSchemaSquashed, |
| 3241 | json2: SQLiteSchemaSquashed, |
| 3242 | tablesResolver: ( |
| 3243 | input: ResolverInput<Table>, |
| 3244 | ) => Promise<ResolverOutputWithMoved<Table>>, |
| 3245 | columnsResolver: ( |
| 3246 | input: ColumnsResolverInput<Column>, |
| 3247 | ) => Promise<ColumnsResolverOutput<Column>>, |
| 3248 | viewsResolver: ( |
| 3249 | input: ResolverInput<SqliteView & { schema: '' }>, |
| 3250 | ) => Promise<ResolverOutputWithMoved<SqliteView>>, |
| 3251 | prevFull: SQLiteSchema, |
| 3252 | curFull: SQLiteSchema, |
| 3253 | action?: 'push' | undefined, |
| 3254 | ): Promise<{ |
| 3255 | statements: JsonStatement[]; |
| 3256 | sqlStatements: string[]; |
| 3257 | _meta: |
| 3258 | | { |
| 3259 | schemas: {}; |
| 3260 | tables: {}; |
| 3261 | columns: {}; |
| 3262 | } |
| 3263 | | undefined; |
| 3264 | }> => { |
| 3265 | const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables); |
| 3266 | |
| 3267 | const { |
| 3268 | created: createdTables, |
| 3269 | deleted: deletedTables, |
| 3270 | renamed: renamedTables, |
| 3271 | } = await tablesResolver({ |
| 3272 | created: tablesDiff.added, |
| 3273 | deleted: tablesDiff.deleted, |
| 3274 | }); |
| 3275 | |
| 3276 | const tablesPatchedSnap1 = copy(json1); |
| 3277 | tablesPatchedSnap1.tables = mapEntries(tablesPatchedSnap1.tables, (_, it) => { |
| 3278 | const { name } = nameChangeFor(it, renamedTables); |
| 3279 | it.name = name; |
| 3280 | return [name, it]; |
| 3281 | }); |
| 3282 | |
| 3283 | const res = diffColumns(tablesPatchedSnap1.tables, json2.tables); |
| 3284 | |
| 3285 | const columnRenames = [] as { |
| 3286 | table: string; |
| 3287 | renames: { from: Column; to: Column }[]; |
| 3288 | }[]; |
| 3289 | |
| 3290 | const columnCreates = [] as { |
| 3291 | table: string; |
| 3292 | columns: Column[]; |
| 3293 | }[]; |
| 3294 | |
| 3295 | const columnDeletes = [] as { |
| 3296 | table: string; |
no test coverage detected