Skip to content

RealLifeGlobal/sqlboiler-crdb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlboiler-crdb

CockroachDB driver for SQLBoiler — generates type-safe Go ORM code from your CockroachDB schema.

Fork of glerchundi/sqlboiler-crdb with enum support, SSL certificates, and updated dependencies.

Installation

go install github.com/realLifeGlobal/sqlboiler-crdb/v4@latest

Then generate your models:

sqlboiler crdb

Configuration

Add a [crdb] section to your sqlboiler.toml:

[crdb]
user     = "root"
pass     = ""
host     = "localhost"
port     = 26257
dbname   = "mydatabase"
sslmode  = "disable"

SSL / Secure Clusters

For clusters requiring certificate-based authentication:

[crdb]
user        = "myuser"
pass        = "mypassword"
host        = "localhost"
port        = 26257
dbname      = "mydatabase"
sslmode     = "verify-full"
sslrootcert = "/path/to/certs/ca.crt"
sslcert     = "/path/to/certs/client.myuser.crt"
sslkey      = "/path/to/certs/client.myuser.key"

You can also use sslmode = "require" with just user/password (no cert files) for password-based auth over TLS.

Enum Types

CockroachDB user-defined enum types are automatically detected and mapped to the format that SQLBoiler's randomize package understands. This means generated tests will use valid enum values instead of random strings.

To generate Go enum types, add:

[crdb]
add-enum-types   = true    # generate Go enum types (default: false)
enum-null-prefix = "Null"  # prefix for nullable enum types (default: "Null")

Without add-enum-types, enum columns are mapped to string / null.String — but with correct randomization values, so tests pass either way.

Changes from Upstream

  • Enum type support — User-defined CockroachDB enums (CREATE TYPE ... AS ENUM) are detected via pg_type/pg_enum and mapped correctly, eliminating "Unhandled data type" warnings and test failures with "invalid input value for enum"
  • SSL certificate supportsslrootcert, sslcert, and sslkey config options for secure CockroachDB clusters (upstream #50)
  • Migrated to aarondl/* — Updated from volatiletech/* to aarondl/* packages following SQLBoiler's maintenance migration
  • SQL-based test schema cloning — Replaced deprecated cockroach dump with SQL queries for test database setup, compatible with modern CockroachDB versions
  • --version flagsqlboiler-crdb --version prints the build version

Version

sqlboiler-crdb --version

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 63.5%
  • Go Template 36.5%