Files
juwan-backend/app/shop/rpc/internal/models/migrate/schema.go
T
2026-03-31 22:12:06 +08:00

132 lines
4.9 KiB
Go

// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// ShopInvitationsColumns holds the columns for the "shop_invitations" table.
ShopInvitationsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "shop_id", Type: field.TypeInt64},
{Name: "player_id", Type: field.TypeInt64},
{Name: "status", Type: field.TypeString, Size: 20, Default: "pending"},
{Name: "invited_by", Type: field.TypeInt64},
{Name: "created_at", Type: field.TypeTime},
{Name: "responded_at", Type: field.TypeTime, Nullable: true},
}
// ShopInvitationsTable holds the schema information for the "shop_invitations" table.
ShopInvitationsTable = &schema.Table{
Name: "shop_invitations",
Columns: ShopInvitationsColumns,
PrimaryKey: []*schema.Column{ShopInvitationsColumns[0]},
Indexes: []*schema.Index{
{
Name: "shopinvitations_shop_id",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[1]},
},
{
Name: "shopinvitations_player_id",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[2]},
},
{
Name: "shopinvitations_player_id_status_created_at",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[2], ShopInvitationsColumns[3], ShopInvitationsColumns[5]},
},
{
Name: "shopinvitations_shop_id_status_created_at",
Unique: false,
Columns: []*schema.Column{ShopInvitationsColumns[1], ShopInvitationsColumns[3], ShopInvitationsColumns[5]},
},
},
}
// ShopPlayersColumns holds the columns for the "shop_players" table.
ShopPlayersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "shop_id", Type: field.TypeInt64},
{Name: "player_id", Type: field.TypeInt64},
{Name: "is_primary", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "joined_at", Type: field.TypeTime},
{Name: "left_at", Type: field.TypeTime, Nullable: true},
}
// ShopPlayersTable holds the schema information for the "shop_players" table.
ShopPlayersTable = &schema.Table{
Name: "shop_players",
Columns: ShopPlayersColumns,
PrimaryKey: []*schema.Column{ShopPlayersColumns[0]},
Indexes: []*schema.Index{
{
Name: "shopplayers_shop_id_player_id",
Unique: true,
Columns: []*schema.Column{ShopPlayersColumns[1], ShopPlayersColumns[2]},
},
{
Name: "shopplayers_player_id",
Unique: false,
Columns: []*schema.Column{ShopPlayersColumns[2]},
},
{
Name: "shopplayers_shop_id_joined_at",
Unique: false,
Columns: []*schema.Column{ShopPlayersColumns[1], ShopPlayersColumns[4]},
},
},
}
// ShopsColumns holds the columns for the "shops" table.
ShopsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "owner_id", Type: field.TypeInt64, Unique: true},
{Name: "name", Type: field.TypeString, Size: 200},
{Name: "banner", Type: field.TypeString, Nullable: true},
{Name: "description", Type: field.TypeString, Nullable: true},
{Name: "rating", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(3,2)"}},
{Name: "total_orders", Type: field.TypeInt, Nullable: true, Default: 0},
{Name: "player_count", Type: field.TypeInt, Nullable: true, Default: 0},
{Name: "commission_type", Type: field.TypeString, Size: 20, Default: "percentage"},
{Name: "commission_value", Type: field.TypeOther, SchemaType: map[string]string{"postgres": "decimal(10,2)"}},
{Name: "allow_multi_shop", Type: field.TypeBool, Nullable: true, Default: false},
{Name: "allow_independent_orders", Type: field.TypeBool, Nullable: true, Default: true},
{Name: "dispatch_mode", Type: field.TypeString, Size: 20, Default: "manual"},
{Name: "announcements", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"postgres": "text[]"}},
{Name: "template_config", Type: field.TypeJSON, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
}
// ShopsTable holds the schema information for the "shops" table.
ShopsTable = &schema.Table{
Name: "shops",
Columns: ShopsColumns,
PrimaryKey: []*schema.Column{ShopsColumns[0]},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
ShopInvitationsTable,
ShopPlayersTable,
ShopsTable,
}
)
func init() {
ShopInvitationsTable.Annotation = &entsql.Annotation{
Table: "shop_invitations",
}
ShopInvitationsTable.Annotation.Checks = map[string]string{
"chk_invitation_status": "status IN ('pending', 'accepted', 'rejected', 'cancelled')",
}
ShopsTable.Annotation = &entsql.Annotation{
Table: "shops",
}
ShopsTable.Annotation.Checks = map[string]string{
"chk_commission_type": "commission_type IN ('fixed', 'percentage')",
"chk_dispatch_mode": "dispatch_mode IN ('manual', 'auto')",
"chk_rating_range": "rating >= 0 AND rating <= 5",
}
}