refactor: 移除模型中的 uniqueIndex 约束
This commit is contained in:
@@ -23,7 +23,7 @@ type sConfig struct {
|
||||
|
||||
}
|
||||
type ServerList struct {
|
||||
OnlineID uint32 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"`
|
||||
OnlineID uint32 `gorm:"column:online_id;comment:'在线ID'" json:"online_id"`
|
||||
//服务器名称Desc
|
||||
Name string `gorm:"comment:'服务器名称'" json:"name"`
|
||||
IP string `gorm:"type:string;comment:'服务器IP'" json:"ip"`
|
||||
|
||||
@@ -13,6 +13,11 @@ DROP INDEX IF EXISTS idx_server_show_server_id;
|
||||
CREATE INDEX IF NOT EXISTS idx_server_show_server_id ON server_show (server_id);
|
||||
|
||||
-- 保证“一个玩家对一个服务器最多一条”
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_server_show_server_owner ON server_show (server_id, owner);
|
||||
ALTER TABLE server_show DROP CONSTRAINT IF EXISTS idx_server_show_server_owner;
|
||||
DROP INDEX IF EXISTS idx_server_show_server_owner;
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_server_show_server_owner
|
||||
ON server_show (server_id, owner)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -19,7 +19,12 @@ CREATE TABLE IF NOT EXISTS config_spt (
|
||||
description TEXT NOT NULL DEFAULT ''
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_config_spt_task_id ON config_spt(task_id);
|
||||
ALTER TABLE config_spt DROP CONSTRAINT IF EXISTS idx_config_spt_task_id;
|
||||
DROP INDEX IF EXISTS idx_config_spt_task_id;
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_config_spt_task_id
|
||||
ON config_spt(task_id)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
ALTER TABLE config_spt DROP COLUMN IF EXISTS seat_id;
|
||||
|
||||
@@ -58,7 +63,7 @@ VALUES
|
||||
(606,'帕多尼',656,1,5,510,'暗黑Ⅷ-Ⅰ门的守护者,浑身充斥着暗黑能量,暗黑能量会随着它的歌神散发出来。',1,''),
|
||||
(607,'加洛德',659,1,5,510,'暗黑Ⅷ-Ⅱ门的守护,暗黑能量的注入,使它的脾气变得暴躁,擅长与对手近身搏斗,浑身的尖刺、催生出的植物都是它进攻的利器。',1,''),
|
||||
(608,'萨多拉尼',661,1,5,510,'暗黑Ⅷ-Ⅲ门的守护,将暗黑能量融入自身,肢体变得非常结实有力,虽然体积很小,但是却拥有了堪比巨龙的神力。',1,'')
|
||||
ON CONFLICT (task_id) DO UPDATE
|
||||
ON CONFLICT (task_id) WHERE deleted_at IS NULL DO UPDATE
|
||||
SET
|
||||
title = EXCLUDED.title,
|
||||
pet_id = EXCLUDED.pet_id,
|
||||
|
||||
@@ -15,7 +15,7 @@ type CDKConfig struct {
|
||||
*cool.Model
|
||||
|
||||
// 核心字段
|
||||
CDKCode string `gorm:"not null;size:16;uniqueIndex:idx_config_gift_cdk_cdk_code,where:deleted_at IS NULL;comment:'CDK编号(唯一标识,用于玩家兑换)'" json:"cdk_code" description:"CDK编号"`
|
||||
CDKCode string `gorm:"not null;size:16;comment:'CDK编号(唯一标识,用于玩家兑换)'" json:"cdk_code" description:"CDK编号"`
|
||||
Type uint32 `gorm:"column:type;not null;default:0;comment:'CDK类型:0普通奖励,1服务器冠名'" json:"type" description:"CDK类型"`
|
||||
|
||||
//cdk可兑换次数,where不等于0
|
||||
|
||||
@@ -12,7 +12,7 @@ const TableNameFightRule = "config_fight_rule"
|
||||
type FightRule struct {
|
||||
*cool.Model // 嵌入基础Model(包含主键、创建/更新时间等通用字段)
|
||||
|
||||
RuleIdx uint32 `gorm:"not null;uniqueIndex:idx_rule_idx,where:deleted_at IS NULL;comment:'规则索引(300-316)'" json:"rule_idx"`
|
||||
RuleIdx uint32 `gorm:"not null;comment:'规则索引(300-316)'" json:"rule_idx"`
|
||||
Args []int `gorm:"type:jsonb;comment:'规则参数(JSON数组,对应RuleBase.args)'" json:"args"`
|
||||
Desc string `gorm:"type:varchar(255);default:'';comment:'规则描述'" json:"desc"`
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ const (
|
||||
type PeakTianxuan struct {
|
||||
*BaseConfig
|
||||
|
||||
PlayerID uint32 `gorm:"not null;index:idx_peak_tianxuan_player;uniqueIndex:idx_peak_tianxuan_player_pet,where:deleted_at IS NULL;comment:'所属玩家ID'" json:"player_id"`
|
||||
PlayerID uint32 `gorm:"not null;index:idx_peak_tianxuan_player;comment:'所属玩家ID'" json:"player_id"`
|
||||
DisplayOrder uint32 `gorm:"not null;default:0;comment:'展示顺序'" json:"display_order"`
|
||||
PetID uint32 `gorm:"not null;uniqueIndex:idx_peak_tianxuan_player_pet,where:deleted_at IS NULL;comment:'天选精灵ID'" json:"pet_id"`
|
||||
PetID uint32 `gorm:"not null;comment:'天选精灵ID'" json:"pet_id"`
|
||||
PresetName string `gorm:"type:varchar(64);not null;default:'';comment:'预设显示名'" json:"preset_name"`
|
||||
Level uint32 `gorm:"not null;default:100;comment:'预设等级'" json:"level"`
|
||||
Nature uint32 `gorm:"not null;default:0;comment:'预设性格'" json:"nature"`
|
||||
|
||||
@@ -11,8 +11,8 @@ const (
|
||||
type PeakTianxuanVote struct {
|
||||
*cool.Model
|
||||
|
||||
WeekIndex uint32 `gorm:"not null;uniqueIndex:idx_peak_tianxuan_vote_week_player,where:deleted_at IS NULL;index:idx_peak_tianxuan_vote_week_pet;comment:'周序号'" json:"week_index"`
|
||||
PlayerID uint32 `gorm:"not null;uniqueIndex:idx_peak_tianxuan_vote_week_player,where:deleted_at IS NULL;comment:'投票玩家ID'" json:"player_id"`
|
||||
WeekIndex uint32 `gorm:"not null;index:idx_peak_tianxuan_vote_week_pet;comment:'周序号'" json:"week_index"`
|
||||
PlayerID uint32 `gorm:"not null;comment:'投票玩家ID'" json:"player_id"`
|
||||
PetID uint32 `gorm:"not null;index:idx_peak_tianxuan_vote_week_pet;comment:'投票精灵ID'" json:"pet_id"`
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ const TableNameServerShow = "server_show"
|
||||
// ServerShow 绑定服务器展示信息(冠名、属主、到期时间)。
|
||||
type ServerShow struct {
|
||||
*cool.Model
|
||||
ServerID uint32 `gorm:"column:server_id;comment:'服务器ID';index:idx_server_show_server_id;uniqueIndex:idx_server_show_server_owner,where:deleted_at IS NULL" json:"server_id"`
|
||||
ServerID uint32 `gorm:"column:server_id;comment:'服务器ID';index:idx_server_show_server_id" json:"server_id"`
|
||||
Name string `gorm:"comment:'服务器展示名'" json:"name"`
|
||||
Owner uint32 `gorm:"comment:'服务器属主';uniqueIndex:idx_server_show_server_owner,where:deleted_at IS NULL" json:"owner"`
|
||||
Owner uint32 `gorm:"comment:'服务器属主'" json:"owner"`
|
||||
ExpireTime time.Time `gorm:"column:expire_time;default:0;comment:'展示到期时间'" json:"expire_time"`
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ type ShopConfig struct {
|
||||
ProductType uint32 `gorm:"not null;default:0;comment:'商品类型'" json:"product_type" description:"商品类型"`
|
||||
|
||||
//商品ID
|
||||
ProductID int64 `gorm:"not null;uniqueIndex:idx_config_shop_product_id,where:deleted_at IS NULL;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
||||
ProductID int64 `gorm:"not null;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
||||
|
||||
// 价格信息 -1代表不允许购买,0表示不支持购买
|
||||
SeerdouPrice int32 `gorm:"not null;default:0;comment:'骄阳豆价格'" json:"seerdou_price" description:"骄阳豆价格"`
|
||||
|
||||
@@ -12,9 +12,9 @@ const (
|
||||
// SignIn 签到阶段配置表。
|
||||
type SignIn struct {
|
||||
*BaseConfig
|
||||
SignType uint32 `gorm:"not null;default:1;uniqueIndex:idx_sign_type_stage,where:deleted_at IS NULL;comment:'签到类别(1-累计 2-连续)'" json:"sign_type"`
|
||||
StageDays uint32 `gorm:"not null;default:1;uniqueIndex:idx_sign_type_stage,where:deleted_at IS NULL;comment:'签到阶段天数(0/1/3/7/14/30)'" json:"stage_days"`
|
||||
CdkID uint32 `gorm:"not null;uniqueIndex:idx_config_sign_in_cdk_id,where:deleted_at IS NULL;comment:'绑定的CDK配置ID'" json:"cdk_id"`
|
||||
SignType uint32 `gorm:"not null;default:1;comment:'签到类别(1-累计 2-连续)'" json:"sign_type"`
|
||||
StageDays uint32 `gorm:"not null;default:1;comment:'签到阶段天数(0/1/3/7/14/30)'" json:"stage_days"`
|
||||
CdkID uint32 `gorm:"not null;comment:'绑定的CDK配置ID'" json:"cdk_id"`
|
||||
}
|
||||
|
||||
func (*SignIn) TableName() string {
|
||||
|
||||
@@ -10,7 +10,7 @@ const (
|
||||
type SptConfig struct {
|
||||
*BaseConfig
|
||||
|
||||
TaskID uint32 `gorm:"not null;uniqueIndex:idx_config_spt_task_id,where:deleted_at IS NULL;comment:'SPT任务ID'" json:"task_id" description:"SPT任务ID"`
|
||||
TaskID uint32 `gorm:"not null;comment:'SPT任务ID'" json:"task_id" description:"SPT任务ID"`
|
||||
Title string `gorm:"type:varchar(64);not null;default:'';comment:'SPT名字'" json:"title" description:"SPT名字"`
|
||||
PetID uint32 `gorm:"not null;default:0;comment:'SPT精灵ID'" json:"pet_id" description:"SPT精灵ID"`
|
||||
Online int32 `gorm:"not null;default:1;comment:'是否开放(1开放/0未开放)'" json:"online" description:"是否开放"`
|
||||
|
||||
@@ -14,7 +14,7 @@ const (
|
||||
type BaseTowerConfig struct {
|
||||
*BaseConfig
|
||||
Name string `gorm:"type:varchar(100);default:'';comment:'name'" json:"name" description:"name"`
|
||||
TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex:,where:deleted_at IS NULL;comment:'tower level'" json:"tower_level"`
|
||||
TowerLevel uint32 `gorm:"not null;default:0;comment:'tower level'" json:"tower_level"`
|
||||
BossIds []uint32 `gorm:"type:jsonb;comment:'boss ids'" json:"boss_ids"`
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const TableNamePlayerInfo = "player_info"
|
||||
|
||||
type Player struct {
|
||||
*cool.Model
|
||||
PlayerID uint64 `gorm:"not null;uniqueIndex:idx_player_info_player_id,where:deleted_at IS NULL;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
PlayerID uint64 `gorm:"not null;index:idx_pet_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
LastResetTime *gtime.Time `struc:"skip" json:"last_reset_time"` // 重置时间,比如电池和每日任务
|
||||
WeekLastResetTime *gtime.Time `struc:"skip" json:"week_last_reset_time"`
|
||||
Data PlayerInfo `gorm:"type:jsonb;not null;comment:'全部数据'" json:"data"`
|
||||
|
||||
Reference in New Issue
Block a user