Skip to content

Instantly share code, notes, and snippets.

@mattfysh
Created March 14, 2024 04:06
Show Gist options
  • Save mattfysh/4e775659aada68a66b78e3b846ebd4a1 to your computer and use it in GitHub Desktop.
Save mattfysh/4e775659aada68a66b78e3b846ebd4a1 to your computer and use it in GitHub Desktop.
using push-generated statements in `generate:sqlite`
import { get, patch, wrapImports } from './rewire'
const push = get('logSuggestionsAndReturn2')
const move = patch('_moveDataStatements', function (tableName, json) {
// set dataLoss=false to generate copy statements
return move.call(this, tableName, json, false)
})
wrapImports('init_migrate', {
async prepareSQL(prep, json1, json2) {
const { statements, _meta: meta } = await prep()
const connection = {
query: async () => [{ count: 0 }],
}
const { statementsToExecute: sqlStatements } = await push({
connection,
statements,
json1,
json2,
meta,
})
return { statements, sqlStatements, meta }
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment