Liking cljdoc? Tell your friends :D

wagoe.platform.shell.adapters.database.utils.schema

Schema-to-DDL generation utilities for database adapters.

This namespace provides utilities for generating database DDL statements from Malli schema definitions. It handles:

  • Column type mapping based on database dialect
  • Table creation with constraints
  • Index generation from schema analysis
  • Cross-database compatibility

Key Features:

  • Uses Malli schemas as canonical source of truth
  • Database-specific column type mapping
  • Foreign key and unique constraint generation
  • Automatic index creation based on field patterns

Usage: (require '[wagoe.platform.shell.adapters.database.utils.schema :as schema])

(schema/generate-table-ddl ctx "users" some-malli-schema) (schema/initialize-tables-from-schemas! ctx schema-map)

Schema-to-DDL generation utilities for database adapters.

This namespace provides utilities for generating database DDL statements
from Malli schema definitions. It handles:
- Column type mapping based on database dialect
- Table creation with constraints
- Index generation from schema analysis
- Cross-database compatibility

Key Features:
- Uses Malli schemas as canonical source of truth
- Database-specific column type mapping
- Foreign key and unique constraint generation
- Automatic index creation based on field patterns

Usage:
  (require '[wagoe.platform.shell.adapters.database.utils.schema :as schema])

  (schema/generate-table-ddl ctx "users" some-malli-schema)
  (schema/initialize-tables-from-schemas! ctx schema-map)
raw docstring

generate-indexes-ddlclj

(generate-indexes-ddl _ctx table-name malli-schema)

Generate CREATE INDEX statements from Malli schema analysis.

Args: ctx: Database context table-name: String name of the table malli-schema: Malli schema definition

Returns: Vector of DDL index statements

Generate CREATE INDEX statements from Malli schema analysis.

Args:
  ctx: Database context
  table-name: String name of the table
  malli-schema: Malli schema definition
  
Returns:
  Vector of DDL index statements
sourceraw docstring

generate-table-ddlclj

(generate-table-ddl ctx table-name malli-schema)

Generate CREATE TABLE DDL from Malli schema definition.

Args: ctx: Database context table-name: String name for the table malli-schema: Malli schema definition ([:map ...] form)

Returns: String DDL statement

Example: (generate-table-ddl ctx "users" User-schema)

Generate CREATE TABLE DDL from Malli schema definition.

Args:
  ctx: Database context
  table-name: String name for the table
  malli-schema: Malli schema definition ([:map ...] form)
  
Returns:
  String DDL statement
  
Example:
  (generate-table-ddl ctx "users" User-schema)
sourceraw docstring

initialize-tables-from-schemas!clj

(initialize-tables-from-schemas! ctx schema-definitions)

Initialize database tables and indexes from a map of Malli schema definitions.

Args: ctx: Database context schema-definitions: Map of table-name -> malli-schema

Returns: nil

Throws: Exception if schema initialization fails

Example: (initialize-tables-from-schemas! ctx {"users" User-schema "user_sessions" UserSession-schema})

Initialize database tables and indexes from a map of Malli schema definitions.

Args:
  ctx: Database context
  schema-definitions: Map of table-name -> malli-schema
  
Returns:
  nil
  
Throws:
  Exception if schema initialization fails
  
Example:
  (initialize-tables-from-schemas! ctx 
    {"users" User-schema
     "user_sessions" UserSession-schema})
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close