Setup
Any migration script similar to the following
up.sql
SET search_path='foo';
--alternatively you could use:
--SELECT pg_catalog.set_config('search_path', '', false);
Versions
diesel = { version = "2.2.0", features = ["postgres"] }
diesel_migrations = { version = "2.2.0", features = ["postgres"] }
- Database: postgres
- Operating System linux
Feature Flags
- diesel:
postgres
- diesel_migrations:
postgres
Problem Description
diesel_migrations fails when search_path is set in migration script
What are you trying to accomplish?
Perform a migration where the search_path is set
This allows using shortened names for things like types
What is the expected output?
$ diesel migration run
Running migration 2025-08-27-111711_initial
$
What is the actual output?
$ diesel migration run
Running migration 2025-08-27-111711_initial
2025-08-27T18:52:00.647148Z ERROR diesel::database: Failed to execute query query=Query { sql: "INSERT INTO \"__diesel_schema_migrations\" (\"version\") VALUES ($1)", binds: [] } err=DatabaseError(Unknown, "relation \"__diesel_schema_migrations\" does not exist")
Failed to run migrations: relation "__diesel_schema_migrations" does not exist
$
Are you seeing any additional errors?
n/a
Steps to reproduce
- create a migration script containing
SET search_path='foo' or similar
- run migration script with
diesel migration run or any other method (eg. programmatically is expected to perform similarly to CLI)
Checklist
Setup
Any migration script similar to the following
up.sql
Versions
Feature Flags
postgrespostgresProblem Description
diesel_migrations fails when search_path is set in migration script
What are you trying to accomplish?
Perform a migration where the search_path is set
This allows using shortened names for things like types
What is the expected output?
What is the actual output?
Are you seeing any additional errors?
n/a
Steps to reproduce
SET search_path='foo'or similardiesel migration runor any other method (eg. programmatically is expected to perform similarly to CLI)Checklist
closed if this is not the case)