Files
xuanzhi-service/server/.ai-specs/doc-sql/book_author_relation.sql
wdh-home 1e33640629
Some checks failed
CI / init (pull_request) Has been cancelled
CI / Frontend node 18.16.0 (pull_request) Has been cancelled
CI / Backend go (1.22) (pull_request) Has been cancelled
CI / release-pr (pull_request) Has been cancelled
CI / devops-test (1.22, 18.16.0) (pull_request) Has been cancelled
CI / release-please (pull_request) Has been cancelled
CI / devops-prod (1.22, 18.x) (pull_request) Has been cancelled
CI / docker (pull_request) Has been cancelled
基础项目
2026-04-26 15:32:21 +08:00

32 lines
1.4 KiB
Go
Raw 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.
-- # 书籍作者关联表
--
-- ## 基本信息
--
-- 模块book
-- 表名book_author_relation
-- 模型model/book/book_author_relation.go
-- 迁移接入initialize/gorm_biz.go
-- 删除策略硬删表
-- 职责承载书籍与作者的多对多关系及展示顺序保证同一本书下作者关联唯一
CREATE TABLE book_author_relation (
id bigserial PRIMARY KEY,
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
book_id bigint NOT NULL,
author_id bigint NOT NULL,
author_sort integer NOT NULL DEFAULT 1 CHECK (author_sort > 0)
);
COMMENT ON TABLE book_author_relation IS '书籍作者关联表';
COMMENT ON COLUMN book_author_relation.id IS '主键';
COMMENT ON COLUMN book_author_relation.created_at IS '创建时间';
COMMENT ON COLUMN book_author_relation.updated_at IS '更新时间';
COMMENT ON COLUMN book_author_relation.book_id IS '关联书籍 ID';
COMMENT ON COLUMN book_author_relation.author_id IS '关联作者 ID';
COMMENT ON COLUMN book_author_relation.author_sort IS '作者展示顺序';
CREATE UNIQUE INDEX uk_book_author_relation_book_id_author_id ON book_author_relation (book_id, author_id);
CREATE INDEX idx_book_author_relation_author_id ON book_author_relation (author_id);
CREATE INDEX idx_book_author_relation_book_id_author_sort ON book_author_relation (book_id, author_sort);