edrisranjbar / qurandl

Quran Download
MIT License
4 stars 1 forks source link

Update on user migration table #35

Closed imranertaza closed 1 year ago

imranertaza commented 1 year ago

I have updated a status field in the user table.

edrisranjbar commented 1 year ago

Hi @imranertaza , Thanks for adding status field for users table, I prefer having isActive field as a boolean; I think that is cleaner. Can you make the changes and re-do the PR?

Thanks bro 👍🏻

imranertaza commented 1 year ago

Hi yes, I have made the changes as you said. I added an isActive field with the boolean type and default value 1. Here default value 1 = active. Please check it and let me know if there is anything that needs to change.

Now, just for the understanding, please. As you know when we set the boolean type. Mysql takes it as tinyint(1) type. where we can use 1 = Active and 0 = Inactive. This is correct. But as MySQL uses tinyint(1), other values can be inserted into this field that does not make any sense. Like we can insert 2,3,4,5 etc that does not make any sense.

On the other hand, if we use enum(1, 0) with default value 1, it will create a restriction and no other values will be inserted into this field except 0 and 1 where 0 = inactive and 1 = active. So it makes sense.

So my question is, it is that why we are going to use boolean/tinyint instead of enum? please share your logic with me. Thank you

edrisranjbar commented 1 year ago

Thanks for making the required changes. yes as per our need which is a boolean field for storing status of the account can be only active or inactive, boolean is a better approach in this case.