fix: 修复争议时间线表名映射

This commit is contained in:
zetaloop
2026-04-25 02:23:04 +08:00
parent 7a8788c62e
commit dc57a61688
3 changed files with 22 additions and 10 deletions
@@ -26,7 +26,7 @@ const (
// FieldCreatedAt holds the string denoting the created_at field in the database. // FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at" FieldCreatedAt = "created_at"
// Table holds the table name of the disputetimeline in the database. // Table holds the table name of the disputetimeline in the database.
Table = "dispute_timelines" Table = "dispute_timeline"
) )
// Columns holds all SQL columns for disputetimeline fields. // Columns holds all SQL columns for disputetimeline fields.
@@ -3,13 +3,14 @@
package migrate package migrate
import ( import (
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/dialect/sql/schema" "entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
) )
var ( var (
// DisputeTimelinesColumns holds the columns for the "dispute_timelines" table. // DisputeTimelineColumns holds the columns for the "dispute_timeline" table.
DisputeTimelinesColumns = []*schema.Column{ DisputeTimelineColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "dispute_id", Type: field.TypeInt64}, {Name: "dispute_id", Type: field.TypeInt64},
{Name: "event_type", Type: field.TypeString, Size: 30}, {Name: "event_type", Type: field.TypeString, Size: 30},
@@ -18,16 +19,16 @@ var (
{Name: "details", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "details", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}},
{Name: "created_at", Type: field.TypeTime}, {Name: "created_at", Type: field.TypeTime},
} }
// DisputeTimelinesTable holds the schema information for the "dispute_timelines" table. // DisputeTimelineTable holds the schema information for the "dispute_timeline" table.
DisputeTimelinesTable = &schema.Table{ DisputeTimelineTable = &schema.Table{
Name: "dispute_timelines", Name: "dispute_timeline",
Columns: DisputeTimelinesColumns, Columns: DisputeTimelineColumns,
PrimaryKey: []*schema.Column{DisputeTimelinesColumns[0]}, PrimaryKey: []*schema.Column{DisputeTimelineColumns[0]},
Indexes: []*schema.Index{ Indexes: []*schema.Index{
{ {
Name: "disputetimeline_dispute_id_created_at", Name: "disputetimeline_dispute_id_created_at",
Unique: false, Unique: false,
Columns: []*schema.Column{DisputeTimelinesColumns[1], DisputeTimelinesColumns[6]}, Columns: []*schema.Column{DisputeTimelineColumns[1], DisputeTimelineColumns[6]},
}, },
}, },
} }
@@ -86,10 +87,13 @@ var (
} }
// Tables holds all the tables in the schema. // Tables holds all the tables in the schema.
Tables = []*schema.Table{ Tables = []*schema.Table{
DisputeTimelinesTable, DisputeTimelineTable,
DisputesTable, DisputesTable,
} }
) )
func init() { func init() {
DisputeTimelineTable.Annotation = &entsql.Annotation{
Table: "dispute_timeline",
}
} }
@@ -5,6 +5,8 @@ import (
"entgo.io/ent" "entgo.io/ent"
"entgo.io/ent/dialect" "entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
"entgo.io/ent/schema/index" "entgo.io/ent/schema/index"
) )
@@ -13,6 +15,12 @@ type DisputeTimeline struct {
ent.Schema ent.Schema
} }
func (DisputeTimeline) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Table("dispute_timeline"),
}
}
func (DisputeTimeline) Fields() []ent.Field { func (DisputeTimeline) Fields() []ent.Field {
return []ent.Field{ return []ent.Field{
field.Int64("id").Unique().Immutable(), field.Int64("id").Unique().Immutable(),