mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-30 13:20:59 +00:00
* feat: create `sqlx.toml` format * feat: add support for ignored_chars config to sqlx_core::migrate * chore: test ignored_chars with `U+FEFF` (ZWNBSP/BOM) https://en.wikipedia.org/wiki/Byte_order_mark * refactor: make `Config` always compiled simplifies usage while still making parsing optional for less generated code * refactor: add origin information to `Column` * feat(macros): implement `type_override` and `column_override` from `sqlx.toml` * refactor(sqlx.toml): make all keys kebab-case, create `macros.preferred-crates` * feat: make macros aware of `macros.preferred-crates` * feat: make `sqlx-cli` aware of `database-url-var` * feat: teach macros about `migrate.table-name`, `migrations-dir` * feat: teach macros about `migrate.ignored-chars` * chore: delete unused source file `sqlx-cli/src/migration.rs` * feat: teach `sqlx-cli` about `migrate.defaults` * feat: teach `sqlx-cli` about `migrate.migrations-dir` * feat: teach `sqlx-cli` about `migrate.table-name` * feat: introduce `migrate.create-schemas` * WIP feat: create multi-tenant database example * fix(postgres): don't fetch `ColumnOrigin` for transparently-prepared statements * feat: progress on axum-multi-tenant example * feat(config): better errors for mislabeled fields * WIP feat: filling out axum-multi-tenant example * feat: multi-tenant example No longer Axum-based because filling out the request routes would have distracted from the purpose of the example. * chore(ci): test multi-tenant example * fixup after merge * fix(ci): enable `sqlx-toml` in CLI build for examples * fix: CI, README for `multi-tenant` * fix: clippy warnings * fix: multi-tenant README * fix: sequential versioning inference for migrations * fix: migration versioning with explicit overrides * fix: only warn on ambiguous crates if the invocation relies on it * fix: remove unused imports * fix: doctest * fix: `sqlx mig add` behavior and tests * fix: restore original type-checking order * fix: deprecation warning in `tests/postgres/macros.rs` * feat: create postgres/multi-database example * fix: examples/postgres/multi-database * fix: cargo fmt * chore: add tests for config `migrate.defaults` * fix: sqlx-cli/tests/add.rs * feat(cli): add `--config` override to all relevant commands * chore: run `sqlx mig add` test with `RUST_BACKTRACE=1` * fix: properly canonicalize config path for `sqlx mig add` test * fix: get `sqlx mig add` test passing * fix(cli): test `migrate.ignored-chars`, fix bugs * feat: create `macros.preferred-crates` example * fix(examples): use workspace `sqlx` * fix: examples * fix(sqlite): unexpected feature flags in `type_checking.rs` * fix: run `cargo fmt` * fix: more example fixes * fix(ci): preferred-crates setup * fix(examples): enable default-features for workspace `sqlx` * fix(examples): issues in `preferred-crates` * chore: adjust error message for missing param type in `query!()` * doc: mention new `sqlx.toml` configuration * chore: add `CHANGELOG` entry Normally I generate these when cutting the release, but I wanted to take time to editorialize this one. * doc: fix new example titles * refactor: make `sqlx-toml` feature non-default, improve errors * refactor: eliminate panics in `Config` read path * chore: remove unused `axum` dependency from new examples * fix(config): restore fallback to default config for macros * chore(config): remove use of `once_cell` (to match `main`)
277 lines
8.2 KiB
YAML
277 lines
8.2 KiB
YAML
name: Examples
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
- '*-dev'
|
|
|
|
jobs:
|
|
sqlx-cli:
|
|
name: Build SQLx CLI
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
run: |
|
|
rustup show active-toolchain || rustup toolchain install
|
|
rustup override set stable
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- run: >
|
|
cargo build
|
|
-p sqlx-cli
|
|
--bin sqlx
|
|
--release
|
|
--no-default-features
|
|
--features mysql,postgres,sqlite,sqlx-toml
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sqlx-cli
|
|
path: target/release/sqlx
|
|
|
|
mysql:
|
|
name: MySQL Examples
|
|
runs-on: ubuntu-latest
|
|
needs: sqlx-cli
|
|
|
|
services:
|
|
mysql:
|
|
image: mysql:latest
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: password
|
|
ports:
|
|
- 3306:3306
|
|
|
|
steps:
|
|
- name: Get SQLx-CLI
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: sqlx-cli
|
|
# $HOME is interpreted differently by the shell
|
|
path: /home/runner/.local/bin
|
|
|
|
- run: |
|
|
ls -R /home/runner/.local/bin
|
|
chmod +x /home/runner/.local/bin/sqlx
|
|
echo /home/runner/.local/bin >> $GITHUB_PATH
|
|
sleep 10
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
run: rustup show active-toolchain || rustup toolchain install
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Todos (Setup)
|
|
working-directory: examples/mysql/todos
|
|
env:
|
|
DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled
|
|
run: sqlx db setup
|
|
|
|
- name: Todos (Run)
|
|
env:
|
|
DATABASE_URL: mysql://root:password@localhost:3306/todos?ssl-mode=disabled
|
|
run: cargo run -p sqlx-example-mysql-todos
|
|
|
|
postgres:
|
|
name: PostgreSQL Examples
|
|
runs-on: ubuntu-latest
|
|
needs: sqlx-cli
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:latest
|
|
env:
|
|
POSTGRES_PASSWORD: password
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- name: Get SQLx-CLI
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: sqlx-cli
|
|
path: /home/runner/.local/bin
|
|
|
|
- run: |
|
|
ls -R /home/runner/.local/bin
|
|
chmod +x $HOME/.local/bin/sqlx
|
|
echo $HOME/.local/bin >> $GITHUB_PATH
|
|
sleep 10
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
run: rustup show active-toolchain || rustup toolchain install
|
|
|
|
- name: Axum Social with Tests (Setup)
|
|
working-directory: examples/postgres/axum-social-with-tests
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
|
|
run: sqlx db setup
|
|
|
|
- name: Axum Social with Tests (Check)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
|
|
run: cargo check -p sqlx-example-postgres-axum-social
|
|
|
|
- name: Axum Social with Tests (Test)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/axum-social
|
|
run: cargo test -p sqlx-example-postgres-axum-social
|
|
|
|
# The Chat example has an interactive TUI which is not trivial to test automatically,
|
|
# so we only check that it compiles.
|
|
- name: Chat (Check)
|
|
run: cargo check -p sqlx-example-postgres-chat
|
|
|
|
- name: Files (Setup)
|
|
working-directory: examples/postgres/files
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/files
|
|
run: sqlx db setup
|
|
|
|
- name: Files (Run)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/files
|
|
run: cargo run -p sqlx-example-postgres-files
|
|
|
|
- name: JSON (Setup)
|
|
working-directory: examples/postgres/json
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/json
|
|
run: sqlx db setup
|
|
|
|
- name: JSON (Run)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/json
|
|
run: cargo run -p sqlx-example-postgres-json
|
|
|
|
- name: Listen (Setup)
|
|
working-directory: examples/postgres/listen
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/listen
|
|
run: sqlx db create
|
|
|
|
- name: Listen (Run)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/listen
|
|
run: cargo run -p sqlx-example-postgres-listen
|
|
|
|
- name: Mockable TODOs (Setup)
|
|
working-directory: examples/postgres/mockable-todos
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/mockable-todos
|
|
run: sqlx db setup
|
|
|
|
- name: Mockable TODOs (Run)
|
|
env:
|
|
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:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/todos
|
|
run: sqlx db setup
|
|
|
|
- name: TODOs (Run)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/todos
|
|
# TODO: test full CLI
|
|
run: cargo run -p sqlx-example-postgres-todos
|
|
|
|
- name: Transaction (Setup)
|
|
working-directory: examples/postgres/transaction
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/txn
|
|
run: sqlx db setup
|
|
|
|
- name: Transaction (Run)
|
|
env:
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/txn
|
|
run: cargo run -p sqlx-example-postgres-transaction
|
|
|
|
sqlite:
|
|
name: SQLite Examples
|
|
runs-on: ubuntu-latest
|
|
needs: sqlx-cli
|
|
|
|
steps:
|
|
- name: Get SQLx-CLI
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: sqlx-cli
|
|
path: /home/runner/.local/bin
|
|
|
|
- run: |
|
|
ls -R /home/runner/.local/bin
|
|
chmod +x /home/runner/.local/bin/sqlx
|
|
echo /home/runner/.local/bin >> $GITHUB_PATH
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
run: rustup show active-toolchain || rustup toolchain install
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: TODOs (Setup)
|
|
env:
|
|
DATABASE_URL: sqlite://todos.sqlite
|
|
run: sqlx db setup --source=examples/sqlite/todos/migrations
|
|
|
|
- name: TODOs (Run)
|
|
env:
|
|
DATABASE_URL: sqlite://todos.sqlite
|
|
run: cargo run -p sqlx-example-sqlite-todos
|