* Updated ahash so it can compile on mac
* Updated MigrateDatabase Trait + related functions
* Postgres force drop database flag impl
* Update migrate.rs
* Reverted MigrateDatabase Trait
* Update migrate.rs
* Update migrate.rs
* Added force drop database fn impl
* Add Migrate Error
* Fixed changed function name
This commit updates the error handling logic in the `connect_tcp` function. Previously, the function would panic if the hostname did not resolve to at least one address.
The updated logic attempts to establish a TCP connection for each address that the hostname resolves to. If it fails to connect to any of the addresses, it will return the last encountered error. If the hostname doesn't resolve to any addresses, the function returns a custom error message stating "Hostname did not resolve to any addresses".
On `PoolOptions::connect()`, we open at least `min_connections`
connections, or 1 if unset. Therefore, the expression needs to be
`max()`. (`min(1, x)` would mean we always open only a single
connection).
Inlined format args make code more readable, and code more compact.
I ran this clippy command to fix most cases, and then cleaned up a few trailing commas and uncaught edge cases.
```
cargo clippy --bins --examples --benches --tests --lib --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
* cli: add --target-version CLI flags for migrate run/revert
* cli: fix broken test
* cli: test harness for `sqlx migrate` along with --target-version tests
* cli: Fail if version supplied to run/revert is too old/new
After some discussion with my coworkers, we thought about the behavior a bit more:
The behavior is now that for a run, if the provided version is too old, the CLI
will return with failure rather than being a no-op. This gives feedback to the
operator instead of being quiet.
It is still valid to up/downgrade to the latest version, this will still be a no-op
to allow for idempotency.
* Support naming migrations sequentially and inferring naming scheme
* Document new options and how naming is inferred
* Only account for up migrations when inferring ordering
* Implement Clone for PoolOptions manually (#2548)
Trying to derive `Clone` automatically for `PoolOptions` results
in errors when `clone` is actually called. This is because the
derive incorrectly determines that `Clone` is _not_ derivable
due to the lack of `Clone` implementation on the `DB: Database`
type parameter, even though no value of that type is actually
stored in a to-be-cloned position (in fact, it's only used for
the `Connection` associated type on the type parameter's
`Database` trait impl).
Manually implementing `Clone` side-steps this issue and insures
the type is always actually cloneable.
For reference: https://github.com/launchbadge/sqlx/issues/2548
* Ran 'cargo fmt'
* Simplified Arc cloning
The documentation for `PgAdvisoryLockGuard` lists a set of types
that should be able to be passed to it, but when actually trying
to do so, compilation would fail due to missing `AsMut` trait
implementations for those types. This commit adds the missing
`AsMut` impls so that `Transaction` and `PgConnection` can be used
as type parameters to `PgAdvisoryLockGuard`, as expected.
For reference: https://github.com/launchbadge/sqlx/issues/2520
* Traverse symlinks when resolving migrations
When enumerating the source directory seeking migration files, `sqlx`
ignores entries that aren't files. This was previously reported as #614
and fixed in #985 but apparently regressed somewhere along the way. This
commit reintroduces the fix from #985 to the current implementation: use
`std::fs::metadata` instead of `std::fs::DirEntry::metadata`. The former
is documented to traverse symlinks; the latter does not.
* add migrations_symlink test