Files
platforms/backend/api/cmd/cli/favorite_migration.go
czl231 3ef33b531d 已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
2026-09-13 00:57:32 +08:00

31 lines
1.9 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 功能描述仅新增电商收藏关系表与中文注释版本1.0.0。
package main
// migrateEcFavorite 使用既有环境数据库配置,不执行其他表迁移或初始化数据。
func migrateEcFavorite() error {
return migrateClientColumns([]string{
`CREATE TABLE IF NOT EXISTS ec_favorite (
id bigserial PRIMARY KEY,
identity varchar(36) NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL,
deleted_at timestamptz,
status integer NOT NULL DEFAULT 1 CHECK (status IN (1, 3)),
user_account_id bigint NOT NULL REFERENCES user_account(id),
ec_product_id bigint NOT NULL REFERENCES ec_product(id),
revision bigint NOT NULL DEFAULT 1 CHECK (revision > 0),
CONSTRAINT ux_ec_favorite_owner_product UNIQUE (user_account_id, ec_product_id)
)`,
`COMMENT ON TABLE ec_favorite IS '电商商品收藏关系;每账户每商品唯一,取消后归档,下架商品保留'`,
`COMMENT ON COLUMN ec_favorite.id IS '收藏关系内部自增主键,不向客户端暴露'`,
`COMMENT ON COLUMN ec_favorite.identity IS '收藏关系公开UUID V7标识'`,
`COMMENT ON COLUMN ec_favorite.created_at IS '首次建立收藏关系的服务端时间'`,
`COMMENT ON COLUMN ec_favorite.updated_at IS '最近一次收藏状态变化的服务端时间'`,
`COMMENT ON COLUMN ec_favorite.deleted_at IS '软删除时间;用户取消收藏不写此字段而使用归档状态'`,
`COMMENT ON COLUMN ec_favorite.status IS '收藏状态1=已收藏3=已取消并归档'`,
`COMMENT ON COLUMN ec_favorite.user_account_id IS '收藏者账户内部关联键对应user_account.id'`,
`COMMENT ON COLUMN ec_favorite.ec_product_id IS '收藏商品内部关联键对应ec_product.id商品下架不删除关系'`,
`COMMENT ON COLUMN ec_favorite.revision IS '正整数并发版本首次为1每次收藏状态变化递增相同目标重试不递增'`,
})
}