fix(): Proper schema usage when running migrations (#14036)

* fix(): Proper schema usage when running migrations

* Create thick-pugs-dance.md
This commit is contained in:
Adrien de Peretti
2025-11-12 15:56:50 +01:00
committed by GitHub
parent da4c0110ba
commit e59cdae336
3 changed files with 57 additions and 13 deletions

View File

@@ -32,7 +32,25 @@ export class CustomDBMigrator extends BaseMigrator {
const MigrationClass = Object.values(
migration
)[0] as Constructor<Migration>
const instance = new MigrationClass($this.driver, $this.config)
const instance = new MigrationClass(
$this.driver,
$this.config
) as Migration
const customSchema = $this.config.options.schema
if (customSchema) {
const up = instance.up
const down = instance.down
instance.up = async function (...args) {
this.driver.execute(`SET LOCAL search_path TO ${customSchema}`)
return up.bind(this)(...args)
}
instance.down = async function (...args) {
this.driver.execute(`SET LOCAL search_path TO ${customSchema}`)
return down.bind(this)(...args)
}
}
await $this.runner.run(instance, method)
}