There is no such thing as tinyint(4)
in MySQL in the first place. tinyint
is a one byte signed integer. You can check all integer types in the docs. You may see something like tinyint(1)
even in the Rails source code, but I think it's a tautology as tinyint
already implies one byte storage.
The Rails way to declare TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT
in a migration is by using limit:
with the appropriate byte size as can be seen in the source code.
Beware that Rails will treat one-byte integers as booleans by default though, as can be seen from the above link.
tinyint
in the first place. It's overly-specific. I would venture to guess that it's actually LESS performant than using a plain integer field, as well. It might save you a negligible amount of space per-record, but I'm not even sure that's the case. I think you'd be hard-pressed to convince me that there was a reason to ever use it. – Popper