Open
Description
I am using schemas to parallelize integration tests (one schema per test worker).
Before each test I want to run the following setup:
- Create a new schema
- Set the
search_path
to be the schema - Run my migrations
Unfortunately right now postgres-migrations
only allows migrations to be once per database (NOT per schema). It looks like this is because in migrate.ts
the check for the migrations table doesn't account for the idea that more than one schema can exist (and that migrations
existing in one doesn't mean migrations
exists in the current search_path).
async function doesTableExist(client: BasicPgClient, tableName: string) {
const result = await client.query(SQL`SELECT EXISTS (
SELECT 1
FROM pg_catalog.pg_class c
WHERE c.relname = ${tableName}
AND c.relkind = 'r'
);`)
As an example, if I manually create a migrations
table in two different schemas this query would return more than one row:
I hope this makes sense! It would be wonderful if this tool could support the parallel-test-schema use case.
Metadata
Metadata
Assignees
Labels
No labels