I'm very new to triggers, so I suspect I've done something naive.
When a row is inserted into a table, I want populate a 'date' column with
the date 45 days hence. I've created a trigger:
CREATE TRIGGER `test`.`setExpiryDate` BEFORE INSERT ON `test`.`mysql_auth`
FOR EACH ROW SET NEW.expires = curdate()+interval 45 day
It works, doing what I want, but I get the following error:
Warning: #1265 Data truncated for column 'expires' at row 1
The table is:
CREATE TABLE `mysql_auth` (
`id` int(11) NOT NULL auto_increment,
`user` varchar(25) NOT NULL,
`password` varchar(32) NOT NULL,
`expires` date NOT NULL,
`login_failures` int(11) NOT NULL default '0',
`last_login_failure` datetime default NULL,
PRIMARY KEY (`id`)
)
Can someone help me understand what it happening here, and how to fix it?
Thanks