Class: SchemaFerry::Core::EnumCheckBuilder
- Inherits:
-
Object
- Object
- SchemaFerry::Core::EnumCheckBuilder
- Includes:
- IdentifierShortenable
- Defined in:
- lib/schema_ferry/core/enum_check_builder.rb
Overview
Builds CHECK constraints enforcing MySQL enum values on varchar columns (enum_as :check).
Constant Summary
Constants included from IdentifierShortenable
IdentifierShortenable::HASH_LENGTH, IdentifierShortenable::MAX_BYTES
Instance Method Summary collapse
Methods included from IdentifierShortenable
Instance Method Details
#call(raw_table, rule) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/schema_ferry/core/enum_check_builder.rb', line 10 def call(raw_table, rule) raw_table[:columns].filter_map do |col| next if rule.ignored_columns.include?(col[:name]) # A type override takes the column away from varchar; the caller owns # any constraint then. next if rule.column_type_overrides.key?(col[:name]) values = enum_values(col[:sql_type]) next if values.nil? build_constraint(raw_table[:name], col[:name], values) end end |