Skip to content

feat: create sqlx.toml format #3383

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

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b487153
feat: create `sqlx.toml` format
abonander Jul 26, 2024
7645fbc
feat: add support for ignored_chars config to sqlx_core::migrate
abonander Sep 9, 2024
210b15f
chore: test ignored_chars with `U+FEFF` (ZWNBSP/BOM)
abonander Sep 9, 2024
daa689b
refactor: make `Config` always compiled
abonander Sep 18, 2024
2b1648f
refactor: add origin information to `Column`
abonander Sep 18, 2024
ee2428c
feat(macros): implement `type_override` and `column_override` from `s…
abonander Sep 19, 2024
4a8e5f0
refactor(sqlx.toml): make all keys kebab-case, create `macros.preferr…
abonander Sep 20, 2024
023e3c4
feat: make macros aware of `macros.preferred-crates`
abonander Sep 20, 2024
f8ab0f2
feat: make `sqlx-cli` aware of `database-url-var`
abonander Sep 20, 2024
6c19198
feat: teach macros about `migrate.table-name`, `migrations-dir`
abonander Sep 23, 2024
1fc70c4
feat: teach macros about `migrate.ignored-chars`
abonander Sep 23, 2024
05a4fec
chore: delete unused source file `sqlx-cli/src/migration.rs`
abonander Oct 5, 2024
471ab66
feat: teach `sqlx-cli` about `migrate.defaults`
abonander Oct 5, 2024
03438fc
feat: teach `sqlx-cli` about `migrate.migrations-dir`
abonander Jan 15, 2025
f12d296
feat: teach `sqlx-cli` about `migrate.table-name`
abonander Jan 22, 2025
ed54612
feat: introduce `migrate.create-schemas`
abonander Jan 22, 2025
6ec0454
WIP feat: create multi-tenant database example
abonander Jan 26, 2025
1add079
fix(postgres): don't fetch `ColumnOrigin` for transparently-prepared …
abonander Feb 2, 2025
51ff60d
feat: progress on axum-multi-tenant example
abonander Feb 2, 2025
639c326
feat(config): better errors for mislabeled fields
abonander Feb 21, 2025
9efcbb7
WIP feat: filling out axum-multi-tenant example
abonander Feb 26, 2025
95771ce
feat: multi-tenant example
abonander Feb 28, 2025
ca65897
chore(ci): test multi-tenant example
abonander Feb 28, 2025
5cf5952
fixup after merge
abonander Feb 28, 2025
36bd8fe
fix(ci): enable `sqlx-toml` in CLI build for examples
abonander Feb 28, 2025
9a32683
fix: CI, README for `multi-tenant`
abonander Feb 28, 2025
49974d8
fix: clippy warnings
abonander Feb 28, 2025
f771d44
fix: multi-tenant README
abonander Feb 28, 2025
8b7f0c9
fix: sequential versioning inference for migrations
abonander Feb 28, 2025
591b921
fix: migration versioning with explicit overrides
abonander Feb 28, 2025
9d7a3d6
fix: only warn on ambiguous crates if the invocation relies on it
abonander Mar 30, 2025
0e7c009
fix: remove unused imports
abonander Mar 30, 2025
a93fd91
fix: doctest
abonander Mar 31, 2025
dee10cb
fix: `sqlx mig add` behavior and tests
abonander Mar 31, 2025
3a4c08c
fix: restore original type-checking order
abonander Mar 31, 2025
6296325
fix: deprecation warning in `tests/postgres/macros.rs`
abonander Mar 31, 2025
1c420a3
feat: create postgres/multi-database example
abonander Apr 11, 2025
31fcb82
fix: examples/postgres/multi-database
abonander Apr 13, 2025
61e07c9
fix: cargo fmt
abonander Apr 13, 2025
1381b0e
chore: add tests for config `migrate.defaults`
abonander May 3, 2025
3520f28
fix: sqlx-cli/tests/add.rs
abonander May 3, 2025
b76ada6
feat(cli): add `--config` override to all relevant commands
abonander May 3, 2025
0a789c1
chore: run `sqlx mig add` test with `RUST_BACKTRACE=1`
abonander May 3, 2025
16cf74b
fix: properly canonicalize config path for `sqlx mig add` test
abonander May 3, 2025
9eea12f
fix: get `sqlx mig add` test passing
abonander May 3, 2025
c64b25a
fix(cli): test `migrate.ignored-chars`, fix bugs
abonander May 16, 2025
b921433
feat: create `macros.preferred-crates` example
abonander Jun 2, 2025
24b0d05
fix(examples): use workspace `sqlx`
abonander Jun 2, 2025
b05185e
fix: examples
abonander Jun 2, 2025
c0fade4
fix(sqlite): unexpected feature flags in `type_checking.rs`
abonander Jun 2, 2025
47127a7
fix: run `cargo fmt`
abonander Jun 2, 2025
3e1f002
fix: more example fixes
abonander Jun 2, 2025
52e7754
fix(ci): preferred-crates setup
abonander Jun 2, 2025
0694fd4
fix(examples): enable default-features for workspace `sqlx`
abonander Jun 2, 2025
a0e90c6
fix(examples): issues in `preferred-crates`
abonander Jun 2, 2025
bdf8302
chore: adjust error message for missing param type in `query!()`
abonander Jun 3, 2025
62f145e
doc: mention new `sqlx.toml` configuration
abonander Jun 3, 2025
60cacd7
chore: add `CHANGELOG` entry
abonander Jun 4, 2025
37554b4
doc: fix new example titles
abonander Jun 4, 2025
3f1a023
refactor: make `sqlx-toml` feature non-default, improve errors
abonander Jun 5, 2025
6d39d17
refactor: eliminate panics in `Config` read path
abonander Jun 5, 2025
a1e3798
chore: remove unused `axum` dependency from new examples
abonander Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
--bin sqlx
--release
--no-default-features
--features mysql,postgres,sqlite
--features mysql,postgres,sqlite,sqlx-toml

- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -175,6 +175,49 @@ jobs:
DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos
run: cargo run -p sqlx-example-postgres-mockable-todos

- name: Multi-Database (Setup)
working-directory: examples/postgres/multi-database
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/multi-database
ACCOUNTS_DATABASE_URL: postgres://postgres:password@localhost:5432/multi-database-accounts
PAYMENTS_DATABASE_URL: postgres://postgres:password@localhost:5432/multi-database-payments
run: |
(cd accounts && sqlx db setup)
(cd payments && sqlx db setup)
sqlx db setup

- name: Multi-Database (Run)
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/multi-database
ACCOUNTS_DATABASE_URL: postgres://postgres:password@localhost:5432/multi-database-accounts
PAYMENTS_DATABASE_URL: postgres://postgres:password@localhost:5432/multi-database-payments
run: cargo run -p sqlx-example-postgres-multi-database

- name: Multi-Tenant (Setup)
working-directory: examples/postgres/multi-tenant
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/multi-tenant
run: |
(cd accounts && sqlx db setup)
(cd payments && sqlx migrate run)
sqlx migrate run

- name: Multi-Tenant (Run)
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/multi-tenant
run: cargo run -p sqlx-example-postgres-multi-tenant

- name: Preferred-Crates (Setup)
working-directory: examples/postgres/preferred-crates
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/preferred-crates
run: sqlx db setup

- name: Multi-Tenant (Run)
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/preferred-crates
run: cargo run -p sqlx-example-postgres-preferred-crates

- name: TODOs (Setup)
working-directory: examples/postgres/todos
env:
Expand Down
32 changes: 29 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,42 @@ This section will be replaced in subsequent alpha releases. See the Git history

### Breaking

* [[#3821]] Groundwork for 0.9.0-alpha.1
* Increased MSRV to 1.86 and set rust-version [@abonander]
* [[#3821]]: Groundwork for 0.9.0-alpha.1 [[@abonander]]
* Increased MSRV to 1.86 and set rust-version
* Deleted deprecated combination runtime+TLS features (e.g. `runtime-tokio-native-tls`)
* Deleted re-export of unstable `TransactionManager` trait in `sqlx`.
* Not technically a breaking change because it's `#[doc(hidden)]`,
but [it _will_ break SeaORM][seaorm-2600] if not proactively fixed.
* [[#3383]]: feat: create `sqlx.toml` format [[@abonander]]
* SQLx and `sqlx-cli` now support per-crate configuration files (`sqlx.toml`)
* New functionality includes, but is not limited to:
* Rename `DATABASE_URL` for a crate (for multi-database workspaces)
* Set global type overrides for the macros (supporting custom types)
* Rename or relocate the `_sqlx_migrations` table (for multiple crates using the same database)
* Set characters to ignore when hashing migrations (e.g. ignore whitespace)
* More to be implemented in future releases.
* Enable feature `sqlx-toml` to use.
* `sqlx-cli` has it enabled by default, but `sqlx` does **not**.
* Default features of library crates can be hard to completely turn off because of [feature unification],
so it's better to keep the default feature set as limited as possible.
[This is something we learned the hard way.][preferred-crates]
* Guide: see `sqlx::_config` module in documentation.
* Reference: [[Link](sqlx-core/src/config/reference.toml)]
* Examples (written for Postgres but can be adapted to other databases; PRs welcome!):
* Multiple databases using `DATABASE_URL` renaming and global type overrides: [[Link](examples/postgres/multi-database)]
* Multi-tenant database using `_sqlx_migrations` renaming and multiple schemas: [[Link](examples/postgres/multi-tenant)]
* Force use of `chrono` when `time` is enabled (e.g. when using `tower-sessions-sqlx-store`): [[Link][preferred-crates]]
* Forcing `bigdecimal` when `rust_decimal` is enabled is also shown, but problems with `chrono`/`time` are more common.
* **Breaking changes**:
* Significant changes to the `Migrate` trait
* `sqlx::migrate::resolve_blocking()` is now `#[doc(hidden)]` and thus SemVer-exempt.

[seaorm-2600]: https://github.com/SeaQL/sea-orm/issues/2600
[feature unification]: https://doc.rust-lang.org/cargo/reference/features.html#feature-unification
[preferred-crates]: examples/postgres/preferred-crates

[#3821]: https://github.com/launchbadge/sqlx/pull/3830
[#3821]: https://github.com/launchbadge/sqlx/pull/3821
[#3383]: https://github.com/launchbadge/sqlx/pull/3383

## 0.8.6 - 2025-05-19

Expand Down
Loading
Loading