-- 创建正式库表
CREATE TABLE official_inventory
(
    id                        BIGSERIAL PRIMARY KEY,             -- 主键ID
    supplier_name             VARCHAR(255)   NOT NULL,           -- 供货商名称
    coal                      VARCHAR(50)    NOT NULL,           -- 煤种
    unit                      VARCHAR(50)    NOT NULL,           -- 单位
    inventory_quantity        DECIMAL(10, 2) NOT NULL,           -- 库存数量
    price_including_tax       DECIMAL(10, 2) NOT NULL,           -- 单价（含税）
    total_price_including_tax DECIMAL(10, 2) NOT NULL,           -- 总价（含税）
    price_excluding_tax       DECIMAL(10, 2) NOT NULL,           -- 不含税单价
    total_price_excluding_tax DECIMAL(10, 2) NOT NULL,           -- 不含税总价
    pending_replenishment     DECIMAL(10, 2) NOT NULL,           -- 待补库
    registrant_id             VARCHAR(50)    NOT NULL,           -- 登记人id
    type             VARCHAR(50)    NOT NULL,           -- 登记人id
    pending_id                BIGINT,                            -- 待入库id
    registration_date         TIMESTAMP WITHOUT TIME ZONE,

    deleted                   INT            NOT NULL DEFAULT 0, -- 软删除标志：0=未删除，1=已删除
    create_by                 VARCHAR(255),                      -- 创建人用户名
    create_time               TIMESTAMP WITHOUT TIME ZONE,       -- 创建时间，默认当前时间
    update_by                 VARCHAR(255),                      -- 最后更新人用户名
    update_time               TIMESTAMP WITHOUT TIME ZONE        -- 最后更新时间，默认当前时间-- 登记日期
);

-- 添加表注释
COMMENT ON TABLE official_inventory IS '正式库存表';

-- 添加字段注释
COMMENT ON COLUMN official_inventory.id IS '主键ID';
COMMENT ON COLUMN official_inventory.supplier_name IS '供货商名称';
COMMENT ON COLUMN official_inventory.coal IS '煤种';
COMMENT ON COLUMN official_inventory.unit IS '单位';
COMMENT ON COLUMN official_inventory.inventory_quantity IS '库存数量';
COMMENT ON COLUMN official_inventory.price_including_tax IS '单价（含税）';
COMMENT ON COLUMN official_inventory.total_price_including_tax IS '总价（含税）';
COMMENT ON COLUMN official_inventory.pending_replenishment IS '待补库';
COMMENT ON COLUMN official_inventory.registrant_id IS '登记人id';
COMMENT ON COLUMN official_inventory.registration_date IS '登记日期';

COMMENT ON COLUMN official_inventory.deleted IS '软删除标志，0=未删除，1=已删除';
COMMENT ON COLUMN official_inventory.create_by IS '创建该记录的用户';
COMMENT ON COLUMN official_inventory.create_time IS '记录创建时间';
COMMENT ON COLUMN official_inventory.update_by IS '最后修改该记录的用户';
COMMENT ON COLUMN official_inventory.update_time IS '记录最后更新时间';