CREATE TABLE sys_apis
(
    id         INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    group_name TEXT      NOT NULL,
    name       TEXT      NOT NULL,
    method     TEXT      NOT NULL,
    path       TEXT      NOT NULL,
    sort       INTEGER            DEFAULT 0,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ,

    UNIQUE (method, path)
);

CREATE TRIGGER update_sys_apis_updated_at
    BEFORE UPDATE
    ON sys_apis
    FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();

COMMENT ON COLUMN sys_apis.id IS '主键ID';
COMMENT ON COLUMN sys_apis.group_name IS '分组名称';
COMMENT ON COLUMN sys_apis.name IS '接口名称';
COMMENT ON COLUMN sys_apis.method IS 'api方法';
COMMENT ON COLUMN sys_apis.path IS 'api路径';
COMMENT ON COLUMN sys_apis.sort IS '排序';
COMMENT ON COLUMN sys_apis.created_at IS '创建时间';
COMMENT ON COLUMN sys_apis.updated_at IS '更新时间';