Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.32k stars 591 forks source link

Tinyint wrong conversion to boolean #174

Open JoaoPortella opened 5 years ago

JoaoPortella commented 5 years ago

The tinyint field is being converted to boolean when it should be tinyInteger.

Excellent tool! thank you!

cacpmw commented 5 years ago

Are you using mysql? In mysql if you define a column as tinyint(1) this is how it handles boolean and therefore it will be converted to boolean on the migration file.

JoaoPortella commented 5 years ago

@cacpmw thank you! Yes. I use tinyint not to save boolean data, but numbers from 1 to 10. And tinyInteger is available in Laravel schemas.

theWebKeyGuy commented 5 years ago

@JoaoPortella Then if you are using tinyint(1) shouldn't you only be able to do 0-9?...

JoaoPortella commented 5 years ago

@theWebKeyGuy I did not try to use as boolean, just changed to tinyint

plweller3 commented 4 years ago

Joao is correct - this is a nasty bug.

Just because Laravel maps boolean to tinyint in MySQL, one should not assume that ALL tinyint fields in MySql are meant to be booleans. It is common practice to use one as a signed status field where the range of values are below 100.