(
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',
)
| 3792 | }; |
| 3793 | |
| 3794 | export const applyLibSQLSnapshotsDiff = async ( |
| 3795 | json1: SQLiteSchemaSquashed, |
| 3796 | json2: SQLiteSchemaSquashed, |
| 3797 | tablesResolver: ( |
| 3798 | input: ResolverInput<Table>, |
| 3799 | ) => Promise<ResolverOutputWithMoved<Table>>, |
| 3800 | columnsResolver: ( |
| 3801 | input: ColumnsResolverInput<Column>, |
| 3802 | ) => Promise<ColumnsResolverOutput<Column>>, |
| 3803 | viewsResolver: ( |
| 3804 | input: ResolverInput<SqliteView & { schema: '' }>, |
| 3805 | ) => Promise<ResolverOutputWithMoved<SqliteView>>, |
| 3806 | prevFull: SQLiteSchema, |
| 3807 | curFull: SQLiteSchema, |
| 3808 | action?: 'push', |
| 3809 | ): Promise<{ |
| 3810 | statements: JsonStatement[]; |
| 3811 | sqlStatements: string[]; |
| 3812 | _meta: |
| 3813 | | { |
| 3814 | schemas: {}; |
| 3815 | tables: {}; |
| 3816 | columns: {}; |
| 3817 | } |
| 3818 | | undefined; |
| 3819 | }> => { |
| 3820 | const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables); |
| 3821 | const { |
| 3822 | created: createdTables, |
| 3823 | deleted: deletedTables, |
| 3824 | renamed: renamedTables, |
| 3825 | } = await tablesResolver({ |
| 3826 | created: tablesDiff.added, |
| 3827 | deleted: tablesDiff.deleted, |
| 3828 | }); |
| 3829 | |
| 3830 | const tablesPatchedSnap1 = copy(json1); |
| 3831 | tablesPatchedSnap1.tables = mapEntries(tablesPatchedSnap1.tables, (_, it) => { |
| 3832 | const { name } = nameChangeFor(it, renamedTables); |
| 3833 | it.name = name; |
| 3834 | return [name, it]; |
| 3835 | }); |
| 3836 | |
| 3837 | const res = diffColumns(tablesPatchedSnap1.tables, json2.tables); |
| 3838 | |
| 3839 | const columnRenames = [] as { |
| 3840 | table: string; |
| 3841 | renames: { from: Column; to: Column }[]; |
| 3842 | }[]; |
| 3843 | |
| 3844 | const columnCreates = [] as { |
| 3845 | table: string; |
| 3846 | columns: Column[]; |
| 3847 | }[]; |
| 3848 | |
| 3849 | const columnDeletes = [] as { |
| 3850 | table: string; |
| 3851 | columns: Column[]; |
no test coverage detected