-- # 书籍系列表
--
-- ## 基本信息
--
-- 模块：book
-- 表名：book_series
-- 模型：model/book/book_series.go
-- 迁移接入：initialize/gorm_biz.go
-- 删除策略：硬删表
-- 职责：承载书籍系列主体信息，用于组织同一作品的分部顺序和系列展示。

CREATE TABLE book_series (
  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,
  name varchar(128) NOT NULL,
  cover_url varchar(500),
  intro text,
  is_enabled boolean NOT NULL DEFAULT true
);

COMMENT ON TABLE book_series IS '书籍系列表';
COMMENT ON COLUMN book_series.id IS '主键';
COMMENT ON COLUMN book_series.created_at IS '创建时间';
COMMENT ON COLUMN book_series.updated_at IS '更新时间';
COMMENT ON COLUMN book_series.name IS '系列名称';
COMMENT ON COLUMN book_series.cover_url IS '系列封面图片 URL';
COMMENT ON COLUMN book_series.intro IS '系列简介';
COMMENT ON COLUMN book_series.is_enabled IS '系列是否启用';

CREATE INDEX idx_book_series_name ON book_series (name);
CREATE INDEX idx_book_series_is_enabled ON book_series (is_enabled);
CREATE INDEX idx_book_series_created_at ON book_series (created_at);
