Skip to content
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

customizable db locking during migration #2063

Merged
merged 4 commits into from
Sep 6, 2022

Conversation

fuzzbuck
Copy link
Contributor

@fuzzbuck fuzzbuck commented Aug 20, 2022

? - Why
Various pgwire databases such as CockroachDB do not support such a feature.

[iodb] running migrations failed: Execute(Database(PgDatabaseError { severity: Error, code: "42883", message: "unknown function: pg_advisory_lock()", detail: None, hint: None, position: None, where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("name_resolution.go"), line: Some(205), routine: Some("ResolveFunction") }))

In such scenarios the only way to perform migrations is without locking

This PR allows the end user to choose whether to lock the DB when running migrations or not.
Default behaviour is maintained and DBs are still locked on default.

Example:
sqlx::migrate!().set_locking(false).run(&pool).await

(Changes have been tested & are actively used in development of our app)

sqlx-core/src/migrate/migrator.rs Outdated Show resolved Hide resolved
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
@fuzzbuck
Copy link
Contributor Author

Please review again

@abonander
Copy link
Collaborator

Can you run cargo fmt real quick?

@fuzzbuck
Copy link
Contributor Author

there

@abonander
Copy link
Collaborator

The instantiation of Migrator in this doctest is missing locking: true: https://github.com/fuzzbuck/sqlx/blob/patch-1/src/macros/test.md?plain=1#L134

@fuzzbuck
Copy link
Contributor Author

fuzzbuck commented Sep 2, 2022

Is that what was causing the CI to fail?

Anyway, that should be good now. Perhaps I shall make a suggestion to add information about doctests here?
EDIT: as well as cargo formatting, common new contributor mistakes, etc.
https://github.com/launchbadge/sqlx/blob/main/CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants