Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sql version manage api and model #2612

Merged
merged 8 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions sqle/model/sql_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package model

import "time"

type SqlVersion struct {
Model
VersionNumber string `json:"version_number" gorm:"type:varchar(255) not null"`
iwanghc marked this conversation as resolved.
Show resolved Hide resolved
Desc string `json:"desc" gorm:"type:varchar(512)"`
Status string `json:"status" gorm:"type:varchar(255)"`
LockTime *time.Time `json:"lock_time" gorm:"type:datetime(3)"`
IsLocked bool `json:"is_locked" gorm:"type:bool" example:"false"`
iwanghc marked this conversation as resolved.
Show resolved Hide resolved
ProjectId ProjectUID `gorm:"index; not null"`
iwanghc marked this conversation as resolved.
Show resolved Hide resolved

SqlVersionStage []*SqlVersionStage
}

type SqlVersionStage struct {
Model
SqlVersionID uint `json:"sql_version_id" gorm:"not null"`
Name string `json:"name" gorm:"type:varchar(255) not null"`
StageSequence int `json:"stage_sequence" gorm:"type:int not null"`

SqlVersionStagesDependency []*SqlVersionStagesDependency
WorkflowReleaseStage []*WorkflowReleaseStage
}

type SqlVersionStagesDependency struct {
Model
SqlVersionStageID uint `json:"sql_version_stage_id" gorm:"not null"`
NextStageID uint `json:"next_stage_id"`
StageInstanceID uint `json:"stage_instance_id" gorm:"not null"`
NextStageInstanceID uint `json:"next_stage_instance_id"`
}

type WorkflowReleaseStage struct {
Model
WorkflowID string `json:"workflow_id" gorm:"not null"`
SqlVersionStageID uint `json:"sql_version_stage_id"`
WorkflowSequence int `json:" workflow_sequence" gorm:"type:int"`

Workflow *Workflow `gorm:"foreignkey:WorkflowID"`
}
4 changes: 4 additions & 0 deletions sqle/model/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ var autoMigrateList = []interface{}{
&SQLManageQueue{},
&ReportPushConfig{},
&ReportPushConfigRecord{},
&SqlVersion{},
&SqlVersionStage{},
&SqlVersionStagesDependency{},
&WorkflowReleaseStage{},
iwanghc marked this conversation as resolved.
Show resolved Hide resolved
}

func (s *Storage) AutoMigrate() error {
Expand Down