Module: Pcrd::Schema::DDL
- Defined in:
- lib/pcrd/schema/ddl.rb
Overview
Generates CREATE TABLE DDL for the target cluster from a source schema plus a Config::Table migration spec.
Column ordering: if table_config.optimize_column_order is true, columns are sorted for minimal padding waste before rendering.
Exclusions (by design):
- Foreign key constraints: listed in preflight post-cutover checklist
- Non-PK indexes: operator creates on target before cutover
- GENERATED/identity: target uses plain type; sequence advanced at cutover
- nextval() defaults: referencing source sequence; omitted from DDL
Class Method Summary collapse
-
.generate(source_columns:, table_config:, primary_key_columns: [], schema_name: "public") ⇒ Object
Returns a CREATE TABLE SQL string (no trailing semicolon — caller adds one if needed, or passes directly to exec_sql).
Class Method Details
.generate(source_columns:, table_config:, primary_key_columns: [], schema_name: "public") ⇒ Object
Returns a CREATE TABLE SQL string (no trailing semicolon — caller adds one if needed, or passes directly to exec_sql).
19 20 21 22 23 24 25 |
# File 'lib/pcrd/schema/ddl.rb', line 19 def self.generate(source_columns:, table_config:, primary_key_columns: [], schema_name: "public") target_cols = synthesize_target_columns(source_columns, table_config) target_pk = map_pk_through_renames(primary_key_columns, table_config) render(target_cols, table_config.name, schema_name, target_pk) end |