Commit graph

141 commits

Author SHA1 Message Date
Austin Bonander
2ab7565bd8 chore: configure clippy cast lints at workspace level 2024-08-23 23:39:32 -07:00
cycraig
4acecfc636
fix(sqlx-cli): do not clean sqlx during prepare (#2786)
* fix(cli): do not clean sqlx during prepare

* feat(cli): only clean dependencies with new --all flag for prepare
2024-08-01 15:36:42 -07:00
Denis Otkidach
572e2a4ed5
fix(cli): typo in error for required DB URL (#3389) 2024-07-29 17:28:41 -07:00
Frank Elsinga
e089d2fb55
bumped cargo_metadata to v0.18.1 (#3386) 2024-07-27 16:19:26 -07:00
Frank Elsinga
b37b34bd04
chore:added a testcase for sqlx migrate add ... (#3352) 2024-07-19 18:50:18 -07:00
Jos Ahrens
543395d80a
fix: build script new line at eof (#3353)
When generating the build script, it will
fail `cargo fmt -- --check` because it is
missing a new line at the end of the file.
2024-07-19 14:53:45 -07:00
Cristian Le
92de9d42a6 Add LICENSE-* files to crates 2024-06-20 10:56:08 -07:00
Austin Bonander
bae083cf79 fix: clippy warnings 2024-06-13 13:11:36 -07:00
Vraj Shah
02f196b4ac
fix: link to correct version in first-migration message (#2900)
Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2024-02-18 20:20:29 -08:00
Dawson
2cc3e0f90b
Minor fixes (#2955)
* doc link fix
variable declaration moved for better readability

* migration version abstraction
2024-01-16 13:49:25 -08:00
Vraj Shah
fda415927a
Sqlx Cli: Added force flag to drop database for postgres (#2873)
* 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
2023-11-21 11:11:08 -08:00
Ferenc Tamás
d3a28d461f
Do not require db url for prepare (#2882)
* feat(cli): do not require db url

* chore: remove unused import

* fix(cli): do not always pass DATABASE_URL

* fix(cli): check db when DATABASE_URL is provided
2023-11-20 20:11:23 -08:00
Rico
220bf93dc2
Fix comment in sqlx migrate add help (#2847)
The old description for the `sequential` flag read "If set, use *timestamp* versioning".
I guess this was a simple copy-paste error.
2023-11-03 17:23:36 -07:00
Matt Fellenz
b16fbebf2f
Don't use separate temp dir for query jsons (2) (#2803)
* Don't use temp dir for query jsons

Fixes #2663

* Return early when exclusive create fails

* Use atomic-file-write for writing query data
2023-10-17 11:41:30 -07:00
Adriano Di Luzio
6bec8574d4
Remove unused remove_dir_all crate (#2757) 2023-09-25 18:01:56 -07:00
Max Vorobev
d0fbe7feff
Automatically infer migration type (#2664) 2023-08-01 11:16:43 -07:00
Yuri Astrakhan
a824e8468c
Cleanup format arguments (#2650)
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
```
2023-07-31 13:27:04 -07:00
Ameer Ghani
84f21e99ef
cli: add --target-version CLI flags for migrate run/revert (#2538)
* 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.
2023-07-31 12:49:53 -07:00
Max Vorobev
f2bb464bcd
Support naming migrations sequentially (#2602)
* Support naming migrations sequentially and inferring naming scheme

* Document new options and how naming is inferred

* Only account for up migrations when inferring ordering
2023-07-24 16:00:26 -07:00
Jon Heinritz
8b223e24d3
Update clap to v4.3.10 (#2576) 2023-07-09 13:13:43 -07:00
Austin Bonander
dcb58b0e2c
0.7.0 release (#2575)
* WIP preparing 0.7.0 release

* fix: re-enable examples

* fix doctests in `sqlx-core`

* cherry-pick CHANGELOG entry for 0.6.3

* add actions workflow for examples

* fix(cli): close connection after running migrations

* fix examples

* fix(sqlite): fix parsing of URLs via `Any`

* fix(example): don't let Postgres `listen` example run forever

* fix Postgres `transaction` example
2023-07-03 14:37:37 -07:00
Jon Heinritz
1b7631eddc
Add CLI autocompletion using clap_complete (#2559) 2023-06-30 14:59:35 -07:00
Paolo Barbolini
14d70feab1 Enable runtime-tokio of sqlx when building sqlx-cli 2023-03-24 00:28:16 -07:00
Austin Schey
cf3ce13d27 fix(prepare): store temporary query files inside the workspace 2023-03-14 17:25:24 -07:00
Craig Bester
3f2ec6f91a chore: update documentation to replace sqlx-data.json with .sqlx 2023-03-01 19:17:21 -08:00
Craig Bester
96c8b12485 feat(prepare): move to one-file-per-query for offline mode
Co-authored-by: Jonas Platte <jonas@lumeo.com>
2023-03-01 19:17:21 -08:00
Craig Bester
a942f5316e fix: install default drivers before sqlx-cli create/drop 2023-02-22 15:09:41 -08:00
Craig Bester
006da611e1 fix: uncomment sqlx-cli database, default features 2023-02-22 15:09:41 -08:00
Austin Bonander
eade49cfb0
0.7.0-alpha.1 release 2023-02-21 14:56:54 -08:00
laundmo
c4a2e73a6f Add context to metadata parse error 2023-02-21 13:25:25 -08:00
Austin Bonander
b5312c3b6f Break drivers out into separate crates, clean up some technical debt (#2039)
* WIP rt refactors

* refactor: break drivers out into separate crates

also cleans up significant technical debt
2023-02-21 13:25:25 -08:00
Austin Bonander
b6cddcd014
prepare 0.6.2 release (#2092) 2022-09-14 15:23:06 -07:00
Travis Whitehead
09717e1b83
fix: Remove default chrono dep on time for sqlx-cli (#2089)
chrono v0.4.19 includes time 0.1 via default feature flag oldtime.
time 0.1 is deprecated and flagged for: https://rustsec.org/advisories/RUSTSEC-2020-0071
2022-09-12 18:08:39 -07:00
cycraig
20af5cd9c3
Use cargo check consistently in prepare (#2071) 2022-08-31 17:02:46 -07:00
cycraig
0823e1139c
Fix prepare race condition in workspaces (#2069)
* Separate offline query metadata per crate

* Update sqlx-cli prepare to use separate query metadata per crate

* Add resolve.root to metadata test fixture

* Simplify root package resolution

* Fix prepare --merged
2022-08-26 17:30:09 -07:00
Austin Bonander
cb52c7c62b chore: prep 0.6.1 release 2022-08-02 19:16:32 -07:00
Austin Bonander
a2eceec33b
chore: replace dotenv with dotenvy (#2003)
* chore: replace `dotenv` with `dotenvy`

The former appears to be unmaintained and the latter is a drop-in replacement.

* chore: fix all warnings
2022-07-28 14:33:44 -07:00
Ivan Kozik
b9a8f90b0c
fix(sqlx-cli): fix the build (#1969)
This fixes:

```
error[E0616]: field `target_directory` of struct `metadata::Metadata` is private
   --> sqlx-cli/src/prepare.rs:175:47
    |
175 |             .env("CARGO_TARGET_DIR", metadata.target_directory.clone())
    |                                               ^^^^^^^^^^^^^^^^ private field
    |
help: a method `target_directory` also exists, call it with parentheses
    |
175 |             .env("CARGO_TARGET_DIR", metadata.target_directory().clone())
    |                                                               ++
```
2022-07-14 00:09:53 -07:00
Fredrik Park
7d8ded9a1a
Set CARGO_TARGET_DIR when compiling the prepare queries (#1910)
* Move compiled query data

I did try to set rustc's --out-dir but encountered a strange error
stating that it can not be set more than once (even though I am unable
to deduce what else is setting it).

This enabled me to set a custom CARGO_TARGET_DIR and still be able to
prepare queries.

* Set CARGO_TARGET_DIR in the rustc invocation
2022-07-12 17:25:52 -07:00
LovecraftianHorror
2c67e2a29e
Try avoiding a full clean in cargo sqlx prepare --merged (#1802)
* refactor(sqlx-cli): Try avoiding a full clean with `--merged`

* docs(sqlx-cli): Sprinkle some comments on the metadata changes

* refactor(sqlx-cli): Make the new recompiltion setup unit-testable

* fix(sqlx-cli): Only pass in `$RUSTFLAGS` when set when using `--merged`

* refactor(sqlx-cli): `cargo clean -p` works by name so rip out pkgid code

* chore(sqlx-cli): Remove unused imports
2022-07-12 14:29:41 -07:00
Austin Bonander
bc3e70545b
sqlite improvements (#1965)
* use direct blocking calls for SQLite in `sqlx_macros`
    * this also ensures the database is closed properly, cleaning up tempfiles
* don't send `PRAGMA journal_mode` unless set
    * this previously defaulted to WAL mode which is a permanent setting
      on databases which doesn't necessarily apply to all use-cases
    * changing into or out of WAL mode acquires an exclusive lock on the database
      that can't be waited on by `sqlite3_busy_timeout()`
    * for consistency, `sqlx-cli` commands that create databases will still
      create SQLite databases in WAL mode; added a flag to disable this.
* in general, don't send `PRAGMA`s unless different than default
    * we were sending a bunch of `PRAGMA`s with their default values just to enforce
      an execution order on them, but we can also do this by inserting empty slots
      for their keys into the `IndexMap`
* add error code to `SqliteError` printout
* document why `u64` is not supported
2022-07-12 13:59:37 -07:00
Austin Bonander
17cebde64a
preparing 0.6.0 release (#1911)
* preparing 0.6.0 release

* run `cargo update` (not `upgrade`)
2022-06-16 15:53:09 -07:00
Miklós Tusz
664d576655
Fix migration checksum comparison during migrate info (#1888)
When running `sqlx migrate info`, the applied migrations checksums are
compared against the checksums of the local migration files. While the
checksums of applied migrations are stored correctly in the database as
sha384sum values, the `migrate info` command was incorrectly comparing
these against the checksums of down-migrations in cases where reversible
migrations are being used (e.g. when migrations end in `.up.sql` and
`.down.sql`).

This fixes the issue by skipping over any migrations with the
`MigrationType::ReversibleDown` type, using the same idiom as is used
when running migrations (with `migrate run`).

Issue introduced in #1680
Partially resolves #1158
2022-06-10 12:07:23 -07:00
Austin Bonander
1f91724927
feat(cli): add --connect-timeout (#1889) 2022-06-08 15:48:04 -07:00
Kian-Meng Ang
d52f301a94
Fix typos (#1894)
* Fix typos

* Update CHANGELOG.md

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
2022-06-08 14:56:56 -07:00
Toby Murray
24baac779f
Put Usage at same level as Install (#1814)
From a formatting perspective, `Usage` is currently nested under `Install`. I think these would appropriately be siblings. This has the side benefit of making the headings under `Usage` more visually distinct from the rest of the content which I think makes it easier to read.
2022-06-01 13:53:47 -07:00
Toby Murray
302b415897
Reword "building in offline mode" (#1815)
Sometimes people do a bad job of reading comprehension (see #1813). This rewords a little to be even more prescriptive about how to build in offline mode.
2022-05-31 16:59:37 -07:00
Paolo Barbolini
b934f82440
Bump remanining dependencies (#1807)
Co-authored-by: Austin Bonander <austin@launchbadge.com>
2022-04-15 14:34:48 -07:00
Paolo Barbolini
fc9c9be5e8
Update to edition 2021 (#1808)
* Update to edition 2021

* Fix running tests
2022-04-15 12:52:00 -07:00
Austin Bonander
2e026cae67
prepare 0.5.12 release (#1800)
* prepare release 0.5.12

* chore: remove mentions of things happening in 0.6

except one mention that should still be happening in 0.6
2022-04-14 14:21:15 -07:00