-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(db) workflow table with events (#121)
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package models | ||
|
||
import "gorm.io/gorm" | ||
|
||
type WorkflowStatus string | ||
|
||
type Event struct { | ||
gorm.Model | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
ServiceID uint `gorm:"foreignKey:ServiceID" json:"service_id"` | ||
Parameters []Parameters `json:"parameters"` | ||
Type EventType `gorm:"type:enum('action', 'reaction');not null" json:"type"` | ||
} | ||
|
||
const ( | ||
WorkflowStatusPending WorkflowStatus = "pending" | ||
WorkflowStatusProcessed WorkflowStatus = "processed" | ||
WorkflowStatusFailed WorkflowStatus = "failed" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package models | ||
|
||
import "gorm.io/gorm" | ||
|
||
type Service struct { | ||
gorm.Model | ||
Label string `json:"label"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package models | ||
|
||
import "gorm.io/gorm" | ||
|
||
type EventType string | ||
|
||
const ( | ||
ActionEventType EventType = "action" | ||
ReactionEventType EventType = "reaction" | ||
) | ||
|
||
type Parameters struct { | ||
gorm.Model | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
Type string `json:"type"` | ||
EventID uint `gorm:"foreignKey:EventID" json:"event_id"` | ||
} | ||
|
||
type Workflow struct { | ||
gorm.Model | ||
UserID uint `gorm:"foreignKey:UserID" json:"user_id"` | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
Status WorkflowStatus `gorm:"type:enum('pending', 'processed', 'failed')" json:"status"` | ||
Events []Event `gorm:"many2many:workflow_events" json:"events"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters