修改表字段的方法

CREATE OR REPLACE FUNCTION nb_meta.gf_alter_field_name (old_name varchar, new_name varchar, table_name varchar)
    RETURNS void
    LANGUAGE plpgsql
AS $func$
DECLARE
    fr record;
    nr record;
BEGIN
    FOR fr IN
        SELECT
            key,
            options
        FROM
            nb_meta.fields
        WHERE
            options ->> 'foreignKey' = old_name
            AND collection_name = table_name 
    LOOP
        UPDATE
            nb_meta.fields
        SET
            options = regexp_replace(fr.options::text, format('"foreignKey":"%s"', old_name), format('"foreignKey":"%s"', new_name))::json
        WHERE
            key = fr.key;
    END LOOP;
    FOR nr IN
        SELECT
            key,
            options,
            options ->> 'isForeignKey' as fk
        FROM
            nb_meta.fields
        WHERE
            name = old_name
            AND collection_name = table_name
    LOOP
        IF nr.fk THEN
            UPDATE
                nb_meta.fields
            SET
                name = new_name,
                options = regexp_replace(nr.options::text, format('"title":"%s"', old_name), format('"title":"%s"', new_name))::json
            WHERE
                key = nr.key;
        ELSE
            UPDATE
                nb_meta.fields
            SET
                name = new_name
            WHERE
                key = nr.key;
        END IF;
    END LOOP;
    EXECUTE format('ALTER TABLE IF EXISTS nb_main.%I RENAME COLUMN %I TO %I', table_name, old_name, new_name);
END;
$func$;

在主应用的数据空间中创建以上函数;

使用SQL table 或 自行创建一个包含以上三个字段的表区块,通过绑定自定义工作流
即可实现在UI上进行表标识的修改