From cd95820ff9e1b99910d9009d165562ab953822a9 Mon Sep 17 00:00:00 2001 From: Bogdans Ozerkins Date: Mon, 14 Aug 2023 19:59:04 -0700 Subject: [PATCH 1/2] fix model migration --- cmd/argo-watcher/state/state_models/task_model.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/argo-watcher/state/state_models/task_model.go b/cmd/argo-watcher/state/state_models/task_model.go index 27b3ee59..4d22461a 100644 --- a/cmd/argo-watcher/state/state_models/task_model.go +++ b/cmd/argo-watcher/state/state_models/task_model.go @@ -12,12 +12,12 @@ import ( type TaskModel struct { Id uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid()"` Created time.Time `gorm:"column:created;autoCreateTime;not null;index;"` - Updated time.Time `gorm:"column:updated;autoUpdateTime;not null;"` + Updated time.Time `gorm:"column:updated;autoUpdateTime;"` Images datatypes.JSONSlice[models.Image] `gorm:"column:images;not null;"` Status string `gorm:"column:status;type:VARCHAR(20);not null;index;"` - ApplicationName sql.NullString `gorm:"column:app;type:VARCHAR(255);not null;"` - Author sql.NullString `gorm:"column:author;type:VARCHAR(255);not null;"` - Project sql.NullString `gorm:"column:project;type:VARCHAR(255);not null;"` + ApplicationName sql.NullString `gorm:"column:app;type:VARCHAR(255);"` + Author sql.NullString `gorm:"column:author;type:VARCHAR(255);"` + Project sql.NullString `gorm:"column:project;type:VARCHAR(255);"` StatusReason sql.NullString `gorm:"column:status_reason;default:''"` } From 43050befbbf1e16201a84be0a21be7e25acb9bba Mon Sep 17 00:00:00 2001 From: Bogdans Ozerkins Date: Mon, 14 Aug 2023 20:04:28 -0700 Subject: [PATCH 2/2] default empty string triggers alter table on start --- cmd/argo-watcher/state/state_models/task_model.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/argo-watcher/state/state_models/task_model.go b/cmd/argo-watcher/state/state_models/task_model.go index 4d22461a..b14275f6 100644 --- a/cmd/argo-watcher/state/state_models/task_model.go +++ b/cmd/argo-watcher/state/state_models/task_model.go @@ -18,7 +18,7 @@ type TaskModel struct { ApplicationName sql.NullString `gorm:"column:app;type:VARCHAR(255);"` Author sql.NullString `gorm:"column:author;type:VARCHAR(255);"` Project sql.NullString `gorm:"column:project;type:VARCHAR(255);"` - StatusReason sql.NullString `gorm:"column:status_reason;default:''"` + StatusReason sql.NullString `gorm:"column:status_reason;"` } func (TaskModel) TableName() string {