mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-10-24 04:14:08 +00:00
Map inet columns to IpAddr through sqlx.toml
Every `inet` column holds a single host address, so a type override in the new per-crate `sqlx.toml` replaces the `as "col: IpAddr"` casts the queries needed to avoid the default `IpNetwork` mapping. Both crates using the query macros also pin `chrono` as the date/time crate. This needs the `sqlx-toml` feature on `sqlx`. `sqlx-cli` needs it too, as it refuses to run in a crate directory that contains a `sqlx.toml` file otherwise. It is a default feature of `sqlx-cli`, so only the `--no-default-features` install in the docs has to name it.
This commit is contained in:
22 files changed
+111
-40
No files matched your search
@@ -30,14 +30,19 @@ Usually it does so by having the database available at compile time, but to avoi
|
||||
Preparing this flat file is done through `sqlx-cli`, and should be done everytime the database schema or the queries changed.
|
||||
|
||||
```sh
|
||||
# Install the CLI
|
||||
cargo install sqlx-cli --no-default-features --features postgres
|
||||
# Install the CLI. The `sqlx-toml` feature is required because the CLI refuses
|
||||
# to run in a crate directory that contains a `sqlx.toml` file without it.
|
||||
cargo install sqlx-cli --no-default-features --features postgres,sqlx-toml
|
||||
|
||||
cd crates/storage-pg/ # Must be in the mas-storage-pg crate folder
|
||||
export DATABASE_URL=postgresql:///matrix_auth
|
||||
cargo sqlx prepare
|
||||
```
|
||||
|
||||
Both `mas-storage-pg` and `syn2mas` use the query macros and have their own
|
||||
`.sqlx` cache and `sqlx.toml`. The `misc/sqlx_update.sh` script regenerates both
|
||||
in one go (it also sets up the temporary tables `syn2mas` needs).
|
||||
|
||||
## Migrations
|
||||
|
||||
Migration files live in the `migrations` folder in the `mas-storage-pg` crate.
|
||||
|
||||
Reference in new issue
Block a user