Ddl.ts overview

The DDL behind every dialect’s migrationStatements, generated from one column spec per table and a per-dialect type map (DdlDialect), so the dialects cannot drift in their columns, keys and indexes. *Schema.test.ts checks that the drizzle tables agree.


Exports Grouped by Category


utils

ColumnType (type alias)

What a column holds, before a dialect names its type.

Signature

type ColumnType =
  | "key"
  | "image"
  | "password"
  | "tag"
  | "short"
  | "identifierValue"
  | "instant"
  | "json"
  | "boolean"
  | "integer"
  | "bigint"

Source

DdlDialect (interface)

How one engine spells the spec.

Signature

export interface DdlDialect {
  readonly types: Readonly<Record<ColumnType, string>>
  /** What follows a primary-key column's type. */
  readonly primaryKey: string
  /** `DEFAULT <value>`'s value, or `undefined` where the engine takes none. */
  readonly defaults: Readonly<Record<DefaultValue, string | undefined>>
  /** Quote a column name the engine reserves. */
  readonly quote: (name: string) => string
  /** Declare indexes inside `CREATE TABLE` rather than as statements of their own. */
  readonly inlineIndexes: boolean
}

Source

pgDialect

PostgreSQL: text keys, timestamptz, jsonb, separate index statements.

Signature

declare const pgDialect: DdlDialect

Source

renderDdl

Every table’s DDL on dialect, under the given names, in dependency order.

Signature

declare const renderDdl: (dialect: DdlDialect, names?: Partial<TableNames>) => ReadonlyArray<string>

Source

renderScript

renderDdl joined into a single runnable SQL script.

Signature

declare const renderScript: (statements: ReadonlyArray<string>) => string

Source

sqliteDialect

SQLite: PostgreSQL’s layout with SQLite’s storage classes (epoch-millisecond INTEGER instants, JSON as TEXT, 0/1 flags).

Signature

declare const sqliteDialect: DdlDialect

Source


This site uses Just the Docs, a documentation theme for Jekyll.