Handle size in binary columns

In the cable schema we use:

```
    t.binary "payload", size: :long, null: false
```

This will fail when resetting the db otherwise with an error due to the unexpected size property.
This commit is contained in:
Jorge Manrubia
2025-12-01 13:32:54 +01:00
parent 5a1b59dc47
commit 3480e2d6db
@@ -24,13 +24,13 @@ module TableDefinitionColumnLimits
options[:limit] ||= STRING_DEFAULT_LIMIT options[:limit] ||= STRING_DEFAULT_LIMIT
end end
if type == :text if type == :text || type == :binary
if options.key?(:size) if options.key?(:size)
size = options.delete(:size) size = options.delete(:size)
options[:limit] ||= TEXT_SIZE_TO_LIMIT.fetch(size) do options[:limit] ||= TEXT_SIZE_TO_LIMIT.fetch(size) do
raise ArgumentError, "Unknown text size: #{size.inspect}. Use :tiny, :medium, or :long" raise ArgumentError, "Unknown text size: #{size.inspect}. Use :tiny, :medium, or :long"
end end
else elsif type == :text
options[:limit] ||= TEXT_DEFAULT_LIMIT options[:limit] ||= TEXT_DEFAULT_LIMIT
end end
end end