( client: Database, left: SqliteSchema, right: SqliteSchema, renamesArr: string[], cli: boolean = false, seedStatements: string[] = [], casing?: CasingType | undefined, )
| 1816 | }; |
| 1817 | |
| 1818 | export const diffTestSchemasPushSqlite = async ( |
| 1819 | client: Database, |
| 1820 | left: SqliteSchema, |
| 1821 | right: SqliteSchema, |
| 1822 | renamesArr: string[], |
| 1823 | cli: boolean = false, |
| 1824 | seedStatements: string[] = [], |
| 1825 | casing?: CasingType | undefined, |
| 1826 | ) => { |
| 1827 | const { sqlStatements } = await applySqliteDiffs(left, 'push'); |
| 1828 | |
| 1829 | for (const st of sqlStatements) { |
| 1830 | client.exec(st); |
| 1831 | } |
| 1832 | |
| 1833 | for (const st of seedStatements) { |
| 1834 | client.exec(st); |
| 1835 | } |
| 1836 | |
| 1837 | // do introspect into PgSchemaInternal |
| 1838 | const introspectedSchema = await fromSqliteDatabase( |
| 1839 | { |
| 1840 | query: async <T>(sql: string, params: any[] = []) => { |
| 1841 | return client.prepare(sql).bind(params).all() as T[]; |
| 1842 | }, |
| 1843 | run: async (query: string) => { |
| 1844 | client.prepare(query).run(); |
| 1845 | }, |
| 1846 | }, |
| 1847 | undefined, |
| 1848 | ); |
| 1849 | |
| 1850 | const rightTables = Object.values(right).filter((it) => is(it, SQLiteTable)) as SQLiteTable[]; |
| 1851 | |
| 1852 | const rightViews = Object.values(right).filter((it) => is(it, SQLiteView)) as SQLiteView[]; |
| 1853 | |
| 1854 | const serialized2 = generateSqliteSnapshot(rightTables, rightViews, casing); |
| 1855 | |
| 1856 | const { version: v1, dialect: d1, ...rest1 } = introspectedSchema; |
| 1857 | const { version: v2, dialect: d2, ...rest2 } = serialized2; |
| 1858 | |
| 1859 | const sch1 = { |
| 1860 | version: '6', |
| 1861 | dialect: 'sqlite', |
| 1862 | id: '0', |
| 1863 | prevId: '0', |
| 1864 | ...rest1, |
| 1865 | } as const; |
| 1866 | |
| 1867 | const sch2 = { |
| 1868 | version: '6', |
| 1869 | dialect: 'sqlite', |
| 1870 | id: '0', |
| 1871 | prevId: '0', |
| 1872 | ...rest2, |
| 1873 | } as const; |
| 1874 | |
| 1875 | const sn1 = squashSqliteScheme(sch1, 'push'); |
no test coverage detected