gloo/pg

Postgres column types for use with gloo/migration.

Build columns with pg.column(name, type) then pass them to the migration DSL. The modifier functions (not_null, primary_key, unique, default) are re-exported here so callers only need to import gloo/pg.

Types

pub type PgColumnType {
  Text
  VarChar(Int)
  Integer
  BigInt
  SmallInt
  Boolean
  Timestamp
  TimestampTz
  Date
  Time
  Uuid
  Numeric(precision: Int, scale: Int)
  JsonB
  ByteA
  Serial
  BigSerial
  Real
  DoublePrecision
}

Constructors

  • Text
  • VarChar(Int)
  • Integer
  • BigInt
  • SmallInt
  • Boolean
  • Timestamp
  • TimestampTz
  • Date
  • Time
  • Uuid
  • Numeric(precision: Int, scale: Int)
  • JsonB
  • ByteA
  • Serial
  • BigSerial
  • Real
  • DoublePrecision

Values

pub fn column(name: String, t: PgColumnType) -> migration.Column

Create a Postgres-typed column. Compile error if you pass a gloo/sqlite.SqColumnType — they are different types.

pub fn default(
  col: migration.Column,
  expr: String,
) -> migration.Column
pub fn type_sql(t: PgColumnType) -> String

Render a Postgres column type to its DDL SQL string.

Search Document