-- 正式库：岗位性质字段及业务字典类型迁移。
-- 执行目标：正式 HighGo 数据库的 shz schema。
-- 岗位性质非必填；具体字典项由后台“业务字典”维护。

BEGIN;

ALTER TABLE "shz"."job"
    ADD COLUMN IF NOT EXISTS "job_nature" VARCHAR(100);

COMMENT ON COLUMN "shz"."job"."job_nature"
    IS '岗位性质，对应业务字典 job_nature，非必填';

INSERT INTO "shz"."bussiness_dict_type" (
    "dict_id", "dict_name", "dict_type", "status", "create_by", "create_time", "remark"
)
SELECT
    (SELECT COALESCE(MAX("dict_id"), 0) + 1 FROM "shz"."bussiness_dict_type"),
    '岗位性质',
    'job_nature',
    '0',
    'system',
    CURRENT_TIMESTAMP,
    '岗位管理使用，字典项由业务字典维护'
WHERE NOT EXISTS (
    SELECT 1
    FROM "shz"."bussiness_dict_type"
    WHERE "dict_type" = 'job_nature'
);

COMMIT;
