Skip to content

Commit

Permalink
feat: update versions for uuid libs, pgrx
Browse files Browse the repository at this point in the history
Signed-off-by: vados <[email protected]>
  • Loading branch information
t3hmrman committed Jul 3, 2023
1 parent da6e665 commit 5c93c4b
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 256 deletions.
407 changes: 208 additions & 199 deletions Cargo.lock

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,29 @@ rust-version = "1.69.0"
crate-type = ["cdylib"]

[features]
default = [ "pg14" ]
pg11 = [ "pgx/pg11", "pgx-tests/pg11" ]
pg12 = [ "pgx/pg12", "pgx-tests/pg12" ]
pg13 = [ "pgx/pg13", "pgx-tests/pg13" ]
pg14 = [ "pgx/pg14", "pgx-tests/pg14" ]
default = ["pg14"]
pg11 = [ "pgrx/pg11", "pgrx-tests/pg11" ]
pg12 = [ "pgrx/pg12", "pgrx-tests/pg12" ]
pg13 = [ "pgrx/pg13", "pgrx-tests/pg13" ]
pg14 = [ "pgrx/pg14", "pgrx-tests/pg14" ]
pg15 = [ "pgrx/pg15", "pgrx-tests/pg15" ]
pg_test = []

[dependencies]
pgx = "0.7.4"
uuid7 = "0.2.6"
nanoid = "0.4.0"
cuid = "1.3.1"
getrandom = "0.2.8"
ksuid = "0.2.0"
ulid = "0.6.0"
timeflake-rs = "0.2.2"
sonyflake = "0.1.2"
nanoid = "0.4.0"
pgrx = "=0.9.7"
pushid = "0.0.1"
xid = "1.0.2"
cuid = "1.2.0"
getrandom = "0.2.8"
sonyflake = "0.2.0"
timeflake-rs = "0.3.0"
ulid = "1.0.0"
uuid7 = "0.6.4"
xid = "1.0.3"

[dev-dependencies]
pgx-tests = "=0.7.4"
pgrx-tests = "=0.9.7"

[profile.dev]
panic = "unwind"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ build-test-watch: check-tool-cargo check-tool-cargo-watch
> $(CARGO_WATCH) -x "test $(CARGO_BUILD_FLAGS)" --watch src

package:
> $(CARGO) pgx package
> $(CARGO) pgrx package

test:
> $(CARGO) test
> $(CARGO) pgx test
> $(CARGO) pgrx test

##########
# Docker #
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| [xid][xid] | `idkit_xid_generate` | [`xid`](https://crates.io/crates/xid) | XID |
| [cuid][cuid] | `idkit_cuid_generate` | [`cuid`](https://crates.io/crates/cuid) | CUID |

This Postgres extension is made possible thanks to [`pgx`][pgx].
This Postgres extension is made possible thanks to [`pgrx`][pgrx].

## Prior Art

Expand Down Expand Up @@ -58,7 +58,7 @@ Here's how to get started working on `pg_idkit` locally.
To work on `pg_idkit`, you'll need the following:

- [Rust][rust] toolchain ([`rustup`][rustup])
- [`pgx`][pgx] and it's toolchain (the rust subcommand)
- [`pgrx`][pgrx] and it's toolchain (the rust subcommand)
- (optional) [`git-crypt`][git-crypt] (for working with secrets)
- (optional) [direnv][direnv]
- (optional) [Docker][docker]
Expand All @@ -80,11 +80,11 @@ export DOCKER_CONFIG=$(realpath secrets/docker)

[direnv]: https://direnv.net

## Install `cargo-pgx`
## Install `cargo-pgrx`

```console
cargo install cargo-pgx@0.7.4
cargo pgx init --pg14 download
cargo install cargo-pgrx@0.9.7
cargo pgrx init
```

## Building the project
Expand All @@ -99,12 +99,12 @@ To run the build continuously for quicker local development (assuming you have `
make build-watch
```

### `pgx` workflow
### `pgrx` workflow

Note that you can use the `pgx`-documented development flow as well (using `cargo pgx`) as well, for example:
Note that you can use the `pgrx`-documented development flow as well (using `cargo pgrx`) as well, for example:

```console
cargo pgx run pg14
cargo pgrx run pg14
```

## Run tests
Expand Down Expand Up @@ -153,7 +153,7 @@ To push up images that are used from continuous integration:
4. Observe the docker login credentials generated in this local repo directory (`secrets/docker/config.json`)
5. Run `make build-ci-image push-ci-image`

[pgx]: https://github.com/tcdi/pgx
[pgrx]: https://github.com/tcdi/pgrx
[github-ai]: https://github.com/ai
[rfc-4122-update]: https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04
[cargo-watch]: https://github.com/passcod/cargo-watch
Expand Down Expand Up @@ -183,7 +183,6 @@ To push up images that are used from continuous integration:
[e-elliott]: https://github.com/ericelliott
[wiki-gregorian]: https://en.wikipedia.org/wiki/Gregorian_calendar
[rust]: https://rust-lang.org
[pgx]: https://github.com/tcdi/pgx
[pg-docs-operator-classes]: https://www.postgresql.org/docs/current/indexes-opclass.html
[repo]: https://github.com/t3hmrman/pg_idkit
[oryx-pro]: https://system76.com/laptops/oryx
Expand Down
10 changes: 5 additions & 5 deletions infra/docker/ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ RUN chmod g+w -R /usr/local/cargo
RUN chmod g+w -R /usr/local/build

# Install development/build/testing deps
# NOTE: version of cargo-pgx must be handled speicfically
RUN su idkit -c "cargo install sccache cargo-cache cargo-pgx@0.7.4"
# NOTE: version of cargo-pgrx must be handled speicfically
RUN su idkit -c "cargo install sccache cargo-cache cargo-pgrx@0.9.7"

# Initialize pgx
# NOTE: pgx must be reinitialized if cargo-pgx changes
RUN su idkit -c "cargo pgx init --pg14 download"
# Initialize pgrx
# NOTE: pgrx must be reinitialized if cargo-pgrx changes
RUN su idkit -c "cargo pgrx init --pg14 download"
4 changes: 2 additions & 2 deletions src/cuid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pgx::*;
use cuid;
use pgrx::*;

/// Generate a random cuid UUID
#[pg_extern]
Expand All @@ -23,7 +23,7 @@ fn idkit_cuid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/ksuid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pgx::*;
use ksuid::Ksuid;
use pgrx::*;

/// Generate a random KSUID (HEX-encoded)
#[pg_extern]
Expand All @@ -20,7 +20,7 @@ fn idkit_ksuid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod pushid;
mod xid;
mod cuid;

use pgx::*;
use pgrx::pg_module_magic;

pg_module_magic!();

Expand Down
4 changes: 2 additions & 2 deletions src/nanoid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::*;
use pgrx::*;
use nanoid::nanoid;

/// Generate a nanoid
Expand All @@ -20,7 +20,7 @@ fn idkit_nanoid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

#[pg_test]
/// Basic length test
Expand Down
4 changes: 2 additions & 2 deletions src/pushid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::*;
use pgrx::*;
use pushid::PushId;
use pushid::PushIdGen;

Expand All @@ -21,7 +21,7 @@ fn idkit_pushid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/timeflake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::*;
use pgrx::*;
use timeflake_rs::Timeflake;

/// Generate a random timeflake UUID
Expand Down Expand Up @@ -26,7 +26,7 @@ fn idkit_timeflake_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down
4 changes: 2 additions & 2 deletions src/ulid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::*;
use pgrx::*;
use ulid::Ulid;

/// Generate a ULID
Expand All @@ -20,7 +20,7 @@ fn idkit_ulid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down
9 changes: 4 additions & 5 deletions src/uuid_v6.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::*;
use pgrx::*;

mod vendor;
use vendor::{Node, UUIDv6};
Expand All @@ -18,12 +18,12 @@ fn idkit_uuidv6_generate_text() -> String {

/// Generate a UUID v6, producing a Postgres uuid object
#[pg_extern]
fn idkit_uuidv6_generate_uuid() -> pgx::Uuid {
fn idkit_uuidv6_generate_uuid() -> pgrx::Uuid {
let node = Node::new();

// This depends on PR to rust-uuidv6
// see: https://github.com/jedisct1/rust-uuidv6/pull/1
pgx::Uuid::from_slice(&UUIDv6::new(&node).create_bytes())
pgrx::Uuid::from_slice(&UUIDv6::new(&node).create_bytes())
.unwrap_or_else(|e| error!("{}", format!("failed to generate/parse uuidv6: {}", e)))
}

Expand All @@ -34,7 +34,7 @@ fn idkit_uuidv6_generate_uuid() -> pgx::Uuid {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand All @@ -58,5 +58,4 @@ mod tests {
let generated = crate::uuid_v6::idkit_uuidv6_generate_uuid();
assert_eq!(generated.len(), 16);
}

}
8 changes: 4 additions & 4 deletions src/uuid_v7.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgx::*;
use pgrx::*;
use uuid7::uuid7;

/// Generate a UUID v7
Expand All @@ -15,8 +15,8 @@ fn idkit_uuidv7_generate_text() -> String {

/// Generate a UUID v7, producing a Postgres uuid object
#[pg_extern]
fn idkit_uuidv7_generate_uuid() -> pgx::Uuid {
pgx::Uuid::from_slice(uuid7().as_bytes())
fn idkit_uuidv7_generate_uuid() -> pgrx::Uuid {
pgrx::Uuid::from_slice(uuid7().as_bytes())
.unwrap_or_else(|e| error!("{}", format!("failed to generate/parse uuidv7: {}", e)))
}

Expand All @@ -27,7 +27,7 @@ fn idkit_uuidv7_generate_uuid() -> pgx::Uuid {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down
6 changes: 3 additions & 3 deletions src/xid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pgx::*;
use ::xid::{new as generate_xid};
use ::xid::new as generate_xid;
use pgrx::*;

/// Generate a random xid UUID
#[pg_extern]
Expand All @@ -20,7 +20,7 @@ fn idkit_xid_generate_text() -> String {
#[cfg(any(test, feature = "pg_test"))]
#[pg_schema]
mod tests {
use pgx::*;
use pgrx::*;

/// Basic length test
#[pg_test]
Expand Down

0 comments on commit 5c93c4b

Please sign in to comment.