Skip to content

Commit

Permalink
Merge pull request stakwork#1932 from aliraza556/create-wf_requests-s…
Browse files Browse the repository at this point in the history
…chema-and-table

Add new database `Table` and schema for `wf_requests`
  • Loading branch information
elraphty authored Nov 12, 2024
2 parents 35936ca + ea10cf9 commit 92d3fa2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions db/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func InitDB() {
db.AutoMigrate(&WorkspaceFeatures{})
db.AutoMigrate(&FeaturePhase{})
db.AutoMigrate(&FeatureStory{})
db.AutoMigrate(&WfRequest{})

DB.MigrateTablesWithOrgUuid()
DB.MigrateOrganizationToWorkspace()
Expand Down
23 changes: 23 additions & 0 deletions db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,25 @@ type FilterStattuCount struct {
Failed int64 `json:"failed"`
}

type WfRequestStatus string

const (
StatusNew WfRequestStatus = "NEW"
StatusPending WfRequestStatus = "PENDING"
StatusCompleted WfRequestStatus = "COMPLETED"
StatusFailed WfRequestStatus = "FAILED"
)

type WfRequest struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
RequestID string `gorm:"unique;not null" json:"request_id"`
Status WfRequestStatus `json:"status"`
RequestData JSONB `gorm:"type:jsonb" json:"request_data"`
ResponseData JSONB `gorm:"type:jsonb" json:"response_data,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

func (Person) TableName() string {
return "people"
}
Expand Down Expand Up @@ -946,6 +965,10 @@ func (ConnectionCodesShort) TableName() string {
return "connectioncodes"
}

func (WfRequest) TableName() string {
return "wf_requests"
}

// PropertyMap ...
type PropertyMap map[string]interface{}

Expand Down
1 change: 1 addition & 0 deletions db/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func InitTestDB() {
db.AutoMigrate(&WorkspaceUsers{})
db.AutoMigrate(&WorkspaceUserRoles{})
db.AutoMigrate(&Bot{})
db.AutoMigrate(&WfRequest{})

people := TestDB.GetAllPeople()
for _, p := range people {
Expand Down

0 comments on commit 92d3fa2

Please sign in to comment.