oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.95k stars 94 forks source link

Setting search path does not work #335

Open konradschewe opened 1 year ago

konradschewe commented 1 year ago

Describe the bug

I am trying to set the search path on a specific schema and then run migrations, but they are still created on public schema instead of the specified one. I am using TypeOrm data source to make queries and run migrations. Does anyone know a valid workaround?

const db = newDb({
    autoCreateForeignKeyIndices: true,
});

const dataSource = await db.adapters.createTypeormDataSource({
    ...options,
    schema: 'my_schema',
    migrations: MY_SCHEMA_MIGRATIONS
}).initialize();

await dataSource.query('SET SEARCH_PATH = my_schema')

await dataSource.runMigrations();

pg-mem version

2.6.12