You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Worker and Status fields in the CronJobLock struct currently have gorm:"not null;default:null". Setting null as a default for NOT NULL fields leads to migration errors in MySQL because MySQL doesn’t support null as a default for NOT NULL columns.
To make this compatible with MySQL and similar databases, these fields should be updated to use an empty string ('') as the default. This will allow migrations to run smoothly without encountering Invalid default value errors.
Additional context
2024/10/28 09:29:11 failed to migrate database: Error 1067 (42000): Invalid default value for 'worker'
cybereyes-sunny
changed the title
[BUG] - Please add descriptive title
[BUG] - MySQL doesn’t treat null as a valid default for NOT NULL fields
Oct 28, 2024
Describe the bug
Update Worker and Status Fields in CronJobLock to Use Compatible Default Values
To Reproduce
Steps to reproduce the behavior:
follow the example and exec:
db.AutoMigrate(&gormlock.CronJobLock{})
Version
github.com/go-co-op/gocron-gorm-lock v1.0.0
Expected behavior
The Worker and Status fields in the CronJobLock struct currently have gorm:"not null;default:null". Setting null as a default for NOT NULL fields leads to migration errors in MySQL because MySQL doesn’t support null as a default for NOT NULL columns.
To make this compatible with MySQL and similar databases, these fields should be updated to use an empty string ('') as the default. This will allow migrations to run smoothly without encountering Invalid default value errors.
Additional context
2024/10/28 09:29:11 failed to migrate database: Error 1067 (42000): Invalid default value for 'worker'
gocron-gorm-lock/job_lock_struct.go
Line 18 in 1a90c83
gocron-gorm-lock/job_lock_struct.go
Line 19 in 1a90c83
The text was updated successfully, but these errors were encountered: