DROP TABLE IF EXISTS inventory_summary;

-- 创建库存汇总表
CREATE TABLE inventory_summary
(
    id                 BIGSERIAL PRIMARY KEY,             -- 主键ID
    inventory_id       bigint         not null default 0,
    inventory_type     varchar(10)    not null default '',
    inventory_quantity DECIMAL(10, 2) not null default 0,
    input_end_record_id      bigint         not null default 0,
    output_end_record_id      bigint         not null default 0,
    deleted            INT            NOT NULL DEFAULT 0, -- 软删除标志：0=未删除，1=已删除
    create_time        TIMESTAMP WITHOUT TIME ZONE,       -- 创建时间，默认当前时间
    update_time        TIMESTAMP WITHOUT TIME ZONE        -- 最后更新时间，默认当前时间
);


-- 添加表注释
COMMENT ON TABLE inventory_summary IS '库存汇总表';

-- 添加字段注释
COMMENT ON COLUMN inventory_summary.id IS '主键ID';
COMMENT ON COLUMN inventory_summary.inventory_id IS '库id';
COMMENT ON COLUMN inventory_summary.inventory_type IS '库类型';
COMMENT ON COLUMN inventory_summary.inventory_quantity IS '库存数量';
COMMENT ON COLUMN inventory_summary.input_end_record_id IS '入库中止明细记录id';
COMMENT ON COLUMN inventory_summary.output_end_record_id IS '出库中止明细记录id';
COMMENT ON COLUMN inventory_summary.deleted IS '软删除标志，0=未删除，1=已删除';
COMMENT ON COLUMN inventory_summary.create_time IS '记录创建时间';
COMMENT ON COLUMN inventory_summary.update_time IS '记录最后更新时间';
