-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi schema postgres migrations lock conflict #118
Comments
The pg advisory log is designed to protect against multiple instances of migrate running against the same postgres RDBMS. The schema name isn't used to generate the lock id, but that could be changed. How are you managing schema creation? |
We use
|
In order to accommodate running multiple concurrent migrations with different schemas, we'll need an additional DB query during the locking phase to get the current schema. I don't think the approach where the schema name is fetched from the config works since we still need to get the current schema to check it's the same as the configured schema name. Implementation note: Feel free to open a PR with such a change (and don't forget to add tests). |
Describe the Bug
We use schema separated multi tenant system (one database and schema per client). On client registration we create schema and run migration on it (using search_path). On concurrent registration of two or more clients migration process failed with error
can't acquire lock
.Steps to Reproduce
Expected Behavior
Make LockID from database and schema names both.
Migrate Version
e.g. v4.0.2
Loaded Source Drivers
file
Loaded Database Drivers
postgres
Go Version
go1.11 linux/amd64
Additional context
For now we just copy postgres subpackage and add
SchemaName
to config (SELECT CURRENT_SCHEMA()
) and concatDatabaseName
withSchameName
with separator.The text was updated successfully, but these errors were encountered: