struct Prostore::Schema::Field

Overview

A column declaration captured from a field macro call (ADR-0002, 0004, 0011, 0013, 0014).

The actual default/backfill/lazy lambdas (when present) are not stored here — they are captured separately at the macro level and referenced by generated code. This struct holds only schema-level facts that survive into the fingerprint, the diff engine, and the migration plan. Note on String typing: while the user-facing DSL accepts Symbols (field 1, :id, ...), the macro stores the column name as a String at the schema-model level. This lets prostore round-trip schema state through JSON for ADR-0009's persisted migration plan. The Crystal type system can't construct Symbols at runtime, so a String here is what makes resume work.

Defined in:

prostore/schema/field.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(tag : Int32, name : String, crystal_type : String, portable_type : String, nullable : Bool, primary : Bool, auto_increment : Bool, has_default : Bool, default_sql : String | Nil, has_backfill : Bool, backfill_sql : String | Nil, has_lazy : Bool, enum_members : Array(EnumMember) | Nil = nil, enum_is_flags : Bool = false) #

[View source]

Instance Method Detail

def auto_increment : Bool #

def backfill_sql : String | Nil #

def clone #

[View source]
def copy_with(tag _tag = @tag, name _name = @name, crystal_type _crystal_type = @crystal_type, portable_type _portable_type = @portable_type, nullable _nullable = @nullable, primary _primary = @primary, auto_increment _auto_increment = @auto_increment, has_default _has_default = @has_default, default_sql _default_sql = @default_sql, has_backfill _has_backfill = @has_backfill, backfill_sql _backfill_sql = @backfill_sql, has_lazy _has_lazy = @has_lazy, enum_members _enum_members = @enum_members, enum_is_flags _enum_is_flags = @enum_is_flags) #

[View source]
def crystal_type : String #

def default_sql : String | Nil #

def enum_check_constraint_name(table : String) : String #

Stable CHECK-constraint name for an enum field (ADR-0016). Used by both the CREATE TABLE renderer and the AlterEnumMembers step so the constraint can be located and replaced at migration time.


[View source]
def enum_is_flags : Bool #

def enum_members : Array(EnumMember) | Nil #

def has_backfill : Bool #

def has_default : Bool #

def has_lambda_backfill? : Bool #

[View source]
def has_lambda_default? : Bool #

[View source]
def has_lazy : Bool #

def name : String #

def nullable : Bool #

def portable_type : String #

def primary : Bool #

def tag : Int32 #