mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-28 07:27:03 +08:00
fix: 修复 mcp tools 软删除定义问题
This commit is contained in:
1 parent
817585c7cd
commit
0a2ef10fb9
11 files changed
+341
-301
No files matched your search
@@ -2015,12 +2015,14 @@ func (c *MCPToolClient) QueryUpstream(_m *MCPTool) *MCPUpstreamQuery {
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *MCPToolClient) Hooks() []Hook {
|
||||
return c.hooks.MCPTool
|
||||
hooks := c.hooks.MCPTool
|
||||
return append(hooks[:len(hooks):len(hooks)], mcptool.Hooks[:]...)
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *MCPToolClient) Interceptors() []Interceptor {
|
||||
return c.inters.MCPTool
|
||||
inters := c.inters.MCPTool
|
||||
return append(inters[:len(inters):len(inters)], mcptool.Interceptors[:]...)
|
||||
}
|
||||
|
||||
func (c *MCPToolClient) mutate(ctx context.Context, m *MCPToolMutation) (Value, error) {
|
||||
|
||||
+12
-15
@@ -20,6 +20,8 @@ type MCPTool struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
// DeletedAt holds the value of the "deleted_at" field.
|
||||
DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// UpstreamID holds the value of the "upstream_id" field.
|
||||
UpstreamID uuid.UUID `json:"upstream_id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
@@ -42,8 +44,6 @@ type MCPTool struct {
|
||||
VersionHash string `json:"version_hash,omitempty"`
|
||||
// SyncedAt holds the value of the "synced_at" field.
|
||||
SyncedAt *time.Time `json:"synced_at,omitempty"`
|
||||
// DeletedAt holds the value of the "deleted_at" field.
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
@@ -89,7 +89,7 @@ func (*MCPTool) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case mcptool.FieldName, mcptool.FieldNamespacedName, mcptool.FieldScope, mcptool.FieldDescription, mcptool.FieldVersionHash:
|
||||
values[i] = new(sql.NullString)
|
||||
case mcptool.FieldSyncedAt, mcptool.FieldDeletedAt, mcptool.FieldCreatedAt, mcptool.FieldUpdatedAt:
|
||||
case mcptool.FieldDeletedAt, mcptool.FieldSyncedAt, mcptool.FieldCreatedAt, mcptool.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case mcptool.FieldID, mcptool.FieldUpstreamID:
|
||||
values[i] = new(uuid.UUID)
|
||||
@@ -114,6 +114,12 @@ func (_m *MCPTool) assignValues(columns []string, values []any) error {
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case mcptool.FieldDeletedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DeletedAt = value.Time
|
||||
}
|
||||
case mcptool.FieldUpstreamID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field upstream_id", values[i])
|
||||
@@ -184,13 +190,6 @@ func (_m *MCPTool) assignValues(columns []string, values []any) error {
|
||||
_m.SyncedAt = new(time.Time)
|
||||
*_m.SyncedAt = value.Time
|
||||
}
|
||||
case mcptool.FieldDeletedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DeletedAt = new(time.Time)
|
||||
*_m.DeletedAt = value.Time
|
||||
}
|
||||
case mcptool.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -244,6 +243,9 @@ func (_m *MCPTool) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("MCPTool(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(_m.DeletedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("upstream_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UpstreamID))
|
||||
builder.WriteString(", ")
|
||||
@@ -281,11 +283,6 @@ func (_m *MCPTool) String() string {
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.DeletedAt; v != nil {
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -15,6 +16,8 @@ const (
|
||||
Label = "mcp_tool"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
|
||||
FieldDeletedAt = "deleted_at"
|
||||
// FieldUpstreamID holds the string denoting the upstream_id field in the database.
|
||||
FieldUpstreamID = "upstream_id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
@@ -37,8 +40,6 @@ const (
|
||||
FieldVersionHash = "version_hash"
|
||||
// FieldSyncedAt holds the string denoting the synced_at field in the database.
|
||||
FieldSyncedAt = "synced_at"
|
||||
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
|
||||
FieldDeletedAt = "deleted_at"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
@@ -59,6 +60,7 @@ const (
|
||||
// Columns holds all SQL columns for mcptool fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldDeletedAt,
|
||||
FieldUpstreamID,
|
||||
FieldName,
|
||||
FieldNamespacedName,
|
||||
@@ -70,7 +72,6 @@ var Columns = []string{
|
||||
FieldEnabled,
|
||||
FieldVersionHash,
|
||||
FieldSyncedAt,
|
||||
FieldDeletedAt,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
@@ -85,7 +86,14 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "github.com/chaitin/MonkeyCode/backend/db/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
NameValidator func(string) error
|
||||
// NamespacedNameValidator is a validator for the "namespaced_name" field. It is called by the builders before save.
|
||||
@@ -135,6 +143,11 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDeletedAt orders the results by the deleted_at field.
|
||||
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpstreamID orders the results by the upstream_id field.
|
||||
func ByUpstreamID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpstreamID, opts...).ToFunc()
|
||||
@@ -185,11 +198,6 @@ func BySyncedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSyncedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDeletedAt orders the results by the deleted_at field.
|
||||
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
+55
-55
@@ -56,6 +56,11 @@ func IDLTE(id uuid.UUID) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
|
||||
func DeletedAt(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// UpstreamID applies equality check predicate on the "upstream_id" field. It's identical to UpstreamIDEQ.
|
||||
func UpstreamID(v uuid.UUID) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldUpstreamID, v))
|
||||
@@ -101,11 +106,6 @@ func SyncedAt(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldSyncedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
|
||||
func DeletedAt(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -116,6 +116,56 @@ func UpdatedAt(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
|
||||
func DeletedAtEQ(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
|
||||
func DeletedAtNEQ(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtIn applies the In predicate on the "deleted_at" field.
|
||||
func DeletedAtIn(vs ...time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldIn(FieldDeletedAt, vs...))
|
||||
}
|
||||
|
||||
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
|
||||
func DeletedAtNotIn(vs ...time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNotIn(FieldDeletedAt, vs...))
|
||||
}
|
||||
|
||||
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
|
||||
func DeletedAtGT(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldGT(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
|
||||
func DeletedAtGTE(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldGTE(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
|
||||
func DeletedAtLT(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldLT(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
|
||||
func DeletedAtLTE(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldLTE(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
|
||||
func DeletedAtIsNil() predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldIsNull(FieldDeletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
|
||||
func DeletedAtNotNil() predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNotNull(FieldDeletedAt))
|
||||
}
|
||||
|
||||
// UpstreamIDEQ applies the EQ predicate on the "upstream_id" field.
|
||||
func UpstreamIDEQ(v uuid.UUID) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldUpstreamID, v))
|
||||
@@ -596,56 +646,6 @@ func SyncedAtNotNil() predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNotNull(FieldSyncedAt))
|
||||
}
|
||||
|
||||
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
|
||||
func DeletedAtEQ(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
|
||||
func DeletedAtNEQ(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNEQ(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtIn applies the In predicate on the "deleted_at" field.
|
||||
func DeletedAtIn(vs ...time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldIn(FieldDeletedAt, vs...))
|
||||
}
|
||||
|
||||
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
|
||||
func DeletedAtNotIn(vs ...time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNotIn(FieldDeletedAt, vs...))
|
||||
}
|
||||
|
||||
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
|
||||
func DeletedAtGT(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldGT(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
|
||||
func DeletedAtGTE(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldGTE(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
|
||||
func DeletedAtLT(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldLT(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
|
||||
func DeletedAtLTE(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldLTE(FieldDeletedAt, v))
|
||||
}
|
||||
|
||||
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
|
||||
func DeletedAtIsNil() predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldIsNull(FieldDeletedAt))
|
||||
}
|
||||
|
||||
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
|
||||
func DeletedAtNotNil() predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldNotNull(FieldDeletedAt))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.MCPTool {
|
||||
return predicate.MCPTool(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -25,6 +25,20 @@ type MCPToolCreate struct {
|
||||
conflict []sql.ConflictOption
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (_c *MCPToolCreate) SetDeletedAt(v time.Time) *MCPToolCreate {
|
||||
_c.mutation.SetDeletedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||
func (_c *MCPToolCreate) SetNillableDeletedAt(v *time.Time) *MCPToolCreate {
|
||||
if v != nil {
|
||||
_c.SetDeletedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (_c *MCPToolCreate) SetUpstreamID(v uuid.UUID) *MCPToolCreate {
|
||||
_c.mutation.SetUpstreamID(v)
|
||||
@@ -139,20 +153,6 @@ func (_c *MCPToolCreate) SetNillableSyncedAt(v *time.Time) *MCPToolCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (_c *MCPToolCreate) SetDeletedAt(v time.Time) *MCPToolCreate {
|
||||
_c.mutation.SetDeletedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||
func (_c *MCPToolCreate) SetNillableDeletedAt(v *time.Time) *MCPToolCreate {
|
||||
if v != nil {
|
||||
_c.SetDeletedAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *MCPToolCreate) SetCreatedAt(v time.Time) *MCPToolCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -199,7 +199,9 @@ func (_c *MCPToolCreate) Mutation() *MCPToolMutation {
|
||||
|
||||
// Save creates the MCPTool in the database.
|
||||
func (_c *MCPToolCreate) Save(ctx context.Context) (*MCPTool, error) {
|
||||
_c.defaults()
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
@@ -226,7 +228,7 @@ func (_c *MCPToolCreate) ExecX(ctx context.Context) {
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *MCPToolCreate) defaults() {
|
||||
func (_c *MCPToolCreate) defaults() error {
|
||||
if _, ok := _c.mutation.Price(); !ok {
|
||||
v := mcptool.DefaultPrice
|
||||
_c.mutation.SetPrice(v)
|
||||
@@ -236,13 +238,20 @@ func (_c *MCPToolCreate) defaults() {
|
||||
_c.mutation.SetEnabled(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
if mcptool.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("db: uninitialized mcptool.DefaultCreatedAt (forgotten import db/runtime?)")
|
||||
}
|
||||
v := mcptool.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
if mcptool.DefaultUpdatedAt == nil {
|
||||
return fmt.Errorf("db: uninitialized mcptool.DefaultUpdatedAt (forgotten import db/runtime?)")
|
||||
}
|
||||
v := mcptool.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -330,6 +339,10 @@ func (_c *MCPToolCreate) createSpec() (*MCPTool, *sqlgraph.CreateSpec) {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.DeletedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
||||
_node.DeletedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(mcptool.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
@@ -370,10 +383,6 @@ func (_c *MCPToolCreate) createSpec() (*MCPTool, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(mcptool.FieldSyncedAt, field.TypeTime, value)
|
||||
_node.SyncedAt = &value
|
||||
}
|
||||
if value, ok := _c.mutation.DeletedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
||||
_node.DeletedAt = &value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
@@ -406,7 +415,7 @@ func (_c *MCPToolCreate) createSpec() (*MCPTool, *sqlgraph.CreateSpec) {
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.MCPTool.Create().
|
||||
// SetUpstreamID(v).
|
||||
// SetDeletedAt(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -415,7 +424,7 @@ func (_c *MCPToolCreate) createSpec() (*MCPTool, *sqlgraph.CreateSpec) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.MCPToolUpsert) {
|
||||
// SetUpstreamID(v+v).
|
||||
// SetDeletedAt(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *MCPToolCreate) OnConflict(opts ...sql.ConflictOption) *MCPToolUpsertOne {
|
||||
@@ -451,6 +460,24 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (u *MCPToolUpsert) SetDeletedAt(v time.Time) *MCPToolUpsert {
|
||||
u.Set(mcptool.FieldDeletedAt, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||
func (u *MCPToolUpsert) UpdateDeletedAt() *MCPToolUpsert {
|
||||
u.SetExcluded(mcptool.FieldDeletedAt)
|
||||
return u
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (u *MCPToolUpsert) ClearDeletedAt() *MCPToolUpsert {
|
||||
u.SetNull(mcptool.FieldDeletedAt)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (u *MCPToolUpsert) SetUpstreamID(v uuid.UUID) *MCPToolUpsert {
|
||||
u.Set(mcptool.FieldUpstreamID, v)
|
||||
@@ -619,24 +646,6 @@ func (u *MCPToolUpsert) ClearSyncedAt() *MCPToolUpsert {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (u *MCPToolUpsert) SetDeletedAt(v time.Time) *MCPToolUpsert {
|
||||
u.Set(mcptool.FieldDeletedAt, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||
func (u *MCPToolUpsert) UpdateDeletedAt() *MCPToolUpsert {
|
||||
u.SetExcluded(mcptool.FieldDeletedAt)
|
||||
return u
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (u *MCPToolUpsert) ClearDeletedAt() *MCPToolUpsert {
|
||||
u.SetNull(mcptool.FieldDeletedAt)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (u *MCPToolUpsert) SetCreatedAt(v time.Time) *MCPToolUpsert {
|
||||
u.Set(mcptool.FieldCreatedAt, v)
|
||||
@@ -709,6 +718,27 @@ func (u *MCPToolUpsertOne) Update(set func(*MCPToolUpsert)) *MCPToolUpsertOne {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (u *MCPToolUpsertOne) SetDeletedAt(v time.Time) *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.SetDeletedAt(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||
func (u *MCPToolUpsertOne) UpdateDeletedAt() *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.UpdateDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (u *MCPToolUpsertOne) ClearDeletedAt() *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.ClearDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (u *MCPToolUpsertOne) SetUpstreamID(v uuid.UUID) *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
@@ -905,27 +935,6 @@ func (u *MCPToolUpsertOne) ClearSyncedAt() *MCPToolUpsertOne {
|
||||
})
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (u *MCPToolUpsertOne) SetDeletedAt(v time.Time) *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.SetDeletedAt(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||
func (u *MCPToolUpsertOne) UpdateDeletedAt() *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.UpdateDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (u *MCPToolUpsertOne) ClearDeletedAt() *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.ClearDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (u *MCPToolUpsertOne) SetCreatedAt(v time.Time) *MCPToolUpsertOne {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
@@ -1090,7 +1099,7 @@ func (_c *MCPToolCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.MCPToolUpsert) {
|
||||
// SetUpstreamID(v+v).
|
||||
// SetDeletedAt(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *MCPToolCreateBulk) OnConflict(opts ...sql.ConflictOption) *MCPToolUpsertBulk {
|
||||
@@ -1169,6 +1178,27 @@ func (u *MCPToolUpsertBulk) Update(set func(*MCPToolUpsert)) *MCPToolUpsertBulk
|
||||
return u
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (u *MCPToolUpsertBulk) SetDeletedAt(v time.Time) *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.SetDeletedAt(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||
func (u *MCPToolUpsertBulk) UpdateDeletedAt() *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.UpdateDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (u *MCPToolUpsertBulk) ClearDeletedAt() *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.ClearDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (u *MCPToolUpsertBulk) SetUpstreamID(v uuid.UUID) *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
@@ -1365,27 +1395,6 @@ func (u *MCPToolUpsertBulk) ClearSyncedAt() *MCPToolUpsertBulk {
|
||||
})
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (u *MCPToolUpsertBulk) SetDeletedAt(v time.Time) *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.SetDeletedAt(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
||||
func (u *MCPToolUpsertBulk) UpdateDeletedAt() *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.UpdateDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (u *MCPToolUpsertBulk) ClearDeletedAt() *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
s.ClearDeletedAt()
|
||||
})
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (u *MCPToolUpsertBulk) SetCreatedAt(v time.Time) *MCPToolUpsertBulk {
|
||||
return u.Update(func(s *MCPToolUpsert) {
|
||||
|
||||
@@ -302,12 +302,12 @@ func (_q *MCPToolQuery) WithUpstream(opts ...func(*MCPUpstreamQuery)) *MCPToolQu
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// UpstreamID uuid.UUID `json:"upstream_id,omitempty"`
|
||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.MCPTool.Query().
|
||||
// GroupBy(mcptool.FieldUpstreamID).
|
||||
// GroupBy(mcptool.FieldDeletedAt).
|
||||
// Aggregate(db.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *MCPToolQuery) GroupBy(field string, fields ...string) *MCPToolGroupBy {
|
||||
@@ -325,11 +325,11 @@ func (_q *MCPToolQuery) GroupBy(field string, fields ...string) *MCPToolGroupBy
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// UpstreamID uuid.UUID `json:"upstream_id,omitempty"`
|
||||
// DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.MCPTool.Query().
|
||||
// Select(mcptool.FieldUpstreamID).
|
||||
// Select(mcptool.FieldDeletedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *MCPToolQuery) Select(fields ...string) *MCPToolSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -31,6 +31,26 @@ func (_u *MCPToolUpdate) Where(ps ...predicate.MCPTool) *MCPToolUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (_u *MCPToolUpdate) SetDeletedAt(v time.Time) *MCPToolUpdate {
|
||||
_u.mutation.SetDeletedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||
func (_u *MCPToolUpdate) SetNillableDeletedAt(v *time.Time) *MCPToolUpdate {
|
||||
if v != nil {
|
||||
_u.SetDeletedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (_u *MCPToolUpdate) ClearDeletedAt() *MCPToolUpdate {
|
||||
_u.mutation.ClearDeletedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (_u *MCPToolUpdate) SetUpstreamID(v uuid.UUID) *MCPToolUpdate {
|
||||
_u.mutation.SetUpstreamID(v)
|
||||
@@ -214,26 +234,6 @@ func (_u *MCPToolUpdate) ClearSyncedAt() *MCPToolUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (_u *MCPToolUpdate) SetDeletedAt(v time.Time) *MCPToolUpdate {
|
||||
_u.mutation.SetDeletedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||
func (_u *MCPToolUpdate) SetNillableDeletedAt(v *time.Time) *MCPToolUpdate {
|
||||
if v != nil {
|
||||
_u.SetDeletedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (_u *MCPToolUpdate) ClearDeletedAt() *MCPToolUpdate {
|
||||
_u.mutation.ClearDeletedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *MCPToolUpdate) SetCreatedAt(v time.Time) *MCPToolUpdate {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
@@ -272,7 +272,9 @@ func (_u *MCPToolUpdate) ClearUpstream() *MCPToolUpdate {
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *MCPToolUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
if err := _u.defaults(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
@@ -299,11 +301,15 @@ func (_u *MCPToolUpdate) ExecX(ctx context.Context) {
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *MCPToolUpdate) defaults() {
|
||||
func (_u *MCPToolUpdate) defaults() error {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
if mcptool.UpdateDefaultUpdatedAt == nil {
|
||||
return fmt.Errorf("db: uninitialized mcptool.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
||||
}
|
||||
v := mcptool.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -352,6 +358,12 @@ func (_u *MCPToolUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.DeletedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.DeletedAtCleared() {
|
||||
_spec.ClearField(mcptool.FieldDeletedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(mcptool.FieldName, field.TypeString, value)
|
||||
}
|
||||
@@ -400,12 +412,6 @@ func (_u *MCPToolUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if _u.mutation.SyncedAtCleared() {
|
||||
_spec.ClearField(mcptool.FieldSyncedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.DeletedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.DeletedAtCleared() {
|
||||
_spec.ClearField(mcptool.FieldDeletedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
@@ -463,6 +469,26 @@ type MCPToolUpdateOne struct {
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (_u *MCPToolUpdateOne) SetDeletedAt(v time.Time) *MCPToolUpdateOne {
|
||||
_u.mutation.SetDeletedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||
func (_u *MCPToolUpdateOne) SetNillableDeletedAt(v *time.Time) *MCPToolUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDeletedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (_u *MCPToolUpdateOne) ClearDeletedAt() *MCPToolUpdateOne {
|
||||
_u.mutation.ClearDeletedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (_u *MCPToolUpdateOne) SetUpstreamID(v uuid.UUID) *MCPToolUpdateOne {
|
||||
_u.mutation.SetUpstreamID(v)
|
||||
@@ -646,26 +672,6 @@ func (_u *MCPToolUpdateOne) ClearSyncedAt() *MCPToolUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (_u *MCPToolUpdateOne) SetDeletedAt(v time.Time) *MCPToolUpdateOne {
|
||||
_u.mutation.SetDeletedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
||||
func (_u *MCPToolUpdateOne) SetNillableDeletedAt(v *time.Time) *MCPToolUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDeletedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (_u *MCPToolUpdateOne) ClearDeletedAt() *MCPToolUpdateOne {
|
||||
_u.mutation.ClearDeletedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_u *MCPToolUpdateOne) SetCreatedAt(v time.Time) *MCPToolUpdateOne {
|
||||
_u.mutation.SetCreatedAt(v)
|
||||
@@ -717,7 +723,9 @@ func (_u *MCPToolUpdateOne) Select(field string, fields ...string) *MCPToolUpdat
|
||||
|
||||
// Save executes the query and returns the updated MCPTool entity.
|
||||
func (_u *MCPToolUpdateOne) Save(ctx context.Context) (*MCPTool, error) {
|
||||
_u.defaults()
|
||||
if err := _u.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
@@ -744,11 +752,15 @@ func (_u *MCPToolUpdateOne) ExecX(ctx context.Context) {
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *MCPToolUpdateOne) defaults() {
|
||||
func (_u *MCPToolUpdateOne) defaults() error {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
if mcptool.UpdateDefaultUpdatedAt == nil {
|
||||
return fmt.Errorf("db: uninitialized mcptool.UpdateDefaultUpdatedAt (forgotten import db/runtime?)")
|
||||
}
|
||||
v := mcptool.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
@@ -814,6 +826,12 @@ func (_u *MCPToolUpdateOne) sqlSave(ctx context.Context) (_node *MCPTool, err er
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.DeletedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.DeletedAtCleared() {
|
||||
_spec.ClearField(mcptool.FieldDeletedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(mcptool.FieldName, field.TypeString, value)
|
||||
}
|
||||
@@ -862,12 +880,6 @@ func (_u *MCPToolUpdateOne) sqlSave(ctx context.Context) (_node *MCPTool, err er
|
||||
if _u.mutation.SyncedAtCleared() {
|
||||
_spec.ClearField(mcptool.FieldSyncedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.DeletedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldDeletedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.DeletedAtCleared() {
|
||||
_spec.ClearField(mcptool.FieldDeletedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(mcptool.FieldCreatedAt, field.TypeTime, value)
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ var (
|
||||
// McpToolsColumns holds the columns for the "mcp_tools" table.
|
||||
McpToolsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID, Unique: true},
|
||||
{Name: "deleted_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "name", Type: field.TypeString, Size: 256},
|
||||
{Name: "namespaced_name", Type: field.TypeString, Size: 320},
|
||||
{Name: "scope", Type: field.TypeEnum, Enums: []string{"user", "platform"}},
|
||||
@@ -223,7 +224,6 @@ var (
|
||||
{Name: "enabled", Type: field.TypeBool, Default: true},
|
||||
{Name: "version_hash", Type: field.TypeString, Nullable: true, Size: 64},
|
||||
{Name: "synced_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "deleted_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "upstream_id", Type: field.TypeUUID},
|
||||
@@ -245,7 +245,7 @@ var (
|
||||
{
|
||||
Name: "mcptool_scope_user_id_namespaced_name",
|
||||
Unique: true,
|
||||
Columns: []*schema.Column{McpToolsColumns[3], McpToolsColumns[4], McpToolsColumns[2]},
|
||||
Columns: []*schema.Column{McpToolsColumns[4], McpToolsColumns[5], McpToolsColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+73
-73
@@ -7774,6 +7774,7 @@ type MCPToolMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *uuid.UUID
|
||||
deleted_at *time.Time
|
||||
name *string
|
||||
namespaced_name *string
|
||||
scope *mcptool.Scope
|
||||
@@ -7785,7 +7786,6 @@ type MCPToolMutation struct {
|
||||
enabled *bool
|
||||
version_hash *string
|
||||
synced_at *time.Time
|
||||
deleted_at *time.Time
|
||||
created_at *time.Time
|
||||
updated_at *time.Time
|
||||
clearedFields map[string]struct{}
|
||||
@@ -7900,6 +7900,55 @@ func (m *MCPToolMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (m *MCPToolMutation) SetDeletedAt(t time.Time) {
|
||||
m.deleted_at = &t
|
||||
}
|
||||
|
||||
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
||||
func (m *MCPToolMutation) DeletedAt() (r time.Time, exists bool) {
|
||||
v := m.deleted_at
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldDeletedAt returns the old "deleted_at" field's value of the MCPTool entity.
|
||||
// If the MCPTool object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *MCPToolMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
||||
}
|
||||
return oldValue.DeletedAt, nil
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (m *MCPToolMutation) ClearDeletedAt() {
|
||||
m.deleted_at = nil
|
||||
m.clearedFields[mcptool.FieldDeletedAt] = struct{}{}
|
||||
}
|
||||
|
||||
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
||||
func (m *MCPToolMutation) DeletedAtCleared() bool {
|
||||
_, ok := m.clearedFields[mcptool.FieldDeletedAt]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
||||
func (m *MCPToolMutation) ResetDeletedAt() {
|
||||
m.deleted_at = nil
|
||||
delete(m.clearedFields, mcptool.FieldDeletedAt)
|
||||
}
|
||||
|
||||
// SetUpstreamID sets the "upstream_id" field.
|
||||
func (m *MCPToolMutation) SetUpstreamID(u uuid.UUID) {
|
||||
m.upstream = &u
|
||||
@@ -8381,55 +8430,6 @@ func (m *MCPToolMutation) ResetSyncedAt() {
|
||||
delete(m.clearedFields, mcptool.FieldSyncedAt)
|
||||
}
|
||||
|
||||
// SetDeletedAt sets the "deleted_at" field.
|
||||
func (m *MCPToolMutation) SetDeletedAt(t time.Time) {
|
||||
m.deleted_at = &t
|
||||
}
|
||||
|
||||
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
||||
func (m *MCPToolMutation) DeletedAt() (r time.Time, exists bool) {
|
||||
v := m.deleted_at
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldDeletedAt returns the old "deleted_at" field's value of the MCPTool entity.
|
||||
// If the MCPTool object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *MCPToolMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
||||
}
|
||||
return oldValue.DeletedAt, nil
|
||||
}
|
||||
|
||||
// ClearDeletedAt clears the value of the "deleted_at" field.
|
||||
func (m *MCPToolMutation) ClearDeletedAt() {
|
||||
m.deleted_at = nil
|
||||
m.clearedFields[mcptool.FieldDeletedAt] = struct{}{}
|
||||
}
|
||||
|
||||
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
||||
func (m *MCPToolMutation) DeletedAtCleared() bool {
|
||||
_, ok := m.clearedFields[mcptool.FieldDeletedAt]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
||||
func (m *MCPToolMutation) ResetDeletedAt() {
|
||||
m.deleted_at = nil
|
||||
delete(m.clearedFields, mcptool.FieldDeletedAt)
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *MCPToolMutation) SetCreatedAt(t time.Time) {
|
||||
m.created_at = &t
|
||||
@@ -8564,6 +8564,9 @@ func (m *MCPToolMutation) Type() string {
|
||||
// AddedFields().
|
||||
func (m *MCPToolMutation) Fields() []string {
|
||||
fields := make([]string, 0, 14)
|
||||
if m.deleted_at != nil {
|
||||
fields = append(fields, mcptool.FieldDeletedAt)
|
||||
}
|
||||
if m.upstream != nil {
|
||||
fields = append(fields, mcptool.FieldUpstreamID)
|
||||
}
|
||||
@@ -8597,9 +8600,6 @@ func (m *MCPToolMutation) Fields() []string {
|
||||
if m.synced_at != nil {
|
||||
fields = append(fields, mcptool.FieldSyncedAt)
|
||||
}
|
||||
if m.deleted_at != nil {
|
||||
fields = append(fields, mcptool.FieldDeletedAt)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, mcptool.FieldCreatedAt)
|
||||
}
|
||||
@@ -8614,6 +8614,8 @@ func (m *MCPToolMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *MCPToolMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case mcptool.FieldDeletedAt:
|
||||
return m.DeletedAt()
|
||||
case mcptool.FieldUpstreamID:
|
||||
return m.UpstreamID()
|
||||
case mcptool.FieldName:
|
||||
@@ -8636,8 +8638,6 @@ func (m *MCPToolMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.VersionHash()
|
||||
case mcptool.FieldSyncedAt:
|
||||
return m.SyncedAt()
|
||||
case mcptool.FieldDeletedAt:
|
||||
return m.DeletedAt()
|
||||
case mcptool.FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
case mcptool.FieldUpdatedAt:
|
||||
@@ -8651,6 +8651,8 @@ func (m *MCPToolMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *MCPToolMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case mcptool.FieldDeletedAt:
|
||||
return m.OldDeletedAt(ctx)
|
||||
case mcptool.FieldUpstreamID:
|
||||
return m.OldUpstreamID(ctx)
|
||||
case mcptool.FieldName:
|
||||
@@ -8673,8 +8675,6 @@ func (m *MCPToolMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
return m.OldVersionHash(ctx)
|
||||
case mcptool.FieldSyncedAt:
|
||||
return m.OldSyncedAt(ctx)
|
||||
case mcptool.FieldDeletedAt:
|
||||
return m.OldDeletedAt(ctx)
|
||||
case mcptool.FieldCreatedAt:
|
||||
return m.OldCreatedAt(ctx)
|
||||
case mcptool.FieldUpdatedAt:
|
||||
@@ -8688,6 +8688,13 @@ func (m *MCPToolMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
// type.
|
||||
func (m *MCPToolMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case mcptool.FieldDeletedAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetDeletedAt(v)
|
||||
return nil
|
||||
case mcptool.FieldUpstreamID:
|
||||
v, ok := value.(uuid.UUID)
|
||||
if !ok {
|
||||
@@ -8765,13 +8772,6 @@ func (m *MCPToolMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetSyncedAt(v)
|
||||
return nil
|
||||
case mcptool.FieldDeletedAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetDeletedAt(v)
|
||||
return nil
|
||||
case mcptool.FieldCreatedAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
@@ -8831,6 +8831,9 @@ func (m *MCPToolMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *MCPToolMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(mcptool.FieldDeletedAt) {
|
||||
fields = append(fields, mcptool.FieldDeletedAt)
|
||||
}
|
||||
if m.FieldCleared(mcptool.FieldUserID) {
|
||||
fields = append(fields, mcptool.FieldUserID)
|
||||
}
|
||||
@@ -8846,9 +8849,6 @@ func (m *MCPToolMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(mcptool.FieldSyncedAt) {
|
||||
fields = append(fields, mcptool.FieldSyncedAt)
|
||||
}
|
||||
if m.FieldCleared(mcptool.FieldDeletedAt) {
|
||||
fields = append(fields, mcptool.FieldDeletedAt)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -8863,6 +8863,9 @@ func (m *MCPToolMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *MCPToolMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case mcptool.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
case mcptool.FieldUserID:
|
||||
m.ClearUserID()
|
||||
return nil
|
||||
@@ -8878,9 +8881,6 @@ func (m *MCPToolMutation) ClearField(name string) error {
|
||||
case mcptool.FieldSyncedAt:
|
||||
m.ClearSyncedAt()
|
||||
return nil
|
||||
case mcptool.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown MCPTool nullable field %s", name)
|
||||
}
|
||||
@@ -8889,6 +8889,9 @@ func (m *MCPToolMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *MCPToolMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case mcptool.FieldDeletedAt:
|
||||
m.ResetDeletedAt()
|
||||
return nil
|
||||
case mcptool.FieldUpstreamID:
|
||||
m.ResetUpstreamID()
|
||||
return nil
|
||||
@@ -8922,9 +8925,6 @@ func (m *MCPToolMutation) ResetField(name string) error {
|
||||
case mcptool.FieldSyncedAt:
|
||||
m.ResetSyncedAt()
|
||||
return nil
|
||||
case mcptool.FieldDeletedAt:
|
||||
m.ResetDeletedAt()
|
||||
return nil
|
||||
case mcptool.FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
|
||||
@@ -148,6 +148,11 @@ func init() {
|
||||
image.DefaultUpdatedAt = imageDescUpdatedAt.Default.(func() time.Time)
|
||||
// image.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
image.UpdateDefaultUpdatedAt = imageDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
mcptoolMixin := schema.MCPTool{}.Mixin()
|
||||
mcptoolMixinHooks0 := mcptoolMixin[0].Hooks()
|
||||
mcptool.Hooks[0] = mcptoolMixinHooks0[0]
|
||||
mcptoolMixinInters0 := mcptoolMixin[0].Interceptors()
|
||||
mcptool.Interceptors[0] = mcptoolMixinInters0[0]
|
||||
mcptoolFields := schema.MCPTool{}.Fields()
|
||||
_ = mcptoolFields
|
||||
// mcptoolDescName is the schema descriptor for name field.
|
||||
@@ -199,11 +204,11 @@ func init() {
|
||||
// mcptool.VersionHashValidator is a validator for the "version_hash" field. It is called by the builders before save.
|
||||
mcptool.VersionHashValidator = mcptoolDescVersionHash.Validators[0].(func(string) error)
|
||||
// mcptoolDescCreatedAt is the schema descriptor for created_at field.
|
||||
mcptoolDescCreatedAt := mcptoolFields[13].Descriptor()
|
||||
mcptoolDescCreatedAt := mcptoolFields[12].Descriptor()
|
||||
// mcptool.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
mcptool.DefaultCreatedAt = mcptoolDescCreatedAt.Default.(func() time.Time)
|
||||
// mcptoolDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
mcptoolDescUpdatedAt := mcptoolFields[14].Descriptor()
|
||||
mcptoolDescUpdatedAt := mcptoolFields[13].Descriptor()
|
||||
// mcptool.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
mcptool.DefaultUpdatedAt = mcptoolDescUpdatedAt.Default.(func() time.Time)
|
||||
// mcptool.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/chaitin/MonkeyCode/backend/pkg/entx"
|
||||
)
|
||||
|
||||
type MCPTool struct {
|
||||
@@ -22,6 +24,12 @@ func (MCPTool) Annotations() []schema.Annotation {
|
||||
}
|
||||
}
|
||||
|
||||
func (MCPTool) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
entx.SoftDeleteMixin2{},
|
||||
}
|
||||
}
|
||||
|
||||
func (MCPTool) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.UUID("id", uuid.UUID{}).Unique(),
|
||||
@@ -36,7 +44,6 @@ func (MCPTool) Fields() []ent.Field {
|
||||
field.Bool("enabled").Default(true),
|
||||
field.String("version_hash").Optional().MaxLen(64),
|
||||
field.Time("synced_at").Optional().Nillable(),
|
||||
field.Time("deleted_at").Optional().Nillable(),
|
||||
field.Time("created_at").Default(time.Now),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user