-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
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
- Rust: 1.90
- Diesel:
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 runor any other method (eg. programmatically is expected to perform similarly to CLI)
Checklist
- I have already looked over the issue tracker and the discussion forum for similar possible closed issues.
- This issue can be reproduced on Rust's stable channel. (Your issue will be
closed if this is not the case) - This issue can be reproduced without requiring a third party crate