Browse Source

fix: orm index

Yeuoly 10 months ago
parent
commit
8c0ac3a001

+ 0 - 1
internal/types/models/curd/atomic.go

@@ -75,7 +75,6 @@ func CreatePlugin(
 			PluginID:               plugin_to_be_returns.PluginID,
 			PluginUniqueIdentifier: plugin_to_be_returns.PluginUniqueIdentifier,
 			TenantID:               tenant_id,
-			UserID:                 user_id,
 		}
 
 		err = db.Create(installation, tx)

+ 7 - 7
internal/types/models/endpoint.go

@@ -9,13 +9,13 @@ import (
 // HookID is a pointer to plugin id and tenant id, using it to identify the endpoint plugin
 type Endpoint struct {
 	Model
-	HookID    string    `json:"hook_id" orm:"uniqueIndex;size:127;column:hook_id"`
-	TenantID  string    `json:"tenant_id" orm:"index;size:64;column:tenant_id"`
-	UserID    string    `json:"user_id" orm:"index;size:64;column:user_id"`
-	PluginID  string    `json:"plugin_id" orm:"index;size:64;column:plugin_id"`
-	ExpiredAt time.Time `json:"expired_at" orm:"column:expired_at"`
-	Enabled   bool      `json:"enabled" orm:"column:enabled"`
-	Settings  string    `json:"settings" orm:"column:settings;size:2048"`
+	HookID    string    `json:"hook_id" gorm:"unique;size:127;column:hook_id"`
+	TenantID  string    `json:"tenant_id" gorm:"index;size:64;column:tenant_id"`
+	UserID    string    `json:"user_id" gorm:"index;size:64;column:user_id"`
+	PluginID  string    `json:"plugin_id" gorm:"index;size:64;column:plugin_id"`
+	ExpiredAt time.Time `json:"expired_at" gorm:"column:expired_at"`
+	Enabled   bool      `json:"enabled" gorm:"column:enabled"`
+	Settings  string    `json:"settings" gorm:"column:settings;size:2048"`
 }
 
 func (e *Endpoint) GetSettings() map[string]any {

+ 6 - 5
internal/types/models/installation.go

@@ -1,15 +1,16 @@
 package models
 
-import "encoding/json"
+import (
+	"encoding/json"
+)
 
 type PluginInstallationStatus string
 
 type PluginInstallation struct {
 	Model
-	TenantID               string `json:"tenant_id" orm:"index;type:uuid;"`
-	UserID                 string `json:"user_id" orm:"index;type:uuid;"`
-	PluginID               string `json:"plugin_id" orm:"index;size:127"`
-	PluginUniqueIdentifier string `json:"plugin_unique_identifier" orm:"index;size:127"`
+	TenantID               string `json:"tenant_id" gorm:"index;type:uuid;"`
+	PluginID               string `json:"plugin_id" gorm:"index;size:127"`
+	PluginUniqueIdentifier string `json:"plugin_unique_identifier" gorm:"index;size:127"`
 	Config                 string `json:"config"`
 }
 

+ 12 - 12
internal/types/models/plugin.go

@@ -8,13 +8,13 @@ import (
 type Plugin struct {
 	Model
 	// PluginUniqueIdentifier is a unique identifier for the plugin, it contains version and checksum
-	PluginUniqueIdentifier string `json:"plugin_unique_identifier" orm:"index;size:127"`
+	PluginUniqueIdentifier string `json:"plugin_unique_identifier" gorm:"index;size:127"`
 	// PluginID is the id of the plugin, only plugin name is considered
-	PluginID     string                            `json:"id" orm:"index;size:127"`
-	Refers       int                               `json:"refers" orm:"default:0"`
-	InstallType  plugin_entities.PluginRuntimeType `json:"install_type" orm:"size:127;index"`
-	ManifestType plugin_entities.DifyManifestType  `json:"manifest_type" orm:"size:127"`
-	Declaration  string                            `json:"declaration" orm:"type:text;size:65535"`
+	PluginID     string                            `json:"id" gorm:"index;size:127"`
+	Refers       int                               `json:"refers" gorm:"default:0"`
+	InstallType  plugin_entities.PluginRuntimeType `json:"install_type" gorm:"size:127;index"`
+	ManifestType plugin_entities.DifyManifestType  `json:"manifest_type" gorm:"size:127"`
+	Declaration  string                            `json:"declaration" gorm:"type:text;size:65535"`
 }
 
 func (p *Plugin) GetDeclaration() (*plugin_entities.PluginDeclaration, error) {
@@ -34,12 +34,12 @@ const (
 
 type ServerlessRuntime struct {
 	Model
-	PluginUniqueIdentifier string                `json:"plugin_unique_identifier" orm:"index;size:127"`
-	FunctionURL            string                `json:"function_url" orm:"size:255"`
-	FunctionName           string                `json:"function_name" orm:"size:127"`
-	Type                   ServerlessRuntimeType `json:"type" orm:"size:127"`
-	Declaration            string                `json:"declaration" orm:"type:text;size:65535"`
-	Checksum               string                `json:"checksum" orm:"size:127"`
+	PluginUniqueIdentifier string                `json:"plugin_unique_identifier" gorm:"size:127;unique"`
+	FunctionURL            string                `json:"function_url" gorm:"size:255"`
+	FunctionName           string                `json:"function_name" gorm:"size:127"`
+	Type                   ServerlessRuntimeType `json:"type" gorm:"size:127"`
+	Declaration            string                `json:"declaration" gorm:"type:text;size:65535"`
+	Checksum               string                `json:"checksum" gorm:"size:127;index"`
 }
 
 func (p *ServerlessRuntime) GetDeclaration() (*plugin_entities.PluginDeclaration, error) {