migrate

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WithGlobalUniqueID sets the universal ids options to the migration.
	// If this option is enabled, ent migration will allocate a 1<<32 range
	// for the ids of each entity (table).
	// Note that this option cannot be applied on tables that already exist.
	WithGlobalUniqueID = schema.WithGlobalUniqueID
	// WithDropColumn sets the drop column option to the migration.
	// If this option is enabled, ent migration will drop old columns
	// that were used for both fields and edges. This defaults to false.
	WithDropColumn = schema.WithDropColumn
	// WithDropIndex sets the drop index option to the migration.
	// If this option is enabled, ent migration will drop old indexes
	// that were defined in the schema. This defaults to false.
	// Note that unique constraints are defined using `UNIQUE INDEX`,
	// and therefore, it's recommended to enable this option to get more
	// flexibility in the schema changes.
	WithDropIndex = schema.WithDropIndex
	// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
	WithForeignKeys = schema.WithForeignKeys
)
View Source
var (
	// AdsColumns holds the columns for the "ads" table.
	AdsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "广告ID"},
		{Name: "title", Type: field.TypeString, Size: 255, Comment: "广告标题", Default: ""},
		{Name: "type", Type: field.TypeString, Size: 255, Comment: "广告类型", Default: ""},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "广告内容"},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "广告描述"},
		{Name: "target_url", Type: field.TypeString, Size: 512, Comment: "广告目标链接", Default: ""},
		{Name: "start_time", Type: field.TypeTime, Comment: "广告开始时间"},
		{Name: "end_time", Type: field.TypeTime, Comment: "广告结束时间"},
		{Name: "status", Type: field.TypeInt, Comment: "广告状态,0禁用,1启用", Default: 0},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// AdsTable holds the schema information for the "ads" table.
	AdsTable = &schema.Table{
		Name:       "ads",
		Columns:    AdsColumns,
		PrimaryKey: []*schema.Column{AdsColumns[0]},
	}
	// AnnouncementColumns holds the columns for the "announcement" table.
	AnnouncementColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "公告ID"},
		{Name: "title", Type: field.TypeString, Size: 255, Comment: "公告标题", Default: ""},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "公告内容"},
		{Name: "show", Type: field.TypeBool, Comment: "是否显示", Default: false},
		{Name: "pinned", Type: field.TypeBool, Comment: "是否置顶", Default: false},
		{Name: "popup", Type: field.TypeBool, Comment: "是否弹窗", Default: false},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// AnnouncementTable holds the schema information for the "announcement" table.
	AnnouncementTable = &schema.Table{
		Name:       "announcement",
		Columns:    AnnouncementColumns,
		PrimaryKey: []*schema.Column{AnnouncementColumns[0]},
	}
	// AuthMethodColumns holds the columns for the "auth_method" table.
	AuthMethodColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "认证方法ID"},
		{Name: "method", Type: field.TypeString, Size: 255, Comment: "认证方法", Default: ""},
		{Name: "config", Type: field.TypeString, Size: 2147483647, Comment: "OAuth配置"},
		{Name: "enabled", Type: field.TypeBool, Comment: "是否启用", Default: false},
		{Name: "created_at", Type: field.TypeTime, Nullable: true, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
	}
	// AuthMethodTable holds the schema information for the "auth_method" table.
	AuthMethodTable = &schema.Table{
		Name:       "auth_method",
		Columns:    AuthMethodColumns,
		PrimaryKey: []*schema.Column{AuthMethodColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "proxyauthmethod_method",
				Unique:  true,
				Columns: []*schema.Column{AuthMethodColumns[1]},
			},
		},
	}
	// CouponColumns holds the columns for the "coupon" table.
	CouponColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "优惠券ID"},
		{Name: "name", Type: field.TypeString, Size: 255, Comment: "优惠券名称", Default: ""},
		{Name: "code", Type: field.TypeString, Unique: true, Size: 255, Comment: "优惠券代码"},
		{Name: "count", Type: field.TypeInt32, Comment: "数量限制", Default: 0},
		{Name: "type", Type: field.TypeInt8, Comment: "优惠券类型:1:百分比 2:固定金额", Default: 1},
		{Name: "discount", Type: field.TypeInt64, Comment: "优惠券折扣", Default: 0},
		{Name: "start_time", Type: field.TypeInt64, Comment: "开始时间", Default: 0},
		{Name: "expire_time", Type: field.TypeInt64, Comment: "结束时间", Default: 0},
		{Name: "user_limit", Type: field.TypeInt64, Comment: "用户限制", Default: 0},
		{Name: "subscribe", Type: field.TypeString, Size: 255, Comment: "订阅限制", Default: ""},
		{Name: "used_count", Type: field.TypeInt8, Comment: "已使用次数", Default: 0},
		{Name: "enable", Type: field.TypeBool, Comment: "是否启用", Default: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// CouponTable holds the schema information for the "coupon" table.
	CouponTable = &schema.Table{
		Name:       "coupon",
		Columns:    CouponColumns,
		PrimaryKey: []*schema.Column{CouponColumns[0]},
	}
	// DocumentColumns holds the columns for the "document" table.
	DocumentColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "文档ID"},
		{Name: "title", Type: field.TypeString, Size: 255, Comment: "文档标题", Default: ""},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "文档内容"},
		{Name: "tags", Type: field.TypeString, Size: 255, Comment: "文档标签", Default: ""},
		{Name: "show", Type: field.TypeBool, Comment: "显示", Default: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// DocumentTable holds the schema information for the "document" table.
	DocumentTable = &schema.Table{
		Name:       "document",
		Columns:    DocumentColumns,
		PrimaryKey: []*schema.Column{DocumentColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "proxydocument_show",
				Unique:  false,
				Columns: []*schema.Column{DocumentColumns[4]},
			},
		},
	}
	// GroupHistoryColumns holds the columns for the "group_history" table.
	GroupHistoryColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "历史记录ID"},
		{Name: "group_mode", Type: field.TypeString, Size: 50, Comment: "分组模式", Default: ""},
		{Name: "trigger_type", Type: field.TypeString, Size: 50, Comment: "触发类型", Default: ""},
		{Name: "state", Type: field.TypeString, Size: 50, Comment: "状态", Default: ""},
		{Name: "total_users", Type: field.TypeInt, Comment: "总用户数", Default: 0},
		{Name: "success_count", Type: field.TypeInt, Comment: "成功数量", Default: 0},
		{Name: "failed_count", Type: field.TypeInt, Comment: "失败数量", Default: 0},
		{Name: "start_time", Type: field.TypeTime, Nullable: true, Comment: "开始时间"},
		{Name: "end_time", Type: field.TypeTime, Nullable: true, Comment: "结束时间"},
		{Name: "operator", Type: field.TypeString, Nullable: true, Size: 100, Comment: "操作人"},
		{Name: "error_message", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "错误信息"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
	}
	// GroupHistoryTable holds the schema information for the "group_history" table.
	GroupHistoryTable = &schema.Table{
		Name:       "group_history",
		Columns:    GroupHistoryColumns,
		PrimaryKey: []*schema.Column{GroupHistoryColumns[0]},
	}
	// GroupHistoryDetailColumns holds the columns for the "group_history_detail" table.
	GroupHistoryDetailColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "详情记录ID"},
		{Name: "history_id", Type: field.TypeInt64, Comment: "历史记录ID"},
		{Name: "node_group_id", Type: field.TypeInt64, Comment: "节点组ID"},
		{Name: "user_count", Type: field.TypeInt, Comment: "用户数量", Default: 0},
		{Name: "node_count", Type: field.TypeInt, Comment: "节点数量", Default: 0},
		{Name: "user_data", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "用户数据"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
	}
	// GroupHistoryDetailTable holds the schema information for the "group_history_detail" table.
	GroupHistoryDetailTable = &schema.Table{
		Name:       "group_history_detail",
		Columns:    GroupHistoryDetailColumns,
		PrimaryKey: []*schema.Column{GroupHistoryDetailColumns[0]},
	}
	// NodesColumns holds the columns for the "nodes" table.
	NodesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "节点ID"},
		{Name: "name", Type: field.TypeString, Size: 100, Comment: "节点名称", Default: ""},
		{Name: "tags", Type: field.TypeString, Size: 255, Comment: "标签", Default: ""},
		{Name: "port", Type: field.TypeUint16, Comment: "连接端口", Default: 0},
		{Name: "address", Type: field.TypeString, Size: 255, Comment: "连接地址", Default: ""},
		{Name: "server_id", Type: field.TypeInt64, Comment: "服务器ID", Default: 0},
		{Name: "protocol", Type: field.TypeString, Size: 100, Comment: "协议", Default: ""},
		{Name: "enabled", Type: field.TypeBool, Comment: "启用", Default: true},
		{Name: "node_type", Type: field.TypeString, Size: 20, Comment: "节点类型", Default: "landing"},
		{Name: "is_hidden", Type: field.TypeBool, Comment: "是否隐藏", Default: false},
		{Name: "sort", Type: field.TypeInt32, Comment: "排序", Default: 0},
		{Name: "node_group_ids", Type: field.TypeJSON, Nullable: true, Comment: "节点组ID列表"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// NodesTable holds the schema information for the "nodes" table.
	NodesTable = &schema.Table{
		Name:       "nodes",
		Columns:    NodesColumns,
		PrimaryKey: []*schema.Column{NodesColumns[0]},
	}
	// OrderColumns holds the columns for the "order" table.
	OrderColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "订单ID"},
		{Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "父订单ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID", Default: 0},
		{Name: "order_no", Type: field.TypeString, Unique: true, Size: 255, Comment: "订单号"},
		{Name: "type", Type: field.TypeInt8, Comment: "订单类型", Default: 1},
		{Name: "quantity", Type: field.TypeInt32, Comment: "数量", Default: 1},
		{Name: "price", Type: field.TypeInt64, Comment: "原价", Default: 0},
		{Name: "amount", Type: field.TypeInt64, Comment: "实付金额", Default: 0},
		{Name: "gift_amount", Type: field.TypeInt64, Comment: "赠送金额", Default: 0},
		{Name: "discount", Type: field.TypeInt64, Comment: "折扣金额", Default: 0},
		{Name: "coupon", Type: field.TypeString, Nullable: true, Size: 255, Comment: "优惠券代码"},
		{Name: "coupon_discount", Type: field.TypeInt64, Comment: "优惠券折扣金额", Default: 0},
		{Name: "commission", Type: field.TypeInt64, Comment: "佣金金额", Default: 0},
		{Name: "payment_id", Type: field.TypeInt64, Comment: "支付方式ID", Default: 0},
		{Name: "method", Type: field.TypeString, Size: 255, Comment: "支付方式标识", Default: ""},
		{Name: "fee_amount", Type: field.TypeInt64, Comment: "手续费金额", Default: 0},
		{Name: "trade_no", Type: field.TypeString, Nullable: true, Size: 255, Comment: "第三方交易号"},
		{Name: "status", Type: field.TypeInt8, Comment: "订单状态", Default: 1},
		{Name: "subscribe_id", Type: field.TypeInt64, Comment: "关联订阅ID", Default: 0},
		{Name: "subscribe_token", Type: field.TypeString, Nullable: true, Size: 255, Comment: "续费订阅Token"},
		{Name: "is_new", Type: field.TypeBool, Comment: "是否新订单", Default: false},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// OrderTable holds the schema information for the "order" table.
	OrderTable = &schema.Table{
		Name:       "order",
		Columns:    OrderColumns,
		PrimaryKey: []*schema.Column{OrderColumns[0]},
	}
	// PaymentColumns holds the columns for the "payment" table.
	PaymentColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "支付ID"},
		{Name: "name", Type: field.TypeString, Size: 100, Comment: "支付名称", Default: ""},
		{Name: "platform", Type: field.TypeString, Size: 100, Comment: "支付平台"},
		{Name: "icon", Type: field.TypeString, Size: 255, Comment: "支付图标", Default: ""},
		{Name: "domain", Type: field.TypeString, Size: 255, Comment: "通知域名", Default: ""},
		{Name: "config", Type: field.TypeString, Size: 2147483647, Comment: "支付配置"},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "支付描述"},
		{Name: "fee_mode", Type: field.TypeUint, Comment: "费用模式", Default: 0},
		{Name: "fee_percent", Type: field.TypeInt64, Comment: "费用百分比", Default: 0},
		{Name: "fee_amount", Type: field.TypeInt64, Comment: "固定费用金额", Default: 0},
		{Name: "sort", Type: field.TypeInt32, Comment: "排序", Default: 0},
		{Name: "enable", Type: field.TypeBool, Comment: "是否启用", Default: false},
		{Name: "token", Type: field.TypeString, Unique: true, Size: 255, Comment: "支付令牌"},
	}
	// PaymentTable holds the schema information for the "payment" table.
	PaymentTable = &schema.Table{
		Name:       "payment",
		Columns:    PaymentColumns,
		PrimaryKey: []*schema.Column{PaymentColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "proxypayment_platform",
				Unique:  false,
				Columns: []*schema.Column{PaymentColumns[2]},
			},
			{
				Name:    "proxypayment_enable",
				Unique:  false,
				Columns: []*schema.Column{PaymentColumns[11]},
			},
		},
	}
	// RedemptionCodeColumns holds the columns for the "redemption_code" table.
	RedemptionCodeColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "兑换码ID"},
		{Name: "code", Type: field.TypeString, Unique: true, Size: 255, Comment: "兑换码"},
		{Name: "total_count", Type: field.TypeInt32, Comment: "总兑换次数", Default: 0},
		{Name: "used_count", Type: field.TypeInt32, Comment: "已使用次数", Default: 0},
		{Name: "subscribe_plan", Type: field.TypeInt64, Comment: "订阅套餐ID", Default: 0},
		{Name: "unit_time", Type: field.TypeString, Size: 50, Comment: "时间单位", Default: "month"},
		{Name: "quantity", Type: field.TypeInt32, Comment: "数量", Default: 1},
		{Name: "status", Type: field.TypeInt8, Comment: "状态", Default: 1},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "删除时间"},
	}
	// RedemptionCodeTable holds the schema information for the "redemption_code" table.
	RedemptionCodeTable = &schema.Table{
		Name:       "redemption_code",
		Columns:    RedemptionCodeColumns,
		PrimaryKey: []*schema.Column{RedemptionCodeColumns[0]},
	}
	// RedemptionRecordColumns holds the columns for the "redemption_record" table.
	RedemptionRecordColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "兑换记录ID"},
		{Name: "subscribe_id", Type: field.TypeInt64, Comment: "订阅ID"},
		{Name: "unit_time", Type: field.TypeString, Size: 50, Comment: "时间单位", Default: "month"},
		{Name: "quantity", Type: field.TypeInt32, Comment: "数量", Default: 1},
		{Name: "redeemed_at", Type: field.TypeTime, Comment: "兑换时间"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "redemption_code_id", Type: field.TypeInt64, Comment: "兑换码ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
	}
	// RedemptionRecordTable holds the schema information for the "redemption_record" table.
	RedemptionRecordTable = &schema.Table{
		Name:       "redemption_record",
		Columns:    RedemptionRecordColumns,
		PrimaryKey: []*schema.Column{RedemptionRecordColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "redemption_record_redemption_code_records",
				Columns:    []*schema.Column{RedemptionRecordColumns[6]},
				RefColumns: []*schema.Column{RedemptionCodeColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "redemption_record_user_redemption_records",
				Columns:    []*schema.Column{RedemptionRecordColumns[7]},
				RefColumns: []*schema.Column{UserColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// SchemaMigrationsColumns holds the columns for the "schema_migrations" table.
	SchemaMigrationsColumns = []*schema.Column{
		{Name: "version", Type: field.TypeInt64, Comment: "迁移版本号"},
		{Name: "dirty", Type: field.TypeBool, Comment: "是否脏数据"},
	}
	// SchemaMigrationsTable holds the schema information for the "schema_migrations" table.
	SchemaMigrationsTable = &schema.Table{
		Name:       "schema_migrations",
		Columns:    SchemaMigrationsColumns,
		PrimaryKey: []*schema.Column{SchemaMigrationsColumns[0]},
	}
	// ServersColumns holds the columns for the "servers" table.
	ServersColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "服务器ID"},
		{Name: "name", Type: field.TypeString, Size: 100, Comment: "服务器名称", Default: ""},
		{Name: "country", Type: field.TypeString, Size: 128, Comment: "国家", Default: ""},
		{Name: "city", Type: field.TypeString, Size: 128, Comment: "城市", Default: ""},
		{Name: "address", Type: field.TypeString, Size: 100, Comment: "服务器地址", Default: ""},
		{Name: "sort", Type: field.TypeInt32, Comment: "排序", Default: 0},
		{Name: "protocols", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "协议配置JSON"},
		{Name: "last_reported_at", Type: field.TypeTime, Nullable: true, Comment: "最后报告时间"},
		{Name: "longitude", Type: field.TypeString, Size: 50, Comment: "经度", Default: "0.0"},
		{Name: "latitude", Type: field.TypeString, Size: 50, Comment: "纬度", Default: "0.0"},
		{Name: "longitude_center", Type: field.TypeString, Size: 50, Comment: "中心经度", Default: "0.0"},
		{Name: "latitude_center", Type: field.TypeString, Size: 50, Comment: "中心纬度", Default: "0.0"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// ServersTable holds the schema information for the "servers" table.
	ServersTable = &schema.Table{
		Name:       "servers",
		Columns:    ServersColumns,
		PrimaryKey: []*schema.Column{ServersColumns[0]},
	}
	// NodeGroupColumns holds the columns for the "node_group" table.
	NodeGroupColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "name", Type: field.TypeString, Size: 255, Comment: "Group Name"},
		{Name: "group_type", Type: field.TypeString, Size: 32, Comment: "Node Group Type", Default: "common"},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 500, Comment: "Group Description"},
		{Name: "sort", Type: field.TypeInt, Comment: "Sort Order", Default: 0},
		{Name: "for_calculation", Type: field.TypeBool, Comment: "For Calculation", Default: true},
		{Name: "is_expired_group", Type: field.TypeBool, Comment: "Is Expired Group", Default: false},
		{Name: "expired_days_limit", Type: field.TypeInt, Comment: "Expired Days Limit", Default: 7},
		{Name: "max_traffic_gb_expired", Type: field.TypeInt64, Nullable: true, Comment: "Max Traffic GB for Expired Users"},
		{Name: "speed_limit", Type: field.TypeInt, Comment: "Speed Limit", Default: 0},
		{Name: "min_traffic_gb", Type: field.TypeInt64, Nullable: true, Comment: "Minimum Traffic"},
		{Name: "max_traffic_gb", Type: field.TypeInt64, Nullable: true, Comment: "Maximum Traffic"},
		{Name: "created_at", Type: field.TypeTime, Comment: "Creation Time"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time"},
	}
	// NodeGroupTable holds the schema information for the "node_group" table.
	NodeGroupTable = &schema.Table{
		Name:       "node_group",
		Columns:    NodeGroupColumns,
		PrimaryKey: []*schema.Column{NodeGroupColumns[0]},
	}
	// SubscribeColumns holds the columns for the "subscribe" table.
	SubscribeColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "订阅套餐ID"},
		{Name: "name", Type: field.TypeString, Size: 255, Comment: "订阅套餐名称", Default: ""},
		{Name: "language", Type: field.TypeString, Size: 255, Comment: "语言", Default: ""},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "订阅套餐描述"},
		{Name: "unit_price", Type: field.TypeInt64, Comment: "单位价格", Default: 0},
		{Name: "unit_time", Type: field.TypeString, Size: 255, Comment: "单位时间", Default: ""},
		{Name: "discount", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "折扣配置"},
		{Name: "replacement", Type: field.TypeInt64, Comment: "替换", Default: 0},
		{Name: "inventory", Type: field.TypeInt32, Comment: "库存", Default: -1},
		{Name: "traffic", Type: field.TypeInt64, Comment: "流量", Default: 0},
		{Name: "speed_limit", Type: field.TypeInt32, Comment: "速度限制", Default: 0},
		{Name: "device_limit", Type: field.TypeInt32, Comment: "设备数限制", Default: 0},
		{Name: "quota", Type: field.TypeInt32, Comment: "配额", Default: 0},
		{Name: "nodes", Type: field.TypeString, Size: 255, Comment: "节点IDs", Default: ""},
		{Name: "node_tags", Type: field.TypeString, Size: 255, Comment: "节点标签", Default: ""},
		{Name: "node_group_ids", Type: field.TypeJSON, Nullable: true, Comment: "节点组ID列表"},
		{Name: "node_group_id", Type: field.TypeInt64, Nullable: true, Comment: "默认节点组ID", Default: 0},
		{Name: "traffic_limit", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "流量限制规则"},
		{Name: "show", Type: field.TypeBool, Comment: "是否显示", Default: false},
		{Name: "sell", Type: field.TypeBool, Comment: "是否售卖", Default: false},
		{Name: "sort", Type: field.TypeInt32, Comment: "排序", Default: 0},
		{Name: "deduction_ratio", Type: field.TypeInt32, Nullable: true, Comment: "扣除比例", Default: 0},
		{Name: "allow_deduction", Type: field.TypeBool, Comment: "允许扣除", Default: true},
		{Name: "reset_cycle", Type: field.TypeInt32, Nullable: true, Comment: "重置周期", Default: 0},
		{Name: "renewal_reset", Type: field.TypeBool, Comment: "续费重置", Default: false},
		{Name: "show_original_price", Type: field.TypeBool, Comment: "显示原价", Default: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// SubscribeTable holds the schema information for the "subscribe" table.
	SubscribeTable = &schema.Table{
		Name:       "subscribe",
		Columns:    SubscribeColumns,
		PrimaryKey: []*schema.Column{SubscribeColumns[0]},
	}
	// SubscribeApplicationColumns holds the columns for the "subscribe_application" table.
	SubscribeApplicationColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "应用配置ID"},
		{Name: "name", Type: field.TypeString, Size: 255, Comment: "应用名称", Default: ""},
		{Name: "icon", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "应用图标", SchemaType: map[string]string{"mysql": "mediumtext"}},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 255, Comment: "应用描述"},
		{Name: "scheme", Type: field.TypeString, Size: 255, Comment: "应用Scheme", Default: ""},
		{Name: "user_agent", Type: field.TypeString, Size: 255, Comment: "User Agent", Default: ""},
		{Name: "is_default", Type: field.TypeBool, Comment: "是否默认应用", Default: false},
		{Name: "subscribe_template", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "订阅模板", SchemaType: map[string]string{"mysql": "mediumtext"}},
		{Name: "output_format", Type: field.TypeString, Size: 50, Comment: "输出格式", Default: "yaml"},
		{Name: "download_link", Type: field.TypeString, Size: 2147483647, Comment: "下载链接"},
		{Name: "created_at", Type: field.TypeTime, Nullable: true, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
	}
	// SubscribeApplicationTable holds the schema information for the "subscribe_application" table.
	SubscribeApplicationTable = &schema.Table{
		Name:       "subscribe_application",
		Columns:    SubscribeApplicationColumns,
		PrimaryKey: []*schema.Column{SubscribeApplicationColumns[0]},
	}
	// SubscribeGroupColumns holds the columns for the "subscribe_group" table.
	SubscribeGroupColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "订阅组ID"},
		{Name: "name", Type: field.TypeString, Size: 255, Comment: "订阅组名称", Default: ""},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "订阅组描述"},
		{Name: "is_expired_group", Type: field.TypeBool, Comment: "是否为过期节点组", Default: false},
		{Name: "expired_days_limit", Type: field.TypeInt32, Nullable: true, Comment: "过期天数限制", Default: 0},
		{Name: "max_traffic_gb_expired", Type: field.TypeInt32, Nullable: true, Comment: "过期组最大流量GB", Default: 0},
		{Name: "speed_limit", Type: field.TypeInt64, Nullable: true, Comment: "过期组限速", Default: 0},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// SubscribeGroupTable holds the schema information for the "subscribe_group" table.
	SubscribeGroupTable = &schema.Table{
		Name:       "subscribe_group",
		Columns:    SubscribeGroupColumns,
		PrimaryKey: []*schema.Column{SubscribeGroupColumns[0]},
	}
	// SystemColumns holds the columns for the "system" table.
	SystemColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true},
		{Name: "category", Type: field.TypeString, Size: 100, Comment: "分类", Default: ""},
		{Name: "key", Type: field.TypeString, Size: 100, Comment: "键名", Default: ""},
		{Name: "value", Type: field.TypeString, Size: 2147483647, Comment: "键值"},
		{Name: "type", Type: field.TypeString, Size: 50, Comment: "类型", Default: ""},
		{Name: "desc", Type: field.TypeString, Size: 2147483647, Comment: "描述"},
		{Name: "created_at", Type: field.TypeTime, Nullable: true, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
	}
	// SystemTable holds the schema information for the "system" table.
	SystemTable = &schema.Table{
		Name:       "system",
		Columns:    SystemColumns,
		PrimaryKey: []*schema.Column{SystemColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "proxysystem_key",
				Unique:  true,
				Columns: []*schema.Column{SystemColumns[2]},
			},
		},
	}
	// SystemLogsColumns holds the columns for the "system_logs" table.
	SystemLogsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true},
		{Name: "type", Type: field.TypeInt8, Comment: "日志类型"},
		{Name: "date", Type: field.TypeString, Nullable: true, Size: 20, Comment: "日志日期"},
		{Name: "object_id", Type: field.TypeInt64, Comment: "对象ID", Default: 0},
		{Name: "content", Type: field.TypeString, Size: 2147483647, Comment: "日志内容"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
	}
	// SystemLogsTable holds the schema information for the "system_logs" table.
	SystemLogsTable = &schema.Table{
		Name:       "system_logs",
		Columns:    SystemLogsColumns,
		PrimaryKey: []*schema.Column{SystemLogsColumns[0]},
	}
	// TaskColumns holds the columns for the "task" table.
	TaskColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "type", Type: field.TypeInt8, Comment: "任务类型"},
		{Name: "scope", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "任务范围"},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "任务内容"},
		{Name: "status", Type: field.TypeInt8, Comment: "任务状态", Default: 0},
		{Name: "errors", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "任务错误信息"},
		{Name: "total", Type: field.TypeUint32, Comment: "总数", Default: 0},
		{Name: "current", Type: field.TypeUint32, Comment: "当前数量", Default: 0},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// TaskTable holds the schema information for the "task" table.
	TaskTable = &schema.Table{
		Name:       "task",
		Columns:    TaskColumns,
		PrimaryKey: []*schema.Column{TaskColumns[0]},
	}
	// TicketColumns holds the columns for the "ticket" table.
	TicketColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true},
		{Name: "title", Type: field.TypeString, Size: 255, Comment: "工单标题", Default: ""},
		{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "工单描述"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID", Default: 0},
		{Name: "status", Type: field.TypeInt8, Comment: "工单状态", Default: 1},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// TicketTable holds the schema information for the "ticket" table.
	TicketTable = &schema.Table{
		Name:       "ticket",
		Columns:    TicketColumns,
		PrimaryKey: []*schema.Column{TicketColumns[0]},
	}
	// TicketFollowColumns holds the columns for the "ticket_follow" table.
	TicketFollowColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true},
		{Name: "ticket_id", Type: field.TypeInt64, Comment: "工单ID", Default: 0},
		{Name: "from", Type: field.TypeString, Size: 255, Comment: "来源/操作人", Default: ""},
		{Name: "type", Type: field.TypeInt8, Comment: "类型", Default: 1},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "跟进内容"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
	}
	// TicketFollowTable holds the schema information for the "ticket_follow" table.
	TicketFollowTable = &schema.Table{
		Name:       "ticket_follow",
		Columns:    TicketFollowColumns,
		PrimaryKey: []*schema.Column{TicketFollowColumns[0]},
	}
	// TrafficLogColumns holds the columns for the "traffic_log" table.
	TrafficLogColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "server_id", Type: field.TypeInt64, Comment: "服务器ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
		{Name: "subscribe_id", Type: field.TypeInt64, Comment: "订阅ID"},
		{Name: "download", Type: field.TypeInt64, Comment: "下载流量", Default: 0},
		{Name: "upload", Type: field.TypeInt64, Comment: "上传流量", Default: 0},
		{Name: "timestamp", Type: field.TypeTime, Comment: "流量日志时间"},
	}
	// TrafficLogTable holds the schema information for the "traffic_log" table.
	TrafficLogTable = &schema.Table{
		Name:       "traffic_log",
		Columns:    TrafficLogColumns,
		PrimaryKey: []*schema.Column{TrafficLogColumns[0]},
	}
	// UserColumns holds the columns for the "user" table.
	UserColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "用户ID"},
		{Name: "password", Type: field.TypeString, Size: 100, Comment: "用户密码"},
		{Name: "algo", Type: field.TypeString, Size: 20, Comment: "加密算法", Default: "default"},
		{Name: "salt", Type: field.TypeString, Nullable: true, Size: 20, Comment: "密码盐值"},
		{Name: "avatar", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "用户头像"},
		{Name: "balance", Type: field.TypeInt64, Nullable: true, Comment: "用户余额", Default: 0},
		{Name: "telegram", Type: field.TypeInt64, Nullable: true, Comment: "Telegram 账号"},
		{Name: "refer_code", Type: field.TypeString, Nullable: true, Size: 20, Comment: "推荐码"},
		{Name: "referer_id", Type: field.TypeInt64, Nullable: true, Comment: "推荐人ID"},
		{Name: "commission", Type: field.TypeInt64, Nullable: true, Comment: "佣金", Default: 0},
		{Name: "referral_percentage", Type: field.TypeInt8, Comment: "推荐百分比", Default: 0},
		{Name: "only_first_purchase", Type: field.TypeBool, Comment: "仅首次购买", Default: true},
		{Name: "gift_amount", Type: field.TypeInt64, Nullable: true, Comment: "礼品金额", Default: 0},
		{Name: "enable", Type: field.TypeBool, Comment: "账号是否启用", Default: true},
		{Name: "is_admin", Type: field.TypeBool, Comment: "是否管理员", Default: false},
		{Name: "valid_email", Type: field.TypeBool, Comment: "邮箱是否已验证", Default: false},
		{Name: "enable_email_notify", Type: field.TypeBool, Comment: "启用邮件通知", Default: false},
		{Name: "enable_telegram_notify", Type: field.TypeBool, Comment: "启用 Telegram 通知", Default: false},
		{Name: "enable_balance_notify", Type: field.TypeBool, Comment: "启用余额变动通知", Default: false},
		{Name: "enable_login_notify", Type: field.TypeBool, Comment: "启用登录通知", Default: false},
		{Name: "enable_subscribe_notify", Type: field.TypeBool, Comment: "启用订阅通知", Default: false},
		{Name: "enable_trade_notify", Type: field.TypeBool, Comment: "启用交易通知", Default: false},
		{Name: "rules", Type: field.TypeString, Nullable: true, Comment: "用户规则"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "删除时间"},
		{Name: "is_del", Type: field.TypeUint64, Nullable: true, Comment: "1: 正常 0: 删除"},
	}
	// UserTable holds the schema information for the "user" table.
	UserTable = &schema.Table{
		Name:       "user",
		Columns:    UserColumns,
		PrimaryKey: []*schema.Column{UserColumns[0]},
	}
	// UserAuthMethodsColumns holds the columns for the "user_auth_methods" table.
	UserAuthMethodsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
		{Name: "auth_type", Type: field.TypeString, Size: 255, Comment: "认证类型"},
		{Name: "auth_identifier", Type: field.TypeString, Unique: true, Size: 255, Comment: "认证标识"},
		{Name: "verified", Type: field.TypeBool, Comment: "是否已验证", Default: false},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// UserAuthMethodsTable holds the schema information for the "user_auth_methods" table.
	UserAuthMethodsTable = &schema.Table{
		Name:       "user_auth_methods",
		Columns:    UserAuthMethodsColumns,
		PrimaryKey: []*schema.Column{UserAuthMethodsColumns[0]},
	}
	// UserDeviceColumns holds the columns for the "user_device" table.
	UserDeviceColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
		{Name: "subscribe_id", Type: field.TypeInt64, Nullable: true, Comment: "订阅ID"},
		{Name: "ip", Type: field.TypeString, Nullable: true, Size: 191, Comment: "设备IP"},
		{Name: "user_agent", Type: field.TypeString, Nullable: true, Size: 64, Comment: "设备User Agent"},
		{Name: "Identifier", Type: field.TypeString, Nullable: true, Size: 191, Comment: "设备标识符"},
		{Name: "short_code", Type: field.TypeString, Size: 255, Comment: "短码", Default: ""},
		{Name: "online", Type: field.TypeBool, Comment: "是否在线", Default: false},
		{Name: "enabled", Type: field.TypeBool, Comment: "是否启用", Default: true},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// UserDeviceTable holds the schema information for the "user_device" table.
	UserDeviceTable = &schema.Table{
		Name:       "user_device",
		Columns:    UserDeviceColumns,
		PrimaryKey: []*schema.Column{UserDeviceColumns[0]},
	}
	// UserDeviceOnlineRecordColumns holds the columns for the "user_device_online_record" table.
	UserDeviceOnlineRecordColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
		{Name: "identifier", Type: field.TypeString, Size: 255, Comment: "设备标识符"},
		{Name: "online_time", Type: field.TypeTime, Nullable: true, Comment: "上线时间"},
		{Name: "offline_time", Type: field.TypeTime, Nullable: true, Comment: "下线时间"},
		{Name: "online_seconds", Type: field.TypeInt64, Nullable: true, Comment: "在线秒数"},
		{Name: "duration_days", Type: field.TypeInt64, Nullable: true, Comment: "持续天数"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
	}
	// UserDeviceOnlineRecordTable holds the schema information for the "user_device_online_record" table.
	UserDeviceOnlineRecordTable = &schema.Table{
		Name:       "user_device_online_record",
		Columns:    UserDeviceOnlineRecordColumns,
		PrimaryKey: []*schema.Column{UserDeviceOnlineRecordColumns[0]},
	}
	// UserSubscribeColumns holds the columns for the "user_subscribe" table.
	UserSubscribeColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
		{Name: "order_id", Type: field.TypeInt64, Comment: "订单ID"},
		{Name: "subscribe_id", Type: field.TypeInt64, Comment: "订阅套餐ID"},
		{Name: "node_group_id", Type: field.TypeInt64, Comment: "节点组ID", Default: 0},
		{Name: "group_locked", Type: field.TypeBool, Comment: "分组是否锁定", Default: false},
		{Name: "start_time", Type: field.TypeTime, Comment: "订阅开始时间"},
		{Name: "expire_time", Type: field.TypeTime, Nullable: true, Comment: "订阅过期时间"},
		{Name: "finished_at", Type: field.TypeTime, Nullable: true, Comment: "订阅完成时间"},
		{Name: "traffic", Type: field.TypeInt64, Nullable: true, Comment: "总流量", Default: 0},
		{Name: "download", Type: field.TypeInt64, Nullable: true, Comment: "下载流量", Default: 0},
		{Name: "upload", Type: field.TypeInt64, Nullable: true, Comment: "上传流量", Default: 0},
		{Name: "expired_download", Type: field.TypeInt64, Nullable: true, Comment: "过期下载流量", Default: 0},
		{Name: "expired_upload", Type: field.TypeInt64, Nullable: true, Comment: "过期上传流量", Default: 0},
		{Name: "token", Type: field.TypeString, Unique: true, Nullable: true, Size: 255, Comment: "订阅令牌"},
		{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true, Size: 255, Comment: "订阅UUID"},
		{Name: "status", Type: field.TypeInt8, Nullable: true, Comment: "订阅状态", Default: 0},
		{Name: "note", Type: field.TypeString, Nullable: true, Size: 500, Comment: "用户备注"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
	}
	// UserSubscribeTable holds the schema information for the "user_subscribe" table.
	UserSubscribeTable = &schema.Table{
		Name:       "user_subscribe",
		Columns:    UserSubscribeColumns,
		PrimaryKey: []*schema.Column{UserSubscribeColumns[0]},
	}
	// UserWithdrawalColumns holds the columns for the "user_withdrawal" table.
	UserWithdrawalColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "提现ID"},
		{Name: "amount", Type: field.TypeInt64, Comment: "提现金额"},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "提现内容"},
		{Name: "status", Type: field.TypeInt8, Comment: "提现状态", Default: 0},
		{Name: "reason", Type: field.TypeString, Nullable: true, Size: 500, Comment: "拒绝原因"},
		{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
		{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
		{Name: "user_id", Type: field.TypeInt64, Comment: "用户ID"},
	}
	// UserWithdrawalTable holds the schema information for the "user_withdrawal" table.
	UserWithdrawalTable = &schema.Table{
		Name:       "user_withdrawal",
		Columns:    UserWithdrawalColumns,
		PrimaryKey: []*schema.Column{UserWithdrawalColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "user_withdrawal_user_withdrawals",
				Columns:    []*schema.Column{UserWithdrawalColumns[7]},
				RefColumns: []*schema.Column{UserColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		AdsTable,
		AnnouncementTable,
		AuthMethodTable,
		CouponTable,
		DocumentTable,
		GroupHistoryTable,
		GroupHistoryDetailTable,
		NodesTable,
		OrderTable,
		PaymentTable,
		RedemptionCodeTable,
		RedemptionRecordTable,
		SchemaMigrationsTable,
		ServersTable,
		NodeGroupTable,
		SubscribeTable,
		SubscribeApplicationTable,
		SubscribeGroupTable,
		SystemTable,
		SystemLogsTable,
		TaskTable,
		TicketTable,
		TicketFollowTable,
		TrafficLogTable,
		UserTable,
		UserAuthMethodsTable,
		UserDeviceTable,
		UserDeviceOnlineRecordTable,
		UserSubscribeTable,
		UserWithdrawalTable,
	}
)

Functions

func Create

func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error

Create creates all table resources using the given schema driver.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is the API for creating, migrating and dropping a schema.

func NewSchema

func NewSchema(drv dialect.Driver) *Schema

NewSchema creates a new schema client.

func (*Schema) Create

func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error

Create creates all schema resources.

func (*Schema) WriteTo

func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error

WriteTo writes the schema changes to w instead of running them against the database.

if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
	log.Fatal(err)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL