Skip to content

feat: CockroachDB Support #2929

@hongkongkiwi

Description

@hongkongkiwi

Summary

This issue tracks the implementation of CockroachDB support for SeaORM.

CockroachDB is wire-compatible with PostgreSQL, so most functionality works with the existing sqlx-postgres driver. The main difference is schema generation: CockroachDB doesn't support PostgreSQL's SERIAL columns and requires GENERATED BY DEFAULT AS IDENTITY instead.

Related PRs

Implementation Status

SeaORM

  • Added DatabaseBackend::Cockroach variant
  • Added cockroachdb feature flag
  • Added URL scheme handling (cockroachdb://, postgres://, postgresql://)
  • Added schema generation for IDENTITY columns
  • Added documentation
  • Added tests

SeaQuery

  • Added backend-cockroach feature flag
  • Added CockroachQueryBuilder as alias to PostgresQueryBuilder
  • Added option-cockroachdb-use-identity feature flag
  • Updated version to 1.0.0-rc.29

Feature Flags

Package Feature Description
sea-orm cockroachdb Enable CockroachDB support
sea-orm cockroachdb-use-identity-pk Use IDENTITY columns for primary keys
sea-query backend-cockroach Enable CockroachDB backend
sea-query option-cockroachdb-use-identity Use IDENTITY columns (reserved)

Usage Example

Cargo

# Cargo.toml
[dependencies]
sea-orm = { version = "2.0", features = ["cockroachdb", "runtime-tokio-native-tls"] }

Rust Code

let db: DbConn = sea_orm::Connect::connect("postgres://user:password@host:26257/database?sslmode=require")
    .await?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions