PostgresDdlGenerator

Classes > Migration.Postgres > PostgresDdlGenerator

PostgreSQL DDL generator for schema operations.

public static class PostgresDdlGenerator

Methods

MigrateSchema(IDbConnection, SchemaDefinition, Action<string>?, Action<string, Exception>?)

public static MigrationResult MigrateSchema(IDbConnection connection, SchemaDefinition schema, Action<string>? onTableCreated = null, Action<string, Exception>? onTableFailed = null)

Migrate a schema definition to PostgreSQL, creating all tables. Each table is created independently - failures on one table don't block others. Uses CREATE TABLE IF NOT EXISTS for idempotency.

Parameters:

Name Type Description
connection IDbConnection Open database connection.
schema SchemaDefinition Schema definition to migrate.
onTableCreated String> Optional callback for each table created (table name).
onTableFailed Exception> Optional callback for each table that failed (table name, exception).

Returns: MigrationResult - Migration result with success status and any errors.

Generate(SchemaOperation)

public static string Generate(SchemaOperation operation)

Generate PostgreSQL DDL for a schema operation.

Parameters:

Name Type Description
operation SchemaOperation

Returns: String

PortableTypeToPostgres(PortableType)

public static string PortableTypeToPostgres(PortableType type)

Map portable type to PostgreSQL type.

Parameters:

Name Type Description
type PortableType

Returns: String