CREATE TABLE sys_roles
(
    id         INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    name       TEXT      NOT NULL,
    code       TEXT      NOT NULL UNIQUE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ
);

CREATE TRIGGER update_sys_roles_updated_at
    BEFORE UPDATE
    ON sys_roles
    FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();

COMMENT ON COLUMN sys_roles.id IS '主键ID';
COMMENT ON COLUMN sys_roles.name IS '角色名称';
COMMENT ON COLUMN sys_roles.code IS '角色编码，唯一';
COMMENT ON COLUMN sys_roles.created_at IS '创建时间';
COMMENT ON COLUMN sys_roles.updated_at IS '更新时间';