Quellcode durchsuchen

move gh webhook to standalone table

Ian Edwards vor 2 Jahren
Ursprung
Commit
60709fbb59

+ 25 - 0
internal/models/github_webhook.go

@@ -0,0 +1,25 @@
+package models
+
+import (
+	"github.com/google/uuid"
+	"gorm.io/gorm"
+)
+
+type GithhubWebhook struct {
+	gorm.Model
+
+	// ID is a UUID for the Revision
+	ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
+
+	// ClusterID is the ID of the cluster that the webhook is associated with.
+	ClusterID int
+
+	// ProjectID is the ID of the project that the webhook is associated with.
+	ProjectID int
+
+	// PorterAppID is the ID of the PorterApp that the webhook is associated with.
+	PorterAppID int
+
+	// GithubWebhookID is the ID of the webhook provided by Github.
+	GithubWebhookID int64
+}

+ 3 - 4
internal/models/porter_app.go

@@ -18,10 +18,9 @@ type PorterApp struct {
 	ImageRepoURI string
 
 	// Git repo information (optional)
-	GitRepoID       uint
-	RepoName        string
-	GitBranch       string
-	GithubWebhookID int64 `gorm:"-"` // do not use in read/writes. this is temporary until migrations are run
+	GitRepoID uint
+	RepoName  string
+	GitBranch string
 
 	BuildContext   string
 	Builder        string

+ 1 - 0
internal/repository/gorm/migrate.go

@@ -65,6 +65,7 @@ func AutoMigrate(db *gorm.DB, debug bool) error {
 		&models.AppRevision{},
 		&models.DeploymentTarget{},
 		&models.AppTemplate{},
+		&models.GithhubWebhook{},
 		&ints.KubeIntegration{},
 		&ints.BasicIntegration{},
 		&ints.OIDCIntegration{},