diff --git a/node_modules/sqlite-up/dist/index.d.ts b/node_modules/sqlite-up/dist/index.d.ts
index 99bf154..6e76bae 100644
--- a/node_modules/sqlite-up/dist/index.d.ts
+++ b/node_modules/sqlite-up/dist/index.d.ts
@@ -1,5 +1,5 @@
 import { EventEmitter } from 'node:events';
-import type { MigrationPlan, MigrationResult, MigrationStatus, MigratorOptions } from './types.js';
+import type { MigrationPlan, MigrationResult, MigrationStatus, MigratorOptions, OptionalArg } from './types.js';
 /**
  * Migration provider for SQLite databases.
  * @example
@@ -7,7 +7,7 @@ import type { MigrationPlan, MigrationResult, MigrationStatus, MigratorOptions }
  * const migrator = new Migrator({ db, migrationsDir: 'migrations' });
  * await migrator.apply();
  */
-export declare class Migrator extends EventEmitter {
+export declare class Migrator<T = undefined> extends EventEmitter {
     /**
      * Driver-specific provider normalized to the sqlite-up database surface.
      */
@@ -86,12 +86,12 @@ export declare class Migrator extends EventEmitter {
      * Apply all pending migrations in a single batch.
      * Returns the names of applied migrations.
      */
-    apply(): Promise<MigrationResult>;
+    apply(...args: OptionalArg<T>): Promise<MigrationResult>;
     /**
      * Roll back the most recent batch of migrations.
      * Returns the names of rolled back migrations.
      */
-    rollback(): Promise<MigrationResult>;
+    rollback(...args: OptionalArg<T>): Promise<MigrationResult>;
     /**
      * Get the status of migrations.
      * Returns:
diff --git a/node_modules/sqlite-up/dist/index.d.ts.map b/node_modules/sqlite-up/dist/index.d.ts.map
index 7f76322..4bdcd79 100644
--- a/node_modules/sqlite-up/dist/index.d.ts.map
+++ b/node_modules/sqlite-up/dist/index.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,OAAO,KAAK,EAGV,aAAa,EAEb,eAAe,EACf,eAAe,EACf,eAAe,EAEhB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,YAAY;IACxC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAiB;IAEjC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAiB;IAE3B;;OAEG;IACH,OAAO,CAAC,aAAa,CAAS;IAE9B;;OAEG;IACH,OAAO,CAAC,eAAe,CAAS;IAEhC;;OAEG;IACH,OAAO,CAAC,SAAS,CAAS;IAE1B;;OAEG;IACH,OAAO,CAAC,UAAU,CAAmB;IAErC;;OAEG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;OAEG;IACH,OAAO,CAAC,cAAc,CAAW;gBAErB,OAAO,EAAE,eAAe;IAWpC;;;OAGG;YACW,IAAI;IAWlB;;OAEG;YACW,UAAU;IA8BxB;;;;OAIG;YACW,2BAA2B;IA8CzC;;;OAGG;YACW,WAAW;IAsBzB;;OAEG;YACW,WAAW;IAQzB;;OAEG;YACW,eAAe;IAO7B;;OAEG;YACW,eAAe;IAY7B;;OAEG;YACW,eAAe;IAW7B;;;OAGG;YACW,cAAc;IAI5B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC;IAyEvC;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC;IAsF1C;;;;;;OAMG;IACG,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC;IA+BxC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;CAwBrC;AAED,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
\ No newline at end of file
diff --git a/node_modules/sqlite-up/dist/index.js b/node_modules/sqlite-up/dist/index.js
index 6317262..0f1f2f7 100644
--- a/node_modules/sqlite-up/dist/index.js
+++ b/node_modules/sqlite-up/dist/index.js
@@ -349,7 +349,7 @@ var Migrator = class extends EventEmitter {
    * Apply all pending migrations in a single batch.
    * Returns the names of applied migrations.
    */
-  async apply() {
+  async apply(...args) {
     try {
       await this.init();
     } catch (err) {
@@ -384,7 +384,7 @@ var Migrator = class extends EventEmitter {
       await this.runTransaction(async () => {
         for (const migration of pendingMigrations) {
           try {
-            await migration.up(this.db);
+            await migration.up(this.db, args[0]);
             await this.recordMigration(migration.name, nextBatch);
             appliedMigrations.push(migration.name);
           } catch (err) {
@@ -407,7 +407,7 @@ var Migrator = class extends EventEmitter {
    * Roll back the most recent batch of migrations.
    * Returns the names of rolled back migrations.
    */
-  async rollback() {
+  async rollback(...args) {
     try {
       await this.init();
     } catch (err) {
@@ -450,7 +450,7 @@ var Migrator = class extends EventEmitter {
             throw new MigrationFileError(`Migration "${row.name}" not found.`);
           }
           try {
-            await migration.down(this.db);
+            await migration.down(this.db, args[0]);
             await this.removeMigration(migration.name, currentBatch);
             appliedMigrations.push(migration.name);
           } catch (err) {
diff --git a/node_modules/sqlite-up/dist/index.js.map b/node_modules/sqlite-up/dist/index.js.map
index 2fc533a..a2c3fad 100644
--- a/node_modules/sqlite-up/dist/index.js.map
+++ b/node_modules/sqlite-up/dist/index.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/providers/manual-transaction.ts","../src/providers/better-sqlite3.ts","../src/providers/bun-sql.ts","../src/providers/bun-sqlite.ts","../src/providers/node-sqlite.ts","../src/providers/index.ts"],"sourcesContent":["import { EventEmitter } from 'node:events';\nimport { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { MigrationError, MigrationExecutionError, MigrationFileError, MigrationLockError } from './errors.js';\nimport { createSqliteProvider, type SqliteProvider } from './providers/index.js';\nimport type {\n  MaybePromise,\n  Migration,\n  MigrationPlan,\n  MigrationRecord,\n  MigrationResult,\n  MigrationStatus,\n  MigratorOptions,\n  SqliteDatabase,\n} from './types.js';\n\n/**\n * Migration provider for SQLite databases.\n * @example\n * const db = new DatabaseSync('database.db');\n * const migrator = new Migrator({ db, migrationsDir: 'migrations' });\n * await migrator.apply();\n */\nexport class Migrator extends EventEmitter {\n  /**\n   * Driver-specific provider normalized to the sqlite-up database surface.\n   */\n  private provider: SqliteProvider;\n\n  /**\n   * Database handle used by migrations and internal bookkeeping queries.\n   */\n  private db: SqliteDatabase;\n\n  /**\n   * Directory where migration modules are loaded from.\n   */\n  private migrationsDir: string;\n\n  /**\n   * Table that records successfully applied migrations.\n   */\n  private migrationsTable: string;\n\n  /**\n   * Table that stores the single-row migration lock.\n   */\n  private lockTable: string;\n\n  /**\n   * Migration modules loaded from disk in execution order.\n   */\n  private migrations: Migration[] = [];\n\n  /**\n   * Whether internal tables and migration files have already been initialized.\n   */\n  private initialized = false;\n\n  /**\n   * File extensions considered when loading migration modules.\n   */\n  private fileExtensions: string[];\n\n  constructor(options: MigratorOptions) {\n    super();\n\n    this.provider = createSqliteProvider(options.db);\n    this.db = this.provider.db;\n    this.migrationsDir = options.migrationsDir;\n    this.migrationsTable = options.migrationsTable ?? 'schema_migrations';\n    this.lockTable = options.migrationsLockTable ?? 'schema_migrations_lock';\n    this.fileExtensions = options.fileExtensions ?? ['ts', 'js'];\n  }\n\n  /**\n   * Ensures the `schema_migrations` and `schema_migrations_lock` tables exist,\n   * and loads migration files from the migrations directory.\n   */\n  private async init(): Promise<void> {\n    if (this.initialized) {\n      return;\n    }\n\n    await this.initTables();\n    await this.loadMigrationsFromDirectory();\n\n    this.initialized = true;\n  }\n\n  /**\n   * Initializes the `schema_migrations` and `schema_migrations_lock` tables.\n   */\n  private async initTables(): Promise<void> {\n    try {\n      // Create the migrations table if it doesn't exist\n      await this.db.exec(`\n        CREATE TABLE IF NOT EXISTS ${this.migrationsTable} (\n          name TEXT PRIMARY KEY,\n          executed_at TEXT NOT NULL,   -- ISO string\n          batch INTEGER NOT NULL\n        )\n      `);\n\n      // Create the lock table if it doesn't exist\n      await this.db.exec(`\n        CREATE TABLE IF NOT EXISTS ${this.lockTable} (\n          id INTEGER PRIMARY KEY CHECK (id = 1),\n          locked INTEGER NOT NULL DEFAULT 0\n        )\n      `);\n\n      // Ensure exactly one row in the lock table (id=1)\n      await this.db.exec(`\n        INSERT OR IGNORE INTO ${this.lockTable} (id, locked) VALUES (1, 0)\n      `);\n\n      // Load all migration files\n    } catch (err) {\n      throw new MigrationError('Failed to initialize migrator', err as Error);\n    }\n  }\n\n  /**\n   * Load migration files from the `migrationsDir`.\n   * Migration files must export { up, down }.\n   * The migrations are loaded in alphabetical order.\n   */\n  private async loadMigrationsFromDirectory(): Promise<void> {\n    try {\n      const entries = await fs.readdir(this.migrationsDir);\n      // Filter and sort migration files alphabetically\n      const migrationFiles = entries\n        .filter((file) => {\n          // Ignore .d.ts files\n          if (file.endsWith('.d.ts')) {\n            return false;\n          }\n          // Check if file has one of the allowed extensions\n          return this.fileExtensions.some((ext) => file.endsWith(`.${ext}`));\n        })\n        .sort();\n\n      const loadedMigrations: Migration[] = [];\n      for (const file of migrationFiles) {\n        const fullPath = path.join(this.migrationsDir, file);\n\n        let imported: {\n          up: (db: SqliteDatabase) => MaybePromise<void>;\n          down: (db: SqliteDatabase) => MaybePromise<void>;\n        };\n\n        try {\n          // Dynamic import (ESM)\n          imported = await import(fullPath);\n        } catch (err) {\n          throw new MigrationFileError(`Error loading migration \"${file}\": ${String(err)}`, err as Error);\n        }\n\n        const { up, down } = imported;\n        if (typeof up !== 'function' || typeof down !== 'function') {\n          throw new MigrationFileError(`Migration \"${file}\" must export \"up\" and \"down\" functions.`);\n        }\n\n        loadedMigrations.push({ name: file, up, down });\n      }\n\n      // Only update migrations array after all files are loaded successfully\n      this.migrations = loadedMigrations;\n    } catch (err) {\n      throw err instanceof MigrationFileError ? err : new MigrationFileError('Failed to load migrations', err as Error);\n    }\n  }\n\n  /**\n   * Acquire a lock to prevent concurrent migrations.\n   * Throws an error if the lock is already held.\n   */\n  private async acquireLock(): Promise<void> {\n    try {\n      await this.runTransaction(async () => {\n        const row = (await this.db.prepare(`SELECT locked FROM ${this.lockTable} WHERE id = 1`).get()) as {\n          locked: number;\n        };\n\n        if (row.locked === 1) {\n          throw new MigrationLockError('Migration lock already held by another process.');\n        }\n\n        await this.db.prepare(`UPDATE ${this.lockTable} SET locked = 1 WHERE id = 1`).run();\n      });\n    } catch (err) {\n      if (err instanceof MigrationLockError) {\n        throw err;\n      }\n\n      throw new MigrationLockError('Failed to acquire migration lock', err as Error);\n    }\n  }\n\n  /**\n   * Release the migration lock.\n   */\n  private async releaseLock(): Promise<void> {\n    try {\n      await this.db.prepare(`UPDATE ${this.lockTable} SET locked = 0 WHERE id = 1`).run();\n    } catch (err) {\n      throw new MigrationLockError('Failed to release migration lock', err as Error);\n    }\n  }\n\n  /**\n   * Get the highest batch number.\n   */\n  private async getCurrentBatch(): Promise<number> {\n    const row = (await this.db.prepare(`SELECT MAX(batch) as batch FROM ${this.migrationsTable}`).get()) as {\n      batch: number | null;\n    };\n    return row?.batch ?? 0;\n  }\n\n  /**\n   * Insert a record for an applied migration.\n   */\n  private async recordMigration(name: string, batch: number): Promise<void> {\n    const executedAt = new Date().toISOString();\n    await this.db\n      .prepare(\n        `\n        INSERT INTO ${this.migrationsTable} (name, executed_at, batch)\n        VALUES (?, ?, ?)\n      `\n      )\n      .run(name, executedAt, batch);\n  }\n\n  /**\n   * Delete a record for a migration that is being rolled back.\n   */\n  private async removeMigration(name: string, batch: number): Promise<void> {\n    await this.db\n      .prepare(\n        `\n        DELETE FROM ${this.migrationsTable}\n        WHERE name = ? AND batch = ?\n      `\n      )\n      .run(name, batch);\n  }\n\n  /**\n   * Run SQL operations in a transaction.\n   * @param fn The function to run in the transaction.\n   */\n  private async runTransaction(fn: () => MaybePromise<void>): Promise<void> {\n    await this.provider.transaction(fn);\n  }\n\n  /**\n   * Apply all pending migrations in a single batch.\n   * Returns the names of applied migrations.\n   */\n  async apply(): Promise<MigrationResult> {\n    // Initialize the migrator\n    try {\n      await this.init();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    // Acquire lock\n    try {\n      await this.acquireLock();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    const appliedMigrations: string[] = [];\n    try {\n      const currentBatch = await this.getCurrentBatch();\n      const nextBatch = currentBatch + 1;\n\n      // Determine pending migrations: not present in schema_migrations\n      const appliedNames = new Set(\n        (await this.db.prepare(`SELECT name FROM ${this.migrationsTable}`).all()).map(\n          (row) => (row as { name: string }).name\n        )\n      );\n\n      // Get pending migrations, if any\n      const pendingMigrations = this.migrations.filter((m) => !appliedNames.has(m.name));\n      if (pendingMigrations.length === 0) {\n        return { success: true, appliedMigrations };\n      }\n\n      // Perform the migration\n      await this.runTransaction(async () => {\n        for (const migration of pendingMigrations) {\n          try {\n            // Apply migration\n            await migration.up(this.db);\n\n            // Record migration\n            await this.recordMigration(migration.name, nextBatch);\n            appliedMigrations.push(migration.name);\n          } catch (err) {\n            throw new MigrationExecutionError(`Failed to apply migration \"${migration.name}\"`, err as Error);\n          }\n        }\n      });\n\n      for (const migrationName of appliedMigrations) {\n        this.emit('migration:applied', migrationName, nextBatch);\n      }\n\n      return { success: true, appliedMigrations };\n    } catch (error) {\n      const err =\n        error instanceof MigrationExecutionError\n          ? error\n          : new MigrationExecutionError('Migration failed', error as Error);\n      return { success: false, error: err, appliedMigrations: [] };\n    } finally {\n      await this.releaseLock();\n    }\n  }\n\n  /**\n   * Roll back the most recent batch of migrations.\n   * Returns the names of rolled back migrations.\n   */\n  async rollback(): Promise<MigrationResult> {\n    // Initialize the migrator\n    try {\n      await this.init();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    // Acquire lock\n    try {\n      await this.acquireLock();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    const appliedMigrations: string[] = [];\n    try {\n      // Check if there are migrations to rollback\n      const currentBatch = await this.getCurrentBatch();\n      if (currentBatch === 0) {\n        return { success: true, appliedMigrations };\n      }\n\n      // Get migrations in the last batch, sorted descending\n      const rows = (await this.db\n        .prepare(\n          `\n          SELECT name\n          FROM ${this.migrationsTable}\n          WHERE batch = ?\n          ORDER BY name DESC\n        `\n        )\n        .all(currentBatch)) as { name: string }[];\n\n      // No migrations found in the last batch\n      if (rows.length === 0) {\n        return { success: true, appliedMigrations };\n      }\n\n      // Perform the rollback\n      await this.runTransaction(async () => {\n        for (const row of rows) {\n          const migration = this.migrations.find((m) => m.name === row.name);\n          if (!migration) {\n            throw new MigrationFileError(`Migration \"${row.name}\" not found.`);\n          }\n\n          try {\n            // Revert migration\n            await migration.down(this.db);\n\n            // Remove migration record\n            await this.removeMigration(migration.name, currentBatch);\n\n            appliedMigrations.push(migration.name);\n          } catch (err) {\n            throw new MigrationExecutionError(`Failed to rollback migration \"${migration.name}\"`, err as Error);\n          }\n        }\n      });\n\n      for (const migrationName of appliedMigrations) {\n        this.emit('migration:rollback', migrationName, currentBatch);\n      }\n\n      return { success: true, appliedMigrations };\n    } catch (error) {\n      const err =\n        error instanceof MigrationExecutionError\n          ? error\n          : new MigrationExecutionError('Rollback failed', error as Error);\n      return { success: false, error: err, appliedMigrations: [] };\n    } finally {\n      await this.releaseLock();\n    }\n  }\n\n  /**\n   * Get the status of migrations.\n   * Returns:\n   * - currentBatch: the highest batch number applied\n   * - pending: number of migrations not yet applied\n   * - applied: list of all applied migrations\n   */\n  async status(): Promise<MigrationStatus> {\n    await this.init();\n\n    try {\n      const currentBatch = await this.getCurrentBatch();\n\n      // Get all applied migrations\n      const rows = (await this.db\n        .prepare(\n          `\n          SELECT name, executed_at, batch\n          FROM ${this.migrationsTable}\n          ORDER BY batch ASC, name ASC\n        `\n        )\n        .all()) as MigrationRecord[];\n\n      // Determine pending migrations\n      const appliedNames = new Set(rows.map((r) => r.name));\n      const pending = this.migrations.length - appliedNames.size;\n\n      return {\n        currentBatch,\n        pending,\n        applied: rows,\n      };\n    } catch (err) {\n      throw new MigrationError('Failed to get migration status', err as Error);\n    }\n  }\n\n  /**\n   * Plan the pending migrations without applying them.\n   * Returns the next batch number and the list of pending migration names in order.\n   */\n  async plan(): Promise<MigrationPlan> {\n    await this.init();\n\n    try {\n      const currentBatch = await this.getCurrentBatch();\n      const nextBatch = currentBatch + 1;\n\n      // Determine pending migrations: not present in schema_migrations\n      const appliedNames = new Set(\n        (await this.db.prepare(`SELECT name FROM ${this.migrationsTable}`).all()).map(\n          (row) => (row as { name: string }).name\n        )\n      );\n\n      const pendingMigrations = this.migrations.filter((m) => !appliedNames.has(m.name)).map((m) => m.name);\n\n      return {\n        nextBatch,\n        pendingMigrations,\n      };\n    } catch (err) {\n      throw new MigrationError('Failed to create migration plan', err as Error);\n    }\n  }\n}\n\nexport {\n  MigrationError,\n  MigrationExecutionError,\n  MigrationFileError,\n  MigrationLockError,\n} from './errors.js';\nexport type {\n  BunSqliteDatabase,\n  MaybePromise,\n  Migration,\n  MigrationPlan,\n  MigrationRecord,\n  MigrationResult,\n  MigrationStatus,\n  MigratorDatabase,\n  MigratorOptions,\n  SqliteDatabase,\n  SqliteRunResult,\n  SqliteStatement,\n  SqliteTransaction,\n} from './types.js';\n","/**\n * Base error class for all sqlite-up errors\n */\nexport class MigrationError extends Error {\n  constructor(\n    message: string,\n    public readonly cause?: Error\n  ) {\n    super(message);\n    this.name = 'MigrationError';\n  }\n}\n\n/**\n * Thrown when there's an issue with migration files\n */\nexport class MigrationFileError extends MigrationError {\n  constructor(message: string, cause?: Error) {\n    super(message, cause);\n    this.name = 'MigrationFileError';\n  }\n}\n\n/**\n * Thrown when there's a locking issue\n */\nexport class MigrationLockError extends MigrationError {\n  constructor(message: string, cause?: Error) {\n    super(message, cause);\n    this.name = 'MigrationLockError';\n  }\n}\n\n/**\n * Thrown when there's an issue during migration execution\n */\nexport class MigrationExecutionError extends MigrationError {\n  constructor(message: string, cause?: Error) {\n    super(message, cause);\n    this.name = 'MigrationExecutionError';\n  }\n}\n","import type { MaybePromise, SqliteDatabase } from '../types.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Creates a provider that wraps migration work in explicit SQL transactions.\n */\nexport function createManualTransactionProvider(db: SqliteDatabase): SqliteProvider {\n  return {\n    db,\n\n    /**\n     * Runs the callback between BEGIN IMMEDIATE and COMMIT, rolling back on failure.\n     */\n    transaction: async (fn: () => MaybePromise<void>): Promise<void> => {\n      await db.exec('BEGIN IMMEDIATE');\n      try {\n        await fn();\n        await db.exec('COMMIT');\n      } catch (err) {\n        try {\n          await db.exec('ROLLBACK');\n        } catch {\n          // Preserve the original transaction failure.\n        }\n        throw err;\n      }\n    },\n  };\n}\n","import type { SqliteDatabase } from '../types.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Structural database shape used to identify better-sqlite3 connections.\n */\nexport type BetterSqlite3Database = SqliteDatabase & {\n  transaction?: unknown;\n  open?: boolean;\n};\n\n/**\n * Checks whether a value looks like a better-sqlite3 database instance.\n */\nexport function isBetterSqlite3Database(db: unknown): db is BetterSqlite3Database {\n  const candidate = db as Partial<BetterSqlite3Database>;\n  return (\n    typeof candidate.exec === 'function' &&\n    typeof candidate.prepare === 'function' &&\n    typeof candidate.transaction === 'function' &&\n    typeof candidate.open === 'boolean'\n  );\n}\n\n/**\n * Creates a sqlite-up provider for better-sqlite3 database instances.\n */\nexport function createBetterSqlite3Provider(db: BetterSqlite3Database): SqliteProvider {\n  return createManualTransactionProvider(db);\n}\n","import type { BunSqliteDatabase, MaybePromise, SqliteDatabase, SqliteTransaction } from '../types.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * SQLite database facade whose transactions may complete asynchronously.\n */\ninterface AsyncTransactionalSqliteDatabase extends SqliteDatabase {\n  /**\n   * Creates a transaction runner that can await asynchronous transaction work.\n   */\n  transaction<Args extends unknown[], Result>(\n    fn: (...args: Args) => MaybePromise<Result>\n  ): SqliteTransaction<Args, Result>;\n}\n\n/**\n * Executes SQL through Bun SQL and normalizes empty parameter lists.\n */\nasync function executeBunSql(client: BunSqliteDatabase, sql: string, params: unknown[] = []): Promise<unknown[]> {\n  return await client.unsafe(sql, params.length > 0 ? params : undefined);\n}\n\n/**\n * Checks whether a value looks like Bun's Promise-based SQL client for SQLite.\n */\nexport function isBunSqlDatabase(db: unknown): db is BunSqliteDatabase {\n  const candidate = db as Partial<BunSqliteDatabase>;\n  return typeof candidate.unsafe === 'function' && typeof (candidate as Partial<SqliteDatabase>).exec !== 'function';\n}\n\n/**\n * Creates a sqlite-up provider for Bun SQL SQLite clients.\n */\nexport function createBunSqlProvider(rootClient: BunSqliteDatabase): SqliteProvider {\n  let activeClient = rootClient;\n\n  const db: AsyncTransactionalSqliteDatabase = {\n    /**\n     * Executes a SQL statement through the currently active Bun SQL client.\n     */\n    exec: async (sql: string) => {\n      await executeBunSql(activeClient, sql);\n    },\n\n    /**\n     * Creates a prepared-statement facade backed by Bun SQL unsafe execution.\n     */\n    prepare: (sql: string) => ({\n      /**\n       * Runs the statement and returns all rows.\n       */\n      all: (...params: unknown[]) => executeBunSql(activeClient, sql, params),\n\n      /**\n       * Runs the statement and returns the first row.\n       */\n      get: async (...params: unknown[]) => {\n        const rows = await executeBunSql(activeClient, sql, params);\n        return rows[0];\n      },\n\n      /**\n       * Runs the statement for side effects and returns the driver result.\n       */\n      run: (...params: unknown[]) => executeBunSql(activeClient, sql, params),\n    }),\n\n    /**\n     * Creates a transaction runner using Bun SQL native transactions when available.\n     */\n    transaction: <Args extends unknown[], Result>(fn: (...args: Args) => MaybePromise<Result>) => {\n      /**\n       * Executes the transaction callback with the active transaction client.\n       */\n      const run = async (...args: Args): Promise<Result> => {\n        if (typeof rootClient.begin === 'function') {\n          return await rootClient.begin(async (tx) => {\n            const previousClient = activeClient;\n            activeClient = tx;\n\n            try {\n              return await fn(...args);\n            } finally {\n              activeClient = previousClient;\n            }\n          });\n        }\n\n        await db.exec('BEGIN');\n        try {\n          const result = await fn(...args);\n          await db.exec('COMMIT');\n          return result;\n        } catch (err) {\n          try {\n            await db.exec('ROLLBACK');\n          } catch {\n            // Preserve the original transaction failure.\n          }\n          throw err;\n        }\n      };\n\n      return run;\n    },\n  };\n\n  return {\n    db,\n\n    /**\n     * Runs migration work inside the Bun SQL transaction facade.\n     */\n    transaction: async (fn: () => MaybePromise<void>) => {\n      const transaction = db.transaction(fn);\n      await transaction();\n    },\n  };\n}\n","import type { SqliteDatabase, SqliteStatement } from '../types.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Structural database shape used to identify Bun's synchronous SQLite client.\n */\nexport type BunSqliteSyncDatabase = SqliteDatabase & {\n  query?: (sql: string) => SqliteStatement;\n};\n\n/**\n * Checks whether a value looks like a Bun SQLite database instance.\n */\nexport function isBunSqliteDatabase(db: unknown): db is BunSqliteSyncDatabase {\n  const candidate = db as Partial<BunSqliteSyncDatabase>;\n  return (\n    typeof candidate.exec === 'function' &&\n    typeof candidate.prepare === 'function' &&\n    typeof candidate.query === 'function'\n  );\n}\n\n/**\n * Creates a sqlite-up provider for Bun SQLite database instances.\n */\nexport function createBunSqliteProvider(db: BunSqliteSyncDatabase): SqliteProvider {\n  return createManualTransactionProvider(db);\n}\n","import type { SqliteDatabase } from '../types.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Structural database shape used to identify Node's node:sqlite DatabaseSync.\n */\nexport type NodeSqliteDatabase = SqliteDatabase & {\n  isOpen?: boolean;\n};\n\n/**\n * Checks whether a value looks like a node:sqlite database instance.\n */\nexport function isNodeSqliteDatabase(db: unknown): db is NodeSqliteDatabase {\n  const candidate = db as Partial<NodeSqliteDatabase>;\n  return (\n    typeof candidate.exec === 'function' &&\n    typeof candidate.prepare === 'function' &&\n    typeof candidate.isOpen === 'boolean'\n  );\n}\n\n/**\n * Creates a sqlite-up provider for node:sqlite database instances.\n */\nexport function createNodeSqliteProvider(db: NodeSqliteDatabase): SqliteProvider {\n  return createManualTransactionProvider(db);\n}\n","import type { MigratorDatabase, SqliteDatabase } from '../types.js';\nimport { createBetterSqlite3Provider, isBetterSqlite3Database } from './better-sqlite3.js';\nimport { createBunSqlProvider, isBunSqlDatabase } from './bun-sql.js';\nimport { createBunSqliteProvider, isBunSqliteDatabase } from './bun-sqlite.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport { createNodeSqliteProvider, isNodeSqliteDatabase } from './node-sqlite.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Checks for the minimal SQLite database surface sqlite-up can use directly.\n */\nfunction isSqliteDatabase(db: unknown): db is SqliteDatabase {\n  const candidate = db as Partial<SqliteDatabase>;\n  return typeof candidate.exec === 'function' && typeof candidate.prepare === 'function';\n}\n\n/**\n * Creates the best provider adapter for a supported SQLite database client.\n */\nexport function createSqliteProvider(db: MigratorDatabase): SqliteProvider {\n  if (isBunSqlDatabase(db)) {\n    return createBunSqlProvider(db);\n  }\n\n  if (isBunSqliteDatabase(db)) {\n    return createBunSqliteProvider(db);\n  }\n\n  if (isBetterSqlite3Database(db)) {\n    return createBetterSqlite3Provider(db);\n  }\n\n  if (isNodeSqliteDatabase(db)) {\n    return createNodeSqliteProvider(db);\n  }\n\n  if (isSqliteDatabase(db)) {\n    return createManualTransactionProvider(db);\n  }\n\n  if (typeof db === 'object' && db !== null) {\n    return createManualTransactionProvider(db as SqliteDatabase);\n  }\n\n  throw new TypeError('Unsupported SQLite database provider.');\n}\n\nexport { createBetterSqlite3Provider, isBetterSqlite3Database } from './better-sqlite3.js';\nexport { createBunSqlProvider, isBunSqlDatabase } from './bun-sql.js';\nexport { createBunSqliteProvider, isBunSqliteDatabase } from './bun-sqlite.js';\nexport { createNodeSqliteProvider, isNodeSqliteDatabase } from './node-sqlite.js';\nexport type { SqliteProvider } from './types.js';\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;;;ACCV,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACE,SACgB,OAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACrD,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACrD,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,0BAAN,cAAsC,eAAe;AAAA,EAC1D,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;;;ACnCO,SAAS,gCAAgC,IAAoC;AAClF,SAAO;AAAA,IACL;AAAA;AAAA;AAAA;AAAA,IAKA,aAAa,OAAO,OAAgD;AAClE,YAAM,GAAG,KAAK,iBAAiB;AAC/B,UAAI;AACF,cAAM,GAAG;AACT,cAAM,GAAG,KAAK,QAAQ;AAAA,MACxB,SAAS,KAAK;AACZ,YAAI;AACF,gBAAM,GAAG,KAAK,UAAU;AAAA,QAC1B,QAAQ;AAAA,QAER;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;;;ACbO,SAAS,wBAAwB,I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AC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAEpG,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,YAAM,IAAI,eAAe,mCAAmC,GAAY;AAAA,IAC1E;AAAA,EACF;AACF;","names":[]}
\ No newline at end of file
+{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/providers/manual-transaction.ts","../src/providers/better-sqlite3.ts","../src/providers/bun-sql.ts","../src/providers/bun-sqlite.ts","../src/providers/node-sqlite.ts","../src/providers/index.ts"],"sourcesContent":["import { EventEmitter } from 'node:events';\nimport { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { MigrationError, MigrationExecutionError, MigrationFileError, MigrationLockError } from './errors.js';\nimport { createSqliteProvider, type SqliteProvider } from './providers/index.js';\nimport type {\n  MaybePromise,\n  NamedMigration,\n  MigrationPlan,\n  MigrationRecord,\n  MigrationResult,\n  MigrationStatus,\n  MigratorOptions,\n  SqliteDatabase,\n  OptionalArg,\n} from './types.js';\n\n/**\n * Migration provider for SQLite databases.\n * @example\n * const db = new DatabaseSync('database.db');\n * const migrator = new Migrator({ db, migrationsDir: 'migrations' });\n * await migrator.apply();\n */\nexport class Migrator<T = undefined> extends EventEmitter {\n  /**\n   * Driver-specific provider normalized to the sqlite-up database surface.\n   */\n  private provider: SqliteProvider;\n\n  /**\n   * Database handle used by migrations and internal bookkeeping queries.\n   */\n  private db: SqliteDatabase;\n\n  /**\n   * Directory where migration modules are loaded from.\n   */\n  private migrationsDir: string;\n\n  /**\n   * Table that records successfully applied migrations.\n   */\n  private migrationsTable: string;\n\n  /**\n   * Table that stores the single-row migration lock.\n   */\n  private lockTable: string;\n\n  /**\n   * Migration modules loaded from disk in execution order.\n   */\n  private migrations: NamedMigration<T>[] = [];\n\n  /**\n   * Whether internal tables and migration files have already been initialized.\n   */\n  private initialized = false;\n\n  /**\n   * File extensions considered when loading migration modules.\n   */\n  private fileExtensions: string[];\n\n  constructor(options: MigratorOptions) {\n    super();\n\n    this.provider = createSqliteProvider(options.db);\n    this.db = this.provider.db;\n    this.migrationsDir = options.migrationsDir;\n    this.migrationsTable = options.migrationsTable ?? 'schema_migrations';\n    this.lockTable = options.migrationsLockTable ?? 'schema_migrations_lock';\n    this.fileExtensions = options.fileExtensions ?? ['ts', 'js'];\n  }\n\n  /**\n   * Ensures the `schema_migrations` and `schema_migrations_lock` tables exist,\n   * and loads migration files from the migrations directory.\n   */\n  private async init(): Promise<void> {\n    if (this.initialized) {\n      return;\n    }\n\n    await this.initTables();\n    await this.loadMigrationsFromDirectory();\n\n    this.initialized = true;\n  }\n\n  /**\n   * Initializes the `schema_migrations` and `schema_migrations_lock` tables.\n   */\n  private async initTables(): Promise<void> {\n    try {\n      // Create the migrations table if it doesn't exist\n      await this.db.exec(`\n        CREATE TABLE IF NOT EXISTS ${this.migrationsTable} (\n          name TEXT PRIMARY KEY,\n          executed_at TEXT NOT NULL,   -- ISO string\n          batch INTEGER NOT NULL\n        )\n      `);\n\n      // Create the lock table if it doesn't exist\n      await this.db.exec(`\n        CREATE TABLE IF NOT EXISTS ${this.lockTable} (\n          id INTEGER PRIMARY KEY CHECK (id = 1),\n          locked INTEGER NOT NULL DEFAULT 0\n        )\n      `);\n\n      // Ensure exactly one row in the lock table (id=1)\n      await this.db.exec(`\n        INSERT OR IGNORE INTO ${this.lockTable} (id, locked) VALUES (1, 0)\n      `);\n\n      // Load all migration files\n    } catch (err) {\n      throw new MigrationError('Failed to initialize migrator', err as Error);\n    }\n  }\n\n  /**\n   * Load migration files from the `migrationsDir`.\n   * Migration files must export { up, down }.\n   * The migrations are loaded in alphabetical order.\n   */\n  private async loadMigrationsFromDirectory(): Promise<void> {\n    try {\n      const entries = await fs.readdir(this.migrationsDir);\n      // Filter and sort migration files alphabetically\n      const migrationFiles = entries\n        .filter((file) => {\n          // Ignore .d.ts files\n          if (file.endsWith('.d.ts')) {\n            return false;\n          }\n          // Check if file has one of the allowed extensions\n          return this.fileExtensions.some((ext) => file.endsWith(`.${ext}`));\n        })\n        .sort();\n\n      const loadedMigrations: NamedMigration<T>[] = [];\n      for (const file of migrationFiles) {\n        const fullPath = path.join(this.migrationsDir, file);\n\n        let imported: {\n          up: (db: SqliteDatabase) => MaybePromise<void>;\n          down: (db: SqliteDatabase) => MaybePromise<void>;\n        };\n\n        try {\n          // Dynamic import (ESM)\n          imported = await import(fullPath);\n        } catch (err) {\n          throw new MigrationFileError(`Error loading migration \"${file}\": ${String(err)}`, err as Error);\n        }\n\n        const { up, down } = imported;\n        if (typeof up !== 'function' || typeof down !== 'function') {\n          throw new MigrationFileError(`Migration \"${file}\" must export \"up\" and \"down\" functions.`);\n        }\n\n        loadedMigrations.push({ name: file, up, down });\n      }\n\n      // Only update migrations array after all files are loaded successfully\n      this.migrations = loadedMigrations;\n    } catch (err) {\n      throw err instanceof MigrationFileError ? err : new MigrationFileError('Failed to load migrations', err as Error);\n    }\n  }\n\n  /**\n   * Acquire a lock to prevent concurrent migrations.\n   * Throws an error if the lock is already held.\n   */\n  private async acquireLock(): Promise<void> {\n    try {\n      await this.runTransaction(async () => {\n        const row = (await this.db.prepare(`SELECT locked FROM ${this.lockTable} WHERE id = 1`).get()) as {\n          locked: number;\n        };\n\n        if (row.locked === 1) {\n          throw new MigrationLockError('Migration lock already held by another process.');\n        }\n\n        await this.db.prepare(`UPDATE ${this.lockTable} SET locked = 1 WHERE id = 1`).run();\n      });\n    } catch (err) {\n      if (err instanceof MigrationLockError) {\n        throw err;\n      }\n\n      throw new MigrationLockError('Failed to acquire migration lock', err as Error);\n    }\n  }\n\n  /**\n   * Release the migration lock.\n   */\n  private async releaseLock(): Promise<void> {\n    try {\n      await this.db.prepare(`UPDATE ${this.lockTable} SET locked = 0 WHERE id = 1`).run();\n    } catch (err) {\n      throw new MigrationLockError('Failed to release migration lock', err as Error);\n    }\n  }\n\n  /**\n   * Get the highest batch number.\n   */\n  private async getCurrentBatch(): Promise<number> {\n    const row = (await this.db.prepare(`SELECT MAX(batch) as batch FROM ${this.migrationsTable}`).get()) as {\n      batch: number | null;\n    };\n    return row?.batch ?? 0;\n  }\n\n  /**\n   * Insert a record for an applied migration.\n   */\n  private async recordMigration(name: string, batch: number): Promise<void> {\n    const executedAt = new Date().toISOString();\n    await this.db\n      .prepare(\n        `\n        INSERT INTO ${this.migrationsTable} (name, executed_at, batch)\n        VALUES (?, ?, ?)\n      `\n      )\n      .run(name, executedAt, batch);\n  }\n\n  /**\n   * Delete a record for a migration that is being rolled back.\n   */\n  private async removeMigration(name: string, batch: number): Promise<void> {\n    await this.db\n      .prepare(\n        `\n        DELETE FROM ${this.migrationsTable}\n        WHERE name = ? AND batch = ?\n      `\n      )\n      .run(name, batch);\n  }\n\n  /**\n   * Run SQL operations in a transaction.\n   * @param fn The function to run in the transaction.\n   */\n  private async runTransaction(fn: () => MaybePromise<void>): Promise<void> {\n    await this.provider.transaction(fn);\n  }\n\n  /**\n   * Apply all pending migrations in a single batch.\n   * Returns the names of applied migrations.\n   */\n  async apply(...args: OptionalArg<T>): Promise<MigrationResult> {\n    // Initialize the migrator\n    try {\n      await this.init();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    // Acquire lock\n    try {\n      await this.acquireLock();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    const appliedMigrations: string[] = [];\n    try {\n      const currentBatch = await this.getCurrentBatch();\n      const nextBatch = currentBatch + 1;\n\n      // Determine pending migrations: not present in schema_migrations\n      const appliedNames = new Set(\n        (await this.db.prepare(`SELECT name FROM ${this.migrationsTable}`).all()).map(\n          (row) => (row as { name: string }).name\n        )\n      );\n\n      // Get pending migrations, if any\n      const pendingMigrations = this.migrations.filter((m) => !appliedNames.has(m.name));\n      if (pendingMigrations.length === 0) {\n        return { success: true, appliedMigrations };\n      }\n\n      // Perform the migration\n      await this.runTransaction(async () => {\n        for (const migration of pendingMigrations) {\n          try {\n            // Apply migration\n            await migration.up(this.db, args[0]);\n\n            // Record migration\n            await this.recordMigration(migration.name, nextBatch);\n            appliedMigrations.push(migration.name);\n          } catch (err) {\n            throw new MigrationExecutionError(`Failed to apply migration \"${migration.name}\"`, err as Error);\n          }\n        }\n      });\n\n      for (const migrationName of appliedMigrations) {\n        this.emit('migration:applied', migrationName, nextBatch);\n      }\n\n      return { success: true, appliedMigrations };\n    } catch (error) {\n      const err =\n        error instanceof MigrationExecutionError\n          ? error\n          : new MigrationExecutionError('Migration failed', error as Error);\n      return { success: false, error: err, appliedMigrations: [] };\n    } finally {\n      await this.releaseLock();\n    }\n  }\n\n  /**\n   * Roll back the most recent batch of migrations.\n   * Returns the names of rolled back migrations.\n   */\n  async rollback(...args: OptionalArg<T>): Promise<MigrationResult> {\n    // Initialize the migrator\n    try {\n      await this.init();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    // Acquire lock\n    try {\n      await this.acquireLock();\n    } catch (err) {\n      return {\n        success: false,\n        error: err as Error,\n        appliedMigrations: [],\n      };\n    }\n\n    const appliedMigrations: string[] = [];\n    try {\n      // Check if there are migrations to rollback\n      const currentBatch = await this.getCurrentBatch();\n      if (currentBatch === 0) {\n        return { success: true, appliedMigrations };\n      }\n\n      // Get migrations in the last batch, sorted descending\n      const rows = (await this.db\n        .prepare(\n          `\n          SELECT name\n          FROM ${this.migrationsTable}\n          WHERE batch = ?\n          ORDER BY name DESC\n        `\n        )\n        .all(currentBatch)) as { name: string }[];\n\n      // No migrations found in the last batch\n      if (rows.length === 0) {\n        return { success: true, appliedMigrations };\n      }\n\n      // Perform the rollback\n      await this.runTransaction(async () => {\n        for (const row of rows) {\n          const migration = this.migrations.find((m) => m.name === row.name);\n          if (!migration) {\n            throw new MigrationFileError(`Migration \"${row.name}\" not found.`);\n          }\n\n          try {\n            // Revert migration\n            await migration.down(this.db, args[0]);\n\n            // Remove migration record\n            await this.removeMigration(migration.name, currentBatch);\n\n            appliedMigrations.push(migration.name);\n          } catch (err) {\n            throw new MigrationExecutionError(`Failed to rollback migration \"${migration.name}\"`, err as Error);\n          }\n        }\n      });\n\n      for (const migrationName of appliedMigrations) {\n        this.emit('migration:rollback', migrationName, currentBatch);\n      }\n\n      return { success: true, appliedMigrations };\n    } catch (error) {\n      const err =\n        error instanceof MigrationExecutionError\n          ? error\n          : new MigrationExecutionError('Rollback failed', error as Error);\n      return { success: false, error: err, appliedMigrations: [] };\n    } finally {\n      await this.releaseLock();\n    }\n  }\n\n  /**\n   * Get the status of migrations.\n   * Returns:\n   * - currentBatch: the highest batch number applied\n   * - pending: number of migrations not yet applied\n   * - applied: list of all applied migrations\n   */\n  async status(): Promise<MigrationStatus> {\n    await this.init();\n\n    try {\n      const currentBatch = await this.getCurrentBatch();\n\n      // Get all applied migrations\n      const rows = (await this.db\n        .prepare(\n          `\n          SELECT name, executed_at, batch\n          FROM ${this.migrationsTable}\n          ORDER BY batch ASC, name ASC\n        `\n        )\n        .all()) as MigrationRecord[];\n\n      // Determine pending migrations\n      const appliedNames = new Set(rows.map((r) => r.name));\n      const pending = this.migrations.length - appliedNames.size;\n\n      return {\n        currentBatch,\n        pending,\n        applied: rows,\n      };\n    } catch (err) {\n      throw new MigrationError('Failed to get migration status', err as Error);\n    }\n  }\n\n  /**\n   * Plan the pending migrations without applying them.\n   * Returns the next batch number and the list of pending migration names in order.\n   */\n  async plan(): Promise<MigrationPlan> {\n    await this.init();\n\n    try {\n      const currentBatch = await this.getCurrentBatch();\n      const nextBatch = currentBatch + 1;\n\n      // Determine pending migrations: not present in schema_migrations\n      const appliedNames = new Set(\n        (await this.db.prepare(`SELECT name FROM ${this.migrationsTable}`).all()).map(\n          (row) => (row as { name: string }).name\n        )\n      );\n\n      const pendingMigrations = this.migrations.filter((m) => !appliedNames.has(m.name)).map((m) => m.name);\n\n      return {\n        nextBatch,\n        pendingMigrations,\n      };\n    } catch (err) {\n      throw new MigrationError('Failed to create migration plan', err as Error);\n    }\n  }\n}\n\nexport {\n  MigrationError,\n  MigrationExecutionError,\n  MigrationFileError,\n  MigrationLockError,\n} from './errors.js';\nexport type {\n  BunSqliteDatabase,\n  MaybePromise,\n  Migration,\n  MigrationPlan,\n  MigrationRecord,\n  MigrationResult,\n  MigrationStatus,\n  MigratorDatabase,\n  MigratorOptions,\n  SqliteDatabase,\n  SqliteRunResult,\n  SqliteStatement,\n  SqliteTransaction,\n} from './types.js';\n","/**\n * Base error class for all sqlite-up errors\n */\nexport class MigrationError extends Error {\n  constructor(\n    message: string,\n    public readonly cause?: Error\n  ) {\n    super(message);\n    this.name = 'MigrationError';\n  }\n}\n\n/**\n * Thrown when there's an issue with migration files\n */\nexport class MigrationFileError extends MigrationError {\n  constructor(message: string, cause?: Error) {\n    super(message, cause);\n    this.name = 'MigrationFileError';\n  }\n}\n\n/**\n * Thrown when there's a locking issue\n */\nexport class MigrationLockError extends MigrationError {\n  constructor(message: string, cause?: Error) {\n    super(message, cause);\n    this.name = 'MigrationLockError';\n  }\n}\n\n/**\n * Thrown when there's an issue during migration execution\n */\nexport class MigrationExecutionError extends MigrationError {\n  constructor(message: string, cause?: Error) {\n    super(message, cause);\n    this.name = 'MigrationExecutionError';\n  }\n}\n","import type { MaybePromise, SqliteDatabase } from '../types.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Creates a provider that wraps migration work in explicit SQL transactions.\n */\nexport function createManualTransactionProvider(db: SqliteDatabase): SqliteProvider {\n  return {\n    db,\n\n    /**\n     * Runs the callback between BEGIN IMMEDIATE and COMMIT, rolling back on failure.\n     */\n    transaction: async (fn: () => MaybePromise<void>): Promise<void> => {\n      await db.exec('BEGIN IMMEDIATE');\n      try {\n        await fn();\n        await db.exec('COMMIT');\n      } catch (err) {\n        try {\n          await db.exec('ROLLBACK');\n        } catch {\n          // Preserve the original transaction failure.\n        }\n        throw err;\n      }\n    },\n  };\n}\n","import type { SqliteDatabase } from '../types.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Structural database shape used to identify better-sqlite3 connections.\n */\nexport type BetterSqlite3Database = SqliteDatabase & {\n  transaction?: unknown;\n  open?: boolean;\n};\n\n/**\n * Checks whether a value looks like a better-sqlite3 database instance.\n */\nexport function isBetterSqlite3Database(db: unknown): db is BetterSqlite3Database {\n  const candidate = db as Partial<BetterSqlite3Database>;\n  return (\n    typeof candidate.exec === 'function' &&\n    typeof candidate.prepare === 'function' &&\n    typeof candidate.transaction === 'function' &&\n    typeof candidate.open === 'boolean'\n  );\n}\n\n/**\n * Creates a sqlite-up provider for better-sqlite3 database instances.\n */\nexport function createBetterSqlite3Provider(db: BetterSqlite3Database): SqliteProvider {\n  return createManualTransactionProvider(db);\n}\n","import type { BunSqliteDatabase, MaybePromise, SqliteDatabase, SqliteTransaction } from '../types.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * SQLite database facade whose transactions may complete asynchronously.\n */\ninterface AsyncTransactionalSqliteDatabase extends SqliteDatabase {\n  /**\n   * Creates a transaction runner that can await asynchronous transaction work.\n   */\n  transaction<Args extends unknown[], Result>(\n    fn: (...args: Args) => MaybePromise<Result>\n  ): SqliteTransaction<Args, Result>;\n}\n\n/**\n * Executes SQL through Bun SQL and normalizes empty parameter lists.\n */\nasync function executeBunSql(client: BunSqliteDatabase, sql: string, params: unknown[] = []): Promise<unknown[]> {\n  return await client.unsafe(sql, params.length > 0 ? params : undefined);\n}\n\n/**\n * Checks whether a value looks like Bun's Promise-based SQL client for SQLite.\n */\nexport function isBunSqlDatabase(db: unknown): db is BunSqliteDatabase {\n  const candidate = db as Partial<BunSqliteDatabase>;\n  return typeof candidate.unsafe === 'function' && typeof (candidate as Partial<SqliteDatabase>).exec !== 'function';\n}\n\n/**\n * Creates a sqlite-up provider for Bun SQL SQLite clients.\n */\nexport function createBunSqlProvider(rootClient: BunSqliteDatabase): SqliteProvider {\n  let activeClient = rootClient;\n\n  const db: AsyncTransactionalSqliteDatabase = {\n    /**\n     * Executes a SQL statement through the currently active Bun SQL client.\n     */\n    exec: async (sql: string) => {\n      await executeBunSql(activeClient, sql);\n    },\n\n    /**\n     * Creates a prepared-statement facade backed by Bun SQL unsafe execution.\n     */\n    prepare: (sql: string) => ({\n      /**\n       * Runs the statement and returns all rows.\n       */\n      all: (...params: unknown[]) => executeBunSql(activeClient, sql, params),\n\n      /**\n       * Runs the statement and returns the first row.\n       */\n      get: async (...params: unknown[]) => {\n        const rows = await executeBunSql(activeClient, sql, params);\n        return rows[0];\n      },\n\n      /**\n       * Runs the statement for side effects and returns the driver result.\n       */\n      run: (...params: unknown[]) => executeBunSql(activeClient, sql, params),\n    }),\n\n    /**\n     * Creates a transaction runner using Bun SQL native transactions when available.\n     */\n    transaction: <Args extends unknown[], Result>(fn: (...args: Args) => MaybePromise<Result>) => {\n      /**\n       * Executes the transaction callback with the active transaction client.\n       */\n      const run = async (...args: Args): Promise<Result> => {\n        if (typeof rootClient.begin === 'function') {\n          return await rootClient.begin(async (tx) => {\n            const previousClient = activeClient;\n            activeClient = tx;\n\n            try {\n              return await fn(...args);\n            } finally {\n              activeClient = previousClient;\n            }\n          });\n        }\n\n        await db.exec('BEGIN');\n        try {\n          const result = await fn(...args);\n          await db.exec('COMMIT');\n          return result;\n        } catch (err) {\n          try {\n            await db.exec('ROLLBACK');\n          } catch {\n            // Preserve the original transaction failure.\n          }\n          throw err;\n        }\n      };\n\n      return run;\n    },\n  };\n\n  return {\n    db,\n\n    /**\n     * Runs migration work inside the Bun SQL transaction facade.\n     */\n    transaction: async (fn: () => MaybePromise<void>) => {\n      const transaction = db.transaction(fn);\n      await transaction();\n    },\n  };\n}\n","import type { SqliteDatabase, SqliteStatement } from '../types.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Structural database shape used to identify Bun's synchronous SQLite client.\n */\nexport type BunSqliteSyncDatabase = SqliteDatabase & {\n  query?: (sql: string) => SqliteStatement;\n};\n\n/**\n * Checks whether a value looks like a Bun SQLite database instance.\n */\nexport function isBunSqliteDatabase(db: unknown): db is BunSqliteSyncDatabase {\n  const candidate = db as Partial<BunSqliteSyncDatabase>;\n  return (\n    typeof candidate.exec === 'function' &&\n    typeof candidate.prepare === 'function' &&\n    typeof candidate.query === 'function'\n  );\n}\n\n/**\n * Creates a sqlite-up provider for Bun SQLite database instances.\n */\nexport function createBunSqliteProvider(db: BunSqliteSyncDatabase): SqliteProvider {\n  return createManualTransactionProvider(db);\n}\n","import type { SqliteDatabase } from '../types.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Structural database shape used to identify Node's node:sqlite DatabaseSync.\n */\nexport type NodeSqliteDatabase = SqliteDatabase & {\n  isOpen?: boolean;\n};\n\n/**\n * Checks whether a value looks like a node:sqlite database instance.\n */\nexport function isNodeSqliteDatabase(db: unknown): db is NodeSqliteDatabase {\n  const candidate = db as Partial<NodeSqliteDatabase>;\n  return (\n    typeof candidate.exec === 'function' &&\n    typeof candidate.prepare === 'function' &&\n    typeof candidate.isOpen === 'boolean'\n  );\n}\n\n/**\n * Creates a sqlite-up provider for node:sqlite database instances.\n */\nexport function createNodeSqliteProvider(db: NodeSqliteDatabase): SqliteProvider {\n  return createManualTransactionProvider(db);\n}\n","import type { MigratorDatabase, SqliteDatabase } from '../types.js';\nimport { createBetterSqlite3Provider, isBetterSqlite3Database } from './better-sqlite3.js';\nimport { createBunSqlProvider, isBunSqlDatabase } from './bun-sql.js';\nimport { createBunSqliteProvider, isBunSqliteDatabase } from './bun-sqlite.js';\nimport { createManualTransactionProvider } from './manual-transaction.js';\nimport { createNodeSqliteProvider, isNodeSqliteDatabase } from './node-sqlite.js';\nimport type { SqliteProvider } from './types.js';\n\n/**\n * Checks for the minimal SQLite database surface sqlite-up can use directly.\n */\nfunction isSqliteDatabase(db: unknown): db is SqliteDatabase {\n  const candidate = db as Partial<SqliteDatabase>;\n  return typeof candidate.exec === 'function' && typeof candidate.prepare === 'function';\n}\n\n/**\n * Creates the best provider adapter for a supported SQLite database client.\n */\nexport function createSqliteProvider(db: MigratorDatabase): SqliteProvider {\n  if (isBunSqlDatabase(db)) {\n    return createBunSqlProvider(db);\n  }\n\n  if (isBunSqliteDatabase(db)) {\n    return createBunSqliteProvider(db);\n  }\n\n  if (isBetterSqlite3Database(db)) {\n    return createBetterSqlite3Provider(db);\n  }\n\n  if (isNodeSqliteDatabase(db)) {\n    return createNodeSqliteProvider(db);\n  }\n\n  if (isSqliteDatabase(db)) {\n    return createManualTransactionProvider(db);\n  }\n\n  if (typeof db === 'object' && db !== null) {\n    return createManualTransactionProvider(db as SqliteDatabase);\n  }\n\n  throw new TypeError('Unsupported SQLite database provider.');\n}\n\nexport { createBetterSqlite3Provider, isBetterSqlite3Database } from './better-sqlite3.js';\nexport { createBunSqlProvider, isBunSqlDatabase } from './bun-sql.js';\nexport { createBunSqliteProvider, isBunSqliteDatabase } from './bun-sqlite.js';\nexport { createNodeSqliteProvider, isNodeSqliteDatabase } from './node-sqlite.js';\nexport type { SqliteProvider } from './types.js';\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;;;ACCV,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACE,SACgB,OAChB;AACA,UAAM,OAAO;AAFG;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACrD,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,qBAAN,cAAiC,eAAe;AAAA,EACrD,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,0BAAN,cAAsC,eAAe;AAAA,EAC1D,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EAC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,GAAY;AAAA,IACzE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAA+B;AACnC,UAAM,KAAK,KAAK;AAEhB,QAAI;AACF,YAAM,eAAe,MAAM,KAAK,gBAAgB;AAChD,YAAM,YAAY,eAAe;AAGjC,YAAM,eAAe,IAAI;AAAA,SACtB,MAAM,KAAK,GAAG,QAAQ,oBAAoB,KAAK,eAAe,EAAE,EAAE,IAAI,GAAG;AAAA,UACxE,CAAC,QAAS,IAAyB;AAAA,QACrC;AAAA,MACF;AAEA,YAAM,oBAAoB,KAAK,WAAW,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAEpG,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,YAAM,IAAI,eAAe,mCAAmC,GAAY;AAAA,IAC1E;AAAA,EACF;AACF;","names":[]}
\ No newline at end of file
diff --git a/node_modules/sqlite-up/dist/types.d.ts b/node_modules/sqlite-up/dist/types.d.ts
index 01a13fd..266e225 100644
--- a/node_modules/sqlite-up/dist/types.d.ts
+++ b/node_modules/sqlite-up/dist/types.d.ts
@@ -2,6 +2,10 @@
  * A value or a promise for that value.
  */
 export type MaybePromise<T> = T | Promise<T>;
+/**
+ *  Argument defaults to undefined but is required if T is not undefined
+ */
+export type OptionalArg<T> = T extends undefined ? [] : [value: T];
 /**
  * Result returned by SQLite statement execution.
  */
@@ -115,19 +119,24 @@ export interface MigratorOptions {
 /**
  * Represents a single migration file/module.
  */
-export interface Migration {
-    /**
-     * Name of the migration (derived from filename)
-     */
-    name: string;
+export interface Migration<T = any> {
     /**
      * Function to apply the migration
      */
-    up: (db: SqliteDatabase) => MaybePromise<void>;
+    up: (db: SqliteDatabase, ctx?: T) => MaybePromise<void>;
     /**
      * Function to revert the migration
      */
-    down: (db: SqliteDatabase) => MaybePromise<void>;
+    down: (db: SqliteDatabase, ctx?: T) => MaybePromise<void>;
+}
+/**
+ * Represents a single migration file/module after being loaded
+ */
+export interface NamedMigration<T = any> extends Migration<T> {
+    /**
+     * Name of the migration (derived from filename)
+     */
+    name: string;
 }
 /**
  * A record of applied migrations as stored in the database.
diff --git a/node_modules/sqlite-up/dist/types.d.ts.map b/node_modules/sqlite-up/dist/types.d.ts.map
index 3935948..b313640 100644
--- a/node_modules/sqlite-up/dist/types.d.ts.map
+++ b/node_modules/sqlite-up/dist/types.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;IAEnD;;OAEG;IACH,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAEjD;;OAEG;IACH,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,eAAe,GAAG,OAAO,CAAC,CAAC;CACpE;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,MAAM,GAAG,OAAO;IACrF,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG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