I have a situation where we store the value of credits a user has in the database:
`credits` DOUBLE(22,2) UNSIGNED NOT NULL DEFAULT '0.00',
The credits are numbers going from 1 to any positive value. But now there is a situation where we want to deduct credits monthly from users, and I see a situation where users may have 0 credits at the time of the SQL query.
What are the best practices to handle this? I know that allowing negative numbers can create lots of bugs and exploits but we really need to implement something this
So example: Every last day of month we will deduct -1 credit from all users. I use mariadb 10.6.11 but can upgrade to a later version if that helps
DEFAULT '0.00'is at least strange. What are the best practices to handle this? Define this column as SIGNED. and add according CHECK constraint.