{"version":3,"file":"common.mjs","sources":["../../src/migrations/common.ts"],"sourcesContent":["import type { Resolver } from 'umzug';\nimport type { Knex } from 'knex';\n\nimport type { Database } from '..';\n\nexport interface UserMigrationProvider {\n  shouldRun(): Promise<boolean>;\n  up(): Promise<void>;\n  down(): Promise<void>;\n}\n\nexport interface InternalMigrationProvider {\n  register(migration: Migration): void;\n  shouldRun(): Promise<boolean>;\n  up(): Promise<void>;\n  down(): Promise<void>;\n}\nexport interface MigrationProvider {\n  providers: { internal: InternalMigrationProvider };\n  shouldRun(): Promise<boolean>;\n  up(): Promise<void>;\n  down(): Promise<void>;\n}\n\nexport type Context = { db: Database };\n\nexport type MigrationResolver = Resolver<Context>;\n\nexport type MigrationFn = (knex: Knex.Transaction, db: Database) => Promise<void>;\n\nexport type Migration = {\n  name: string;\n  up: MigrationFn;\n  down: MigrationFn;\n};\n\nexport const wrapTransaction = (db: Database) => (fn: MigrationFn) => () => {\n  return db.transaction(({ trx }) => Promise.resolve(fn(trx, db)));\n};\n"],"names":["wrapTransaction","db","fn","transaction","trx","Promise","resolve"],"mappings":"AAoCaA,MAAAA,eAAAA,GAAkB,CAACC,EAAAA,GAAiB,CAACC,EAAoB,GAAA,IAAA;AACpE,YAAA,OAAOD,EAAGE,CAAAA,WAAW,CAAC,CAAC,EAAEC,GAAG,EAAE,GAAKC,OAAQC,CAAAA,OAAO,CAACJ,EAAAA,CAAGE,GAAKH,EAAAA,EAAAA,CAAAA,CAAAA,CAAAA;;;;;"}