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

Add new database Table and schema for wf_requests #1932

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aliraza556 I don't think NEW is a status.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elraphty, for now NEW is a valid state this will be the default state before we send to stakwork. When stakwork sends back a project_id then we can update it to PENDING. I and @humansinstitute agreed to this, but if you have a better status name that will be nice we just came up with that on the fly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Okay bro, will merge now.

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
Loading