Describe the bug

当我的数据表中timestamp类型字段设置默认值为null时,再次使用auto migration 失败。

To Reproduce

Steps to reproduce the behavior: 1. 数据表DDL:

CREATE TABLE `api_token` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `uuid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `expiration_time` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  1. 使用cwgo model 生成 api_token.gen.go 文件中数据表的对应的定义为
type APIToken struct {
    ID            int64  `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
    UUID          string `gorm:"column:uuid;type:varchar(50);not null" json:"uuid"`
    ExpirationTime  time.Time `gorm:"column:expiration_time;type:timestamp" json:"expiration_time"`
    CreatedAt       time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
    UpdatedAt       time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
}
  1. 再次使用 migration 在新环境下创建数据表失败: 错误信息:Error 1067 (42000): Invalid default value for 'expiration_time',

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: Darrell-Neo

hello @xuanskyer, could you try to see if either of these two solutions work?

  1. Change ExpirationTime in the APIToken struct to:
ExpirationTime  *time.Time `gorm:"column:expiration_time;type:timestamp;default:null" json:"expiration_time"`
  1. Change ExpirationTime in the APIToken struct to:
ExpirationTime  time.Time `gorm:"column:expiration_time;type:timestamp;default:null" json:"expiration_time"`

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking