From 1947a11dae7e370d96c7e1b3362ed1e332f99587 Mon Sep 17 00:00:00 2001 From: Igor Zalutski Date: Fri, 4 Oct 2024 18:11:41 +0100 Subject: [PATCH] Remove IsAcknowledged, use status instead --- ee/drift/controllers/ci_jobs.go | 9 +++--- ee/drift/model/org_settings.gen.go | 5 ++-- ee/drift/model/projects.gen.go | 1 - ee/drift/model/users.gen.go | 20 +++++++------ ee/drift/models_generated/org_settings.gen.go | 14 +++++---- ee/drift/models_generated/projects.gen.go | 6 +--- ee/drift/models_generated/users.gen.go | 30 ++++++++++++------- 7 files changed, 48 insertions(+), 37 deletions(-) diff --git a/ee/drift/controllers/ci_jobs.go b/ee/drift/controllers/ci_jobs.go index 41d9d0a94..d7077dd6a 100644 --- a/ee/drift/controllers/ci_jobs.go +++ b/ee/drift/controllers/ci_jobs.go @@ -1,13 +1,14 @@ package controllers import ( + "log" + "net/http" + "time" + "github.com/diggerhq/digger/ee/drift/dbmodels" "github.com/diggerhq/digger/ee/drift/model" "github.com/diggerhq/digger/libs/terraform_utils" "github.com/gin-gonic/gin" - "log" - "net/http" - "time" ) type SetJobStatusRequest struct { @@ -119,7 +120,7 @@ func ProjectDriftStateMachineApply(project model.Project, tfplan string, resourc } if !isEmptyPlan && !wasEmptyPlan { if project.DriftTerraformPlan != tfplan { - if project.IsAcknowledged { + if project.DriftStatus == dbmodels.DriftStatusAcknowledgeDrift { project.DriftStatus = dbmodels.DriftStatusNewDrift } } diff --git a/ee/drift/model/org_settings.gen.go b/ee/drift/model/org_settings.gen.go index b539ccbb9..760d1588c 100644 --- a/ee/drift/model/org_settings.gen.go +++ b/ee/drift/model/org_settings.gen.go @@ -12,12 +12,13 @@ const TableNameOrgSetting = "org_settings" // OrgSetting mapped from table type OrgSetting struct { - ID int64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` CreatedAt time.Time `gorm:"column:created_at;not null;default:now()" json:"created_at"` ScheduleType string `gorm:"column:schedule_type" json:"schedule_type"` Schedule string `gorm:"column:schedule" json:"schedule"` SlackNotificationURL string `gorm:"column:slack_notification_url" json:"slack_notification_url"` - OrgID string `gorm:"column:org_id;not null" json:"org_id"` + OrgID string `gorm:"column:org_id" json:"org_id"` + ExternalOrgID string `gorm:"column:external_org_id" json:"external_org_id"` + ID string `gorm:"column:id;primaryKey;default:gen_random_uuid()" json:"id"` } // TableName OrgSetting's table name diff --git a/ee/drift/model/projects.gen.go b/ee/drift/model/projects.gen.go index cc7f2d310..3add734a7 100644 --- a/ee/drift/model/projects.gen.go +++ b/ee/drift/model/projects.gen.go @@ -27,7 +27,6 @@ type Project struct { ToUpdate int32 `gorm:"column:to_update" json:"to_update"` ToCreate int32 `gorm:"column:to_create" json:"to_create"` ToDelete int32 `gorm:"column:to_delete" json:"to_delete"` - IsAcknowledged bool `gorm:"column:is_acknowledged;not null" json:"is_acknowledged"` } // TableName Project's table name diff --git a/ee/drift/model/users.gen.go b/ee/drift/model/users.gen.go index e171f3d91..1c6d87f72 100644 --- a/ee/drift/model/users.gen.go +++ b/ee/drift/model/users.gen.go @@ -14,15 +14,17 @@ const TableNameUser = "users" // User mapped from table type User struct { - ID string `gorm:"column:id;primaryKey;default:uuid_generate_v4()" json:"id"` - CreatedAt time.Time `gorm:"column:created_at" json:"created_at"` - UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"` - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"` - Email string `gorm:"column:email;not null" json:"email"` - OrganisationID string `gorm:"column:organisation_id" json:"organisation_id"` - ExternalID string `gorm:"column:external_id" json:"external_id"` - FirstName string `gorm:"column:first_name" json:"first_name"` - LastName string `gorm:"column:last_name" json:"last_name"` + ID string `gorm:"column:id;primaryKey;default:uuid_generate_v4()" json:"id"` + CreatedAt time.Time `gorm:"column:created_at" json:"created_at"` + UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"` + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"` + Email string `gorm:"column:email;not null" json:"email"` + OrganisationID string `gorm:"column:organisation_id" json:"organisation_id"` + ExternalID string `gorm:"column:external_id" json:"external_id"` + FirstName string `gorm:"column:first_name" json:"first_name"` + LastName string `gorm:"column:last_name" json:"last_name"` + StripeCustomerID string `gorm:"column:stripe_customer_id" json:"stripe_customer_id"` + IsPaying bool `gorm:"column:is_paying" json:"is_paying"` } // TableName User's table name diff --git a/ee/drift/models_generated/org_settings.gen.go b/ee/drift/models_generated/org_settings.gen.go index f61f2f82e..b3f5ce61b 100644 --- a/ee/drift/models_generated/org_settings.gen.go +++ b/ee/drift/models_generated/org_settings.gen.go @@ -27,12 +27,13 @@ func newOrgSetting(db *gorm.DB, opts ...gen.DOOption) orgSetting { tableName := _orgSetting.orgSettingDo.TableName() _orgSetting.ALL = field.NewAsterisk(tableName) - _orgSetting.ID = field.NewInt64(tableName, "id") _orgSetting.CreatedAt = field.NewTime(tableName, "created_at") _orgSetting.ScheduleType = field.NewString(tableName, "schedule_type") _orgSetting.Schedule = field.NewString(tableName, "schedule") _orgSetting.SlackNotificationURL = field.NewString(tableName, "slack_notification_url") _orgSetting.OrgID = field.NewString(tableName, "org_id") + _orgSetting.ExternalOrgID = field.NewString(tableName, "external_org_id") + _orgSetting.ID = field.NewString(tableName, "id") _orgSetting.fillFieldMap() @@ -43,12 +44,13 @@ type orgSetting struct { orgSettingDo ALL field.Asterisk - ID field.Int64 CreatedAt field.Time ScheduleType field.String Schedule field.String SlackNotificationURL field.String OrgID field.String + ExternalOrgID field.String + ID field.String fieldMap map[string]field.Expr } @@ -65,12 +67,13 @@ func (o orgSetting) As(alias string) *orgSetting { func (o *orgSetting) updateTableName(table string) *orgSetting { o.ALL = field.NewAsterisk(table) - o.ID = field.NewInt64(table, "id") o.CreatedAt = field.NewTime(table, "created_at") o.ScheduleType = field.NewString(table, "schedule_type") o.Schedule = field.NewString(table, "schedule") o.SlackNotificationURL = field.NewString(table, "slack_notification_url") o.OrgID = field.NewString(table, "org_id") + o.ExternalOrgID = field.NewString(table, "external_org_id") + o.ID = field.NewString(table, "id") o.fillFieldMap() @@ -87,13 +90,14 @@ func (o *orgSetting) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (o *orgSetting) fillFieldMap() { - o.fieldMap = make(map[string]field.Expr, 6) - o.fieldMap["id"] = o.ID + o.fieldMap = make(map[string]field.Expr, 7) o.fieldMap["created_at"] = o.CreatedAt o.fieldMap["schedule_type"] = o.ScheduleType o.fieldMap["schedule"] = o.Schedule o.fieldMap["slack_notification_url"] = o.SlackNotificationURL o.fieldMap["org_id"] = o.OrgID + o.fieldMap["external_org_id"] = o.ExternalOrgID + o.fieldMap["id"] = o.ID } func (o orgSetting) clone(db *gorm.DB) orgSetting { diff --git a/ee/drift/models_generated/projects.gen.go b/ee/drift/models_generated/projects.gen.go index de575c203..83faf17a8 100644 --- a/ee/drift/models_generated/projects.gen.go +++ b/ee/drift/models_generated/projects.gen.go @@ -40,7 +40,6 @@ func newProject(db *gorm.DB, opts ...gen.DOOption) project { _project.ToUpdate = field.NewInt32(tableName, "to_update") _project.ToCreate = field.NewInt32(tableName, "to_create") _project.ToDelete = field.NewInt32(tableName, "to_delete") - _project.IsAcknowledged = field.NewBool(tableName, "is_acknowledged") _project.fillFieldMap() @@ -64,7 +63,6 @@ type project struct { ToUpdate field.Int32 ToCreate field.Int32 ToDelete field.Int32 - IsAcknowledged field.Bool fieldMap map[string]field.Expr } @@ -94,7 +92,6 @@ func (p *project) updateTableName(table string) *project { p.ToUpdate = field.NewInt32(table, "to_update") p.ToCreate = field.NewInt32(table, "to_create") p.ToDelete = field.NewInt32(table, "to_delete") - p.IsAcknowledged = field.NewBool(table, "is_acknowledged") p.fillFieldMap() @@ -111,7 +108,7 @@ func (p *project) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (p *project) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 14) + p.fieldMap = make(map[string]field.Expr, 13) p.fieldMap["id"] = p.ID p.fieldMap["created_at"] = p.CreatedAt p.fieldMap["updated_at"] = p.UpdatedAt @@ -125,7 +122,6 @@ func (p *project) fillFieldMap() { p.fieldMap["to_update"] = p.ToUpdate p.fieldMap["to_create"] = p.ToCreate p.fieldMap["to_delete"] = p.ToDelete - p.fieldMap["is_acknowledged"] = p.IsAcknowledged } func (p project) clone(db *gorm.DB) project { diff --git a/ee/drift/models_generated/users.gen.go b/ee/drift/models_generated/users.gen.go index 0cfc80088..15c28bbc5 100644 --- a/ee/drift/models_generated/users.gen.go +++ b/ee/drift/models_generated/users.gen.go @@ -36,6 +36,8 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user { _user.ExternalID = field.NewString(tableName, "external_id") _user.FirstName = field.NewString(tableName, "first_name") _user.LastName = field.NewString(tableName, "last_name") + _user.StripeCustomerID = field.NewString(tableName, "stripe_customer_id") + _user.IsPaying = field.NewBool(tableName, "is_paying") _user.fillFieldMap() @@ -45,16 +47,18 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user { type user struct { userDo - ALL field.Asterisk - ID field.String - CreatedAt field.Time - UpdatedAt field.Time - DeletedAt field.Field - Email field.String - OrganisationID field.String - ExternalID field.String - FirstName field.String - LastName field.String + ALL field.Asterisk + ID field.String + CreatedAt field.Time + UpdatedAt field.Time + DeletedAt field.Field + Email field.String + OrganisationID field.String + ExternalID field.String + FirstName field.String + LastName field.String + StripeCustomerID field.String + IsPaying field.Bool fieldMap map[string]field.Expr } @@ -80,6 +84,8 @@ func (u *user) updateTableName(table string) *user { u.ExternalID = field.NewString(table, "external_id") u.FirstName = field.NewString(table, "first_name") u.LastName = field.NewString(table, "last_name") + u.StripeCustomerID = field.NewString(table, "stripe_customer_id") + u.IsPaying = field.NewBool(table, "is_paying") u.fillFieldMap() @@ -96,7 +102,7 @@ func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (u *user) fillFieldMap() { - u.fieldMap = make(map[string]field.Expr, 9) + u.fieldMap = make(map[string]field.Expr, 11) u.fieldMap["id"] = u.ID u.fieldMap["created_at"] = u.CreatedAt u.fieldMap["updated_at"] = u.UpdatedAt @@ -106,6 +112,8 @@ func (u *user) fillFieldMap() { u.fieldMap["external_id"] = u.ExternalID u.fieldMap["first_name"] = u.FirstName u.fieldMap["last_name"] = u.LastName + u.fieldMap["stripe_customer_id"] = u.StripeCustomerID + u.fieldMap["is_paying"] = u.IsPaying } func (u user) clone(db *gorm.DB) user {