Skip to content

Very WIP: Custom Postgres Types in Macros #336

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
85 changes: 85 additions & 0 deletions .github/workflows/sqlx-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: sqlx-cli

on:
pull_request:
push:
branches:
- master

jobs:
# tests `cargo sqlx prepare` using `examples/postgres/todos/`
test-prepare:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: todos
ports:
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v1

# Rust ------------------------------------------------

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Cache target/
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Load schema
working-directory: examples/postgres/todos
env:
# the in-container port is always 5432
DATABASE_URL: postgres://postgres:postgres@localhost:5432/todos
run: |
export CONTAINER_ID=$(docker ps --filter "ancestor=postgres:12" --format "{{.ID}}")
docker cp schema.sql $CONTAINER_ID:/schema.sql
docker exec $CONTAINER_ID bash -c "psql -d $DATABASE_URL -f ./schema.sql"

- name: install sqlx-cli
run: cargo install -f --path sqlx-cli/

- name: test `cargo sqlx prepare [--check]`
working-directory: examples/postgres/todos/
env:
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/todos
run: |
cargo sqlx prepare &&
cargo sqlx prepare --check

# now we have no connection to the database, we should be able to still build
- name: build example without DB
working-directory: examples/postgres/todos/
run: |
cargo clean -p sqlx-example-postgres-todos &&
cargo build

# check that the application works without rebuilding it
- name: run example
env:
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/todos
run: |
./target/debug/sqlx-example-postgres-todos add "test if `cargo sqlx prepare` worked" &&
./target/debug/sqlx-example-postgres-todos done 1

- name: Prepare build directory for cache
run: |
find ./target/debug -maxdepth 1 -type f -delete \
&& rm -fr ./target/debug/{deps,.fingerprint}/*sqlx* \
&& rm -f ./target/.rustc_info.json
62 changes: 42 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"sqlx-core",
"sqlx-macros",
"sqlx-test",
"cargo-sqlx",
"sqlx-cli",
"examples/mysql/todos",
"examples/postgres/listen",
"examples/postgres/todos",
Expand Down Expand Up @@ -39,6 +39,9 @@ default = [ "macros", "runtime-async-std" ]
macros = [ "sqlx-macros" ]
tls = [ "sqlx-core/tls" ]

# offline building support in `sqlx-macros`
offline = ["sqlx-macros/offline", "sqlx-core/offline"]

# intended mainly for CI and docs
all = [ "tls", "all-database", "all-type" ]
all-database = [ "mysql", "sqlite", "postgres" ]
Expand Down
14 changes: 0 additions & 14 deletions cargo-sqlx/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions cargo-sqlx/src/database_migrator.rs

This file was deleted.

Loading