CREATE TABLE FORM_BO_ATTR (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   ENT_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   DATA_TYPE_           VARCHAR(40)          NULL DEFAULT NULL,
   DEFAULT_VALUE_       VARCHAR(1024)        NULL DEFAULT NULL,
   FORMAT_              VARCHAR(255)         NULL DEFAULT NULL,
   IS_REQUIRED_         INT4                 NOT NULL,
   ATTR_LENGTH_         INT4                 NULL DEFAULT NULL,
   DECIMAL_LEN_         INT4                 NULL DEFAULT NULL,
   FIELD_NAME_          VARCHAR(50)          NULL DEFAULT NULL,
   SN_                  INT2                 NULL DEFAULT NULL,
   STATUS_              VARCHAR(20)          NULL DEFAULT NULL,
   INDEX_               INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_ATTR PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_ATTR IS
'业务实体定义属性';

COMMENT ON COLUMN FORM_BO_ATTR.NAME_ IS
'属性名称';

COMMENT ON COLUMN FORM_BO_ATTR.DESC_ IS
'属性描述';

COMMENT ON COLUMN FORM_BO_ATTR.ENT_ID_ IS
'实体ID';

COMMENT ON COLUMN FORM_BO_ATTR.DATA_TYPE_ IS
'数据类型。string=字符串；number=数值；datetime=日期（长日期，通过显示格式来限制）';

COMMENT ON COLUMN FORM_BO_ATTR.DEFAULT_VALUE_ IS
'基本默认值';

COMMENT ON COLUMN FORM_BO_ATTR.FORMAT_ IS
'基本类型显示格式';

COMMENT ON COLUMN FORM_BO_ATTR.IS_REQUIRED_ IS
'是否必填';

COMMENT ON COLUMN FORM_BO_ATTR.ATTR_LENGTH_ IS
'属性长度';

COMMENT ON COLUMN FORM_BO_ATTR.DECIMAL_LEN_ IS
'浮点长度';

COMMENT ON COLUMN FORM_BO_ATTR.FIELD_NAME_ IS
'字段名';

COMMENT ON COLUMN FORM_BO_ATTR.STATUS_ IS
'状态 show：显示，hide：隐藏';

COMMENT ON COLUMN FORM_BO_ATTR.INDEX_ IS
'排序';

CREATE TABLE FORM_BO_DATA_RELATION (
   ID_                  VARCHAR(50)          NOT NULL,
   PK_                  VARCHAR(50)          NULL DEFAULT NULL,
   FK_                  VARCHAR(50)          NULL DEFAULT NULL,
   PK_NUM_              DECIMAL(20,0)        NULL DEFAULT NULL,
   FK_NUM_              DECIMAL(20,0)        NULL DEFAULT NULL,
   SUB_BO_NAME          VARCHAR(50)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_DATA_RELATION PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_DATA_RELATION IS
'多对多业务数据关联表';

COMMENT ON COLUMN FORM_BO_DATA_RELATION.PK_ IS
'主表PK数据';

COMMENT ON COLUMN FORM_BO_DATA_RELATION.FK_ IS
'外键ID数据';

COMMENT ON COLUMN FORM_BO_DATA_RELATION.PK_NUM_ IS
'主键值';

COMMENT ON COLUMN FORM_BO_DATA_RELATION.FK_NUM_ IS
'外键数字';

COMMENT ON COLUMN FORM_BO_DATA_RELATION.SUB_BO_NAME IS
'子实体名称';

CREATE TABLE FORM_BO_DEF (
   ID_                  VARCHAR(50)          NOT NULL,
   CATEGORY_ID_         VARCHAR(50)          NULL DEFAULT NULL,
   CATEGORY_NAME_       VARCHAR(255)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(50)          NULL DEFAULT NULL,
   DESCRIPTION_         VARCHAR(100)         NULL DEFAULT NULL,
   SUPPORT_DB_          INT2                 NULL DEFAULT NULL,
   DEPLOYED_            INT2                 NULL DEFAULT NULL,
   STATUS_              VARCHAR(20)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(50)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   REV_                 INT4                 NOT NULL DEFAULT 1,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_DEF PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_DEF IS
'BO定义';

COMMENT ON COLUMN FORM_BO_DEF.CATEGORY_ID_ IS
'分类ID';

COMMENT ON COLUMN FORM_BO_DEF.CATEGORY_NAME_ IS
'分类名称';

COMMENT ON COLUMN FORM_BO_DEF.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_BO_DEF.DESCRIPTION_ IS
'表单定义描述';

COMMENT ON COLUMN FORM_BO_DEF.SUPPORT_DB_ IS
'BO支持数据库，相关的BO实体生成物理表';

COMMENT ON COLUMN FORM_BO_DEF.DEPLOYED_ IS
'是否发布';

COMMENT ON COLUMN FORM_BO_DEF.STATUS_ IS
'BO状态(normal,正常,forbidden 禁用)';

COMMENT ON COLUMN FORM_BO_DEF.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN FORM_BO_DEF.REV_ IS
'关联锁';

CREATE TABLE FORM_BO_ENT (
   ID_                  VARCHAR(64)          NOT NULL,
   PACKAGE_ID_          VARCHAR(50)          NULL DEFAULT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   IS_CREATE_TABLE_     INT2                 NOT NULL,
   TABLE_NAME_          VARCHAR(50)          NULL DEFAULT NULL,
   DS_NAME_             VARCHAR(50)          NULL DEFAULT NULL,
   PK_TYPE_             VARCHAR(20)          NULL DEFAULT NULL,
   IS_EXTERNAL_         INT2                 NULL DEFAULT NULL,
   PK_                  VARCHAR(50)          NULL DEFAULT NULL,
   FK_                  VARCHAR(50)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_ENT PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_ENT IS
'业务实体定义';

COMMENT ON COLUMN FORM_BO_ENT.PACKAGE_ID_ IS
'分类ID';

COMMENT ON COLUMN FORM_BO_ENT.NAME_ IS
'对象名称(需要唯一约束)';

COMMENT ON COLUMN FORM_BO_ENT.DESC_ IS
'对象描述';

COMMENT ON COLUMN FORM_BO_ENT.STATUS_ IS
'状态。inactive=未激活；actived=激活；forbidden=禁用';

COMMENT ON COLUMN FORM_BO_ENT.IS_CREATE_TABLE_ IS
'是否生成表';

COMMENT ON COLUMN FORM_BO_ENT.TABLE_NAME_ IS
'表名';

COMMENT ON COLUMN FORM_BO_ENT.DS_NAME_ IS
'数据源名称';

COMMENT ON COLUMN FORM_BO_ENT.PK_TYPE_ IS
'主键类型';

COMMENT ON COLUMN FORM_BO_ENT.IS_EXTERNAL_ IS
'是否外部表';

COMMENT ON COLUMN FORM_BO_ENT.PK_ IS
'主键字段名称';

COMMENT ON COLUMN FORM_BO_ENT.FK_ IS
'外键字段名称';

CREATE TABLE FORM_BO_ENT_RELATION (
   ID_                  VARCHAR(50)          NOT NULL,
   BO_DEFID_            VARCHAR(50)          NULL DEFAULT NULL,
   PARENT_ID_           VARCHAR(50)          NULL DEFAULT NULL,
   REF_ENT_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                VARCHAR(50)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_ENT_RELATION PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_ENT_RELATION IS
'BO定义实体关系';

COMMENT ON COLUMN FORM_BO_ENT_RELATION.BO_DEFID_ IS
'BO定义ID';

COMMENT ON COLUMN FORM_BO_ENT_RELATION.PARENT_ID_ IS
'上级ID';

COMMENT ON COLUMN FORM_BO_ENT_RELATION.REF_ENT_ID_ IS
'关联实体ID';

COMMENT ON COLUMN FORM_BO_ENT_RELATION.TYPE_ IS
'类型 (主表,main, onetoone,onetomany,manytomany)';

CREATE TABLE FORM_BO_INT (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_ID_              VARCHAR(64)          NOT NULL,
   INST_DATA_           TEXT                 NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_INT PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_INT IS
'业务对象实例';

COMMENT ON COLUMN FORM_BO_INT.DEF_ID_ IS
'对象定义ID';

COMMENT ON COLUMN FORM_BO_INT.INST_DATA_ IS
'实例数据';

CREATE TABLE FORM_BO_RELATION (
   ID_                  VARCHAR(50)          NOT NULL,
   FORM_ID_             VARCHAR(50)          NULL DEFAULT NULL,
   BO_DEF_ID_           VARCHAR(50)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BO_RELATION PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BO_RELATION IS
'表单和BO的关联';

COMMENT ON COLUMN FORM_BO_RELATION.FORM_ID_ IS
'表单ID';

COMMENT ON COLUMN FORM_BO_RELATION.BO_DEF_ID_ IS
'BO定义ID';

CREATE TABLE FORM_BUS_SET (
   ID_                  VARCHAR(50)          NOT NULL,
   FORM_KEY_            VARCHAR(50)          NULL DEFAULT NULL,
   JS_PRE_SCRIPT        VARCHAR(3000)        NULL DEFAULT NULL,
   JS_AFTER_SCRIPT      VARCHAR(1000)        NULL DEFAULT NULL,
   PRE_SCRIPT           VARCHAR(3000)        NULL DEFAULT NULL,
   AFTER_SCRIPT         VARCHAR(3000)        NULL DEFAULT NULL,
   ISTREELIST           INT2                 NULL DEFAULT NULL,
   TREECONF             VARCHAR(200)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_BUS_SET PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_BUS_SET IS
'业务数据保存配置';

COMMENT ON COLUMN FORM_BUS_SET.FORM_KEY_ IS
'表单key';

COMMENT ON COLUMN FORM_BUS_SET.JS_PRE_SCRIPT IS
'JavaScript前置脚本';

COMMENT ON COLUMN FORM_BUS_SET.JS_AFTER_SCRIPT IS
'JavaScript后置脚本';

COMMENT ON COLUMN FORM_BUS_SET.PRE_SCRIPT IS
'保存前置脚本';

COMMENT ON COLUMN FORM_BUS_SET.AFTER_SCRIPT IS
'保存后置脚本';

COMMENT ON COLUMN FORM_BUS_SET.ISTREELIST IS
'是否树形列表';

COMMENT ON COLUMN FORM_BUS_SET.TREECONF IS
'树形配置';

CREATE TABLE FORM_CODEGEN_LOG (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_                VARCHAR(40)          NULL DEFAULT NULL,
   TABLE_OR_FORM_       VARCHAR(255)         NULL DEFAULT NULL,
   OPE_CONTENT_         TEXT                 NULL,
   IP_                  VARCHAR(40)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_CODEGEN_LOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_CODEGEN_LOG IS
'代码生成日志';

COMMENT ON COLUMN FORM_CODEGEN_LOG.ID_ IS
'主键';

COMMENT ON COLUMN FORM_CODEGEN_LOG.TYPE_ IS
'操作类型';

COMMENT ON COLUMN FORM_CODEGEN_LOG.TABLE_OR_FORM_ IS
'表或表单名称';

COMMENT ON COLUMN FORM_CODEGEN_LOG.OPE_CONTENT_ IS
'操作参数';

COMMENT ON COLUMN FORM_CODEGEN_LOG.IP_ IS
'操作IP';

COMMENT ON COLUMN FORM_CODEGEN_LOG.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN FORM_CODEGEN_LOG.CREATE_ORG_ID_ IS
'创建人所属组织';

COMMENT ON COLUMN FORM_CODEGEN_LOG.TENANT_ID_ IS
'租户ID';

CREATE TABLE FORM_COMBINATE_DIALOG (
   ID_                  VARCHAR(50)          NOT NULL,
   NAME_                VARCHAR(100)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(50)          NULL DEFAULT NULL,
   WIDTH_               INT4                 NULL DEFAULT NULL,
   HEIGHT_              INT4                 NULL DEFAULT NULL,
   TREE_DIALOG_ID_      VARCHAR(50)          NULL DEFAULT NULL,
   TREE_DIALOG_NAME_    VARCHAR(100)         NULL DEFAULT NULL,
   LIST_DIALOG_ID_      VARCHAR(50)          NULL DEFAULT NULL,
   LIST_DIALOG_NAME_    VARCHAR(100)         NULL DEFAULT NULL,
   FIELD_               VARCHAR(500)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_COMBINATE_DIALOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_COMBINATE_DIALOG IS
'组合对话框';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.NAME_ IS
'名称';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.WIDTH_ IS
'宽度';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.HEIGHT_ IS
'高度';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.TREE_DIALOG_ID_ IS
'树形对话框ID';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.TREE_DIALOG_NAME_ IS
'树形对话框名称';

COMMENT ON COLUMN FORM_COMBINATE_DIALOG.LIST_DIALOG_ID_ IS
'列表对话框ID';

CREATE TABLE FORM_CUSTOM_CHART (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   ALIAS_               VARCHAR(64)          NULL DEFAULT NULL,
   STYLE_               INT2                 NULL DEFAULT NULL,
   OBJ_NAME_            VARCHAR(64)          NULL DEFAULT NULL,
   DISPLAYFIELD_        TEXT                 NULL,
   CONDITIONFIELD_      TEXT                 NULL,
   RESULTFIELD_         TEXT                 NULL,
   SORTFIELD_           TEXT                 NULL DEFAULT NULL,
   DSALIAS_             VARCHAR(64)          NULL DEFAULT NULL,
   IS_TABLE_            INT2                 NOT NULL,
   DIY_SQL_             TEXT                 NULL,
   WIDTH_               INT4                 NULL DEFAULT NULL,
   HEIGHT_              INT4                 NULL DEFAULT NULL,
   XAXIS_FIELD_         VARCHAR(200)         NULL DEFAULT NULL,
   YAXIS_UNIT_          VARCHAR(200)         NULL DEFAULT NULL,
   CONF_                VARCHAR(510)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_CUSTOM_CHART PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_CUSTOM_CHART IS
'自定义对图表';

COMMENT ON COLUMN FORM_CUSTOM_CHART.STYLE_ IS
'图表类型：1-折线图，2-饼图，3-柱状图，4-雷达图，5-树形图';

COMMENT ON COLUMN FORM_CUSTOM_CHART.IS_TABLE_ IS
'是否数据库表1:表，2.自定义sql';

COMMENT ON COLUMN FORM_CUSTOM_CHART.WIDTH_ IS
'图标宽度';

COMMENT ON COLUMN FORM_CUSTOM_CHART.HEIGHT_ IS
'图表宽度';

CREATE TABLE FORM_CUSTOM_DIALOG (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   ALIAS_               VARCHAR(64)          NOT NULL,
   STYLE_               INT2                 NULL DEFAULT NULL,
   OBJ_NAME_            VARCHAR(64)          NULL DEFAULT NULL,
   NEED_PAGE_           INT2                 NULL DEFAULT NULL,
   PAGE_SIZE_           INT4                 NULL DEFAULT NULL,
   DISPLAYFIELD_        TEXT                 NULL,
   CONDITIONFIELD_      TEXT                 NULL,
   RESULTFIELD_         TEXT                 NULL,
   SORTFIELD_           VARCHAR(200)         NULL DEFAULT NULL,
   DSALIAS_             VARCHAR(64)          NULL DEFAULT NULL,
   IS_TABLE_            INT2                 NULL DEFAULT NULL,
   DIY_SQL_             TEXT                 NULL DEFAULT NULL,
   SQL_BUILD_TYPE_      INT2                 NULL DEFAULT NULL,
   WIDTH_               INT4                 NULL DEFAULT NULL,
   HEIGHT_              INT4                 NULL DEFAULT NULL,
   SELECT_NUM_          INT4                 NULL DEFAULT NULL,
   SYSTEM_              INT2                 NULL DEFAULT 0,
   PARENT_CHECK_        INT2                 NULL DEFAULT NULL,
   CHILDREN_CHECK_      INT2                 NULL DEFAULT NULL,
   DS_TYPE_             VARCHAR(20)          NULL DEFAULT NULL,
   URL_                 VARCHAR(255)         NULL DEFAULT NULL,
   REQUEST_TYPE_        VARCHAR(20)          NULL DEFAULT NULL,
   DATA_PARAM_          VARCHAR(2000)        NULL DEFAULT NULL,
   PAGE_KEY_            VARCHAR(20)          NULL DEFAULT NULL,
   PAGESIZE_KEY_        VARCHAR(20)          NULL DEFAULT NULL,
   TOTAL_KEY_           VARCHAR(20)          NULL DEFAULT NULL,
   LIST_KEY_            VARCHAR(20)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   HEADER_              VARCHAR(512)         NULL DEFAULT NULL,
   COMBINATION_RULE_    TEXT                 NULL,
   CONSTRAINT PK_FORM_CUSTOM_DIALOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_CUSTOM_DIALOG IS
'自定义对话框';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.NAME_ IS
'名字';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.STYLE_ IS
'显示样式：0-列表，1-树形';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.OBJ_NAME_ IS
'对象名称，如果是表就是表名，视图则视图名';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.NEED_PAGE_ IS
'是否分页';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.PAGE_SIZE_ IS
'分页大小';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.DISPLAYFIELD_ IS
'显示字段';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.CONDITIONFIELD_ IS
'条件字段的json';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.RESULTFIELD_ IS
'返回字段json';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.SORTFIELD_ IS
'排序字段';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.DSALIAS_ IS
'数据源的别名';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.IS_TABLE_ IS
'是否数据库表0:视图,1:数据库表';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.DIY_SQL_ IS
'自定义SQL';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.SQL_BUILD_TYPE_ IS
'SQL构建类型';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.WIDTH_ IS
'弹出框的宽度';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.HEIGHT_ IS
'弹出框的高度';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.SELECT_NUM_ IS
'是否单选 -1:多选';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.SYSTEM_ IS
'系统默认';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.PARENT_CHECK_ IS
'树多选父级级联';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.CHILDREN_CHECK_ IS
'树多选子级级联';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.DS_TYPE_ IS
'数据源类型';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.URL_ IS
'接口地址';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.REQUEST_TYPE_ IS
'接口请求类型（GETPOST）';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.DATA_PARAM_ IS
'接口参数';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.PAGE_KEY_ IS
'页号（key）';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.PAGESIZE_KEY_ IS
'分页大小(key)';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.TOTAL_KEY_ IS
'总条数（key）';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.LIST_KEY_ IS
'列表(key)';

COMMENT ON COLUMN FORM_CUSTOM_DIALOG.HEADER_ IS
'头部信息';

CREATE TABLE FORM_CUSTOM_QUERY (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   ALIAS_               VARCHAR(64)          NOT NULL,
   OBJ_NAME_            VARCHAR(64)          NULL DEFAULT NULL,
   NEED_PAGE_           INT2                 NULL DEFAULT NULL,
   PAGE_SIZE_           INT4                 NULL DEFAULT NULL,
   CONDITIONFIELD_      TEXT                 NULL,
   RESULTFIELD_         TEXT                 NULL,
   SORTFIELD_           TEXT                 NULL,
   DSALIAS_             VARCHAR(64)          NULL DEFAULT NULL,
   IS_TABLE_            INT2                 NULL DEFAULT NULL,
   DIY_SQL_             TEXT                 NULL DEFAULT NULL,
   SQL_BUILD_TYPE_      INT2                 NULL DEFAULT NULL,
   DS_TYPE_             VARCHAR(20)          NULL DEFAULT NULL,
   URL_                 VARCHAR(1000)        NULL DEFAULT NULL,
   REQUEST_TYPE_        VARCHAR(20)          NULL DEFAULT NULL,
   DATA_PARAM_          VARCHAR(2000)        NULL DEFAULT NULL,
   PAGE_KEY_            VARCHAR(20)          NULL DEFAULT NULL,
   PAGESIZE_KEY_        VARCHAR(20)          NULL DEFAULT NULL,
   TOTAL_KEY_           VARCHAR(20)          NULL DEFAULT NULL,
   LIST_KEY_            VARCHAR(20)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   HEADER_              VARCHAR(512)         NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_CUSTOM_QUERY PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_CUSTOM_QUERY IS
'自定义查询';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.NAME_ IS
'名字';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.NEED_PAGE_ IS
'是否分页';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.PAGE_SIZE_ IS
'分页大小';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.CONDITIONFIELD_ IS
'条件字段的json';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.RESULTFIELD_ IS
'返回字段json';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.SORTFIELD_ IS
'排序字段';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.DSALIAS_ IS
'数据源的别名';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.IS_TABLE_ IS
'是否数据库表0:视图,1:数据库表';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.DIY_SQL_ IS
'自定义SQL';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.SQL_BUILD_TYPE_ IS
'SQL构建类型';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.DS_TYPE_ IS
'数据源类型';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.URL_ IS
'接口地址';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.REQUEST_TYPE_ IS
'接口请求类型（GETPOST）';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.DATA_PARAM_ IS
'接口参数';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.PAGE_KEY_ IS
'页号（key）';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.PAGESIZE_KEY_ IS
'分页大小(key)';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.TOTAL_KEY_ IS
'总条数（key）';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.LIST_KEY_ IS
'列表(key)';

COMMENT ON COLUMN FORM_CUSTOM_QUERY.HEADER_ IS
'头部信息';

CREATE TABLE FORM_DATA_IMPORT_LOG (
   ID_                  VARCHAR(64)          NOT NULL,
   P_ID_                VARCHAR(64)          NULL DEFAULT NULL,
   ROW_NUMBER_          INT4                 NULL DEFAULT NULL,
   COLUMN_NAME_         VARCHAR(64)          NULL DEFAULT NULL,
   ERROR_MSG_           TEXT                 NULL,
   BO_ALIAS_            VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_DATA_IMPORT_LOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_DATA_IMPORT_LOG IS
'数据导入日志';

COMMENT ON COLUMN FORM_DATA_IMPORT_LOG.ROW_NUMBER_ IS
'错误行号';

COMMENT ON COLUMN FORM_DATA_IMPORT_LOG.COLUMN_NAME_ IS
'错误列号';

COMMENT ON COLUMN FORM_DATA_IMPORT_LOG.ERROR_MSG_ IS
'错误信息';

COMMENT ON COLUMN FORM_DATA_IMPORT_LOG.BO_ALIAS_ IS
'bo别名';

CREATE TABLE FORM_DATA_TEMPLATE (
   ID_                  VARCHAR(64)          NOT NULL,
   BO_DEF_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   BO_DEF_ALIAS_        VARCHAR(128)         NULL DEFAULT NULL,
   FORM_KEY_            VARCHAR(126)         NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(128)         NULL DEFAULT NULL,
   STYLE_               INT2                 NULL DEFAULT NULL,
   NEED_PAGE_           INT2                 NULL DEFAULT 1,
   PAGE_SIZE_           INT2                 NULL DEFAULT NULL,
   TEMPLATE_ALIAS_      VARCHAR(128)         NULL DEFAULT NULL,
   TEMPLATE_HTML_       TEXT                 NULL,
   DISPLAY_FIELD_       TEXT                 NULL,
   SORT_FIELD_          TEXT                 NULL,
   CONDITION_FIELD_     TEXT                 NULL,
   MANAGE_FIELD_        TEXT                 NULL DEFAULT NULL,
   FILTER_FIELD_        TEXT                 NULL,
   VAR_FIELD_           VARCHAR(200)         NULL DEFAULT NULL,
   FILTER_TYPE_         INT2                 NULL DEFAULT NULL,
   SOURCE_              INT2                 NULL DEFAULT NULL,
   DEF_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   IS_QUERY_            INT2                 NULL DEFAULT 1,
   IS_FILTER_           INT2                 NULL DEFAULT 1,
   EXPORT_FIELD_        TEXT                 NULL,
   PRINT_FIELD_         TEXT                 NULL,
   SUBJECT_             VARCHAR(255)         NULL DEFAULT NULL,
   FORM_FIELD_          TEXT                 NULL,
   TYPE_ID_             VARCHAR(50)          NULL DEFAULT NULL,
   TYPE_NAME_           VARCHAR(100)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   MOBILE_FORM_ALIAS_   VARCHAR(255)         NULL DEFAULT NULL,
   MOBILE_FORM_NAME_    VARCHAR(255)         NULL DEFAULT NULL,
   TREE_FIELD_          TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(200)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   FILTERING_FIELD_     TEXT                 NULL,
   SUMMARY_FIELD_       TEXT                 NULL DEFAULT NULL,
   BEFORE_SCRIPT_       TEXT                 NULL,
   AFTER_FCRIPT_        TEXT                 NULL,
   SUB_FIELD_           TEXT                 NULL,
   ALLOW_SHARE_         INT2                 NULL DEFAULT 2,
   RESET_TEMP_          INT2                 NULL,
   CONSTRAINT PK_FORM_DATA_TEMPLATE PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_DATA_TEMPLATE IS
'数据视图';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.BO_DEF_ID_ IS
'业务对象定义id';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.BO_DEF_ALIAS_ IS
'业务对象定义别名';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.FORM_KEY_ IS
'自定义表单key';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.NAME_ IS
'名称';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.STYLE_ IS
'样式';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.NEED_PAGE_ IS
'是否需要分页 0不分页  1分页';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.PAGE_SIZE_ IS
'分页大小';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.TEMPLATE_ALIAS_ IS
'数据模板别名';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.MANAGE_FIELD_ IS
'管理字段';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.VAR_FIELD_ IS
'变量字段';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.FILTER_TYPE_ IS
'过滤类型（1.建立条件,2.脚本条件）';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.SOURCE_ IS
'数据来源';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.IS_QUERY_ IS
'是否查询';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.IS_FILTER_ IS
'是否过滤';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.BEFORE_SCRIPT_ IS
'前置groovy脚本';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.AFTER_FCRIPT_ IS
'后置groovy脚本';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.SUB_FIELD_ IS
'子表字段';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.ALLOW_SHARE_ IS
'是否允许外链。1，允许。2，不允许';

COMMENT ON COLUMN FORM_DATA_TEMPLATE.RESET_TEMP_ IS
'是否需要初始化模板 1: 是 0: 否';

CREATE TABLE FORM_DATA_TEMPLATE_DRAFT (
   ID_                  VARCHAR(64)          NOT NULL,
   TITLE_               VARCHAR(255)         NULL DEFAULT NULL,
   TEMP_ALIAS_          VARCHAR(64)          NULL DEFAULT NULL,
   DATA_JSON_           TEXT                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_DATA_TEMPLATE_DRAFT PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_DATA_TEMPLATE_DRAFT IS
'数据报表草稿数据';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.ID_ IS
'主键';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.TITLE_ IS
'标题';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.TEMP_ALIAS_ IS
'数据报表别名';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.DATA_JSON_ IS
'报表数据json';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.UPDATE_TIME_ IS
'更新时间';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_DRAFT.TENANT_ID_ IS
'租户id';

CREATE TABLE FORM_DATA_TEMPLATE_EXTEND (
   ID_                  VARCHAR(64)          NOT NULL,
   CONTENT_             TEXT                 NULL,
   COUNT_               VARCHAR(64)          NULL DEFAULT NULL,
   OBJ_ID_              VARCHAR(2000)        NULL,
   TYPE_OBJ_            VARCHAR(64)          NULL DEFAULT NULL,
   OBJ_NAME_            TEXT                 NULL,
   RULE_                TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   FORM_DATA_TEMPLATE_ID VARCHAR(64)          NULL DEFAULT NULL,
   SUBJECT_             VARCHAR(500)         NULL,
   CONSTRAINT PK_FORM_DATA_TEMPLATE_EXTEND PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_DATA_TEMPLATE_EXTEND IS
'业务数据模板扩展';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.ID_ IS
'主键';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.CONTENT_ IS
'提醒内容';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.COUNT_ IS
'提醒次数';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.OBJ_ID_ IS
'提醒对象ID';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.TYPE_OBJ_ IS
'提醒内型';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.OBJ_NAME_ IS
'提醒对象名称';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.RULE_ IS
'提醒条件';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.TENANT_ID_ IS
'租户Id';

COMMENT ON COLUMN FORM_DATA_TEMPLATE_EXTEND.SUBJECT_ IS
'提醒主题';

CREATE TABLE FORM_DEFINITION (
   ID_                  VARCHAR(50)          NOT NULL,
   DEF_ID_              VARCHAR(50)          NULL DEFAULT NULL,
   NAME_                VARCHAR(200)         NULL DEFAULT NULL,
   FORM_KEY_            VARCHAR(50)          NULL DEFAULT NULL,
   DESC_                VARCHAR(200)         NULL DEFAULT NULL,
   FORM_HTML_           TEXT                 NULL,
   STATUS_              VARCHAR(20)          NULL DEFAULT NULL,
   FORM_TYPE_           VARCHAR(20)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(50)          NULL DEFAULT NULL,
   TYPE_NAME_           VARCHAR(100)         NULL DEFAULT NULL,
   IS_MAIN_             CHAR(1)              NULL DEFAULT NULL,
   VERSION_             INT4                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(50)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(50)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   FORM_TAB_TITLE_      VARCHAR(200)         NULL DEFAULT NULL,
   DIY_JS_              TEXT                 NULL,
   EXPAND_              TEXT                 NULL,
   IS_PRINT_            CHAR(1)              NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   FORM_SETTING_        TEXT                 NULL,
   CONSTRAINT PK_FORM_DEFINITION PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_DEFINITION IS
'表单定义';

COMMENT ON COLUMN FORM_DEFINITION.DEF_ID_ IS
'表单元数据定义ID';

COMMENT ON COLUMN FORM_DEFINITION.NAME_ IS
'表单名称';

COMMENT ON COLUMN FORM_DEFINITION.FORM_KEY_ IS
'表单key';

COMMENT ON COLUMN FORM_DEFINITION.DESC_ IS
'描述';

COMMENT ON COLUMN FORM_DEFINITION.FORM_HTML_ IS
'表单定义HTML';

COMMENT ON COLUMN FORM_DEFINITION.STATUS_ IS
'状态 draft=草稿；deploy=发布';

COMMENT ON COLUMN FORM_DEFINITION.FORM_TYPE_ IS
'表单类型 分为 pc,mobile';

COMMENT ON COLUMN FORM_DEFINITION.TYPE_ID_ IS
'所属分类ID';

COMMENT ON COLUMN FORM_DEFINITION.TYPE_NAME_ IS
'分类名称';

COMMENT ON COLUMN FORM_DEFINITION.IS_MAIN_ IS
'是否主版本';

COMMENT ON COLUMN FORM_DEFINITION.VERSION_ IS
'版本号';

COMMENT ON COLUMN FORM_DEFINITION.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN FORM_DEFINITION.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN FORM_DEFINITION.FORM_TAB_TITLE_ IS
'表单tab标题';

COMMENT ON COLUMN FORM_DEFINITION.IS_PRINT_ IS
'是否为打印模板（Y：是，N：否）';

COMMENT ON COLUMN FORM_DEFINITION.FORM_SETTING_ IS
'表单设置';

CREATE TABLE FORM_DEFINITION_HI (
   ID_                  VARCHAR(64)          NOT NULL,
   FORM_ID_             VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   FORM_HTML_           TEXT                 NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   FORM_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   VERSION_             VARCHAR(20)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_DEFINITION_HI PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_DEFINITION_HI IS
'流程表单HTML设计历史记录';

COMMENT ON COLUMN FORM_DEFINITION_HI.FORM_ID_ IS
'对应表单ID';

COMMENT ON COLUMN FORM_DEFINITION_HI.NAME_ IS
'表单名称';

COMMENT ON COLUMN FORM_DEFINITION_HI.DESC_ IS
'表单描述';

COMMENT ON COLUMN FORM_DEFINITION_HI.FORM_HTML_ IS
'表单设计（HTML代码）';

CREATE TABLE FORM_FIELD (
   ID_                  VARCHAR(20)          NOT NULL,
   NAME_                VARCHAR(50)          NULL DEFAULT NULL,
   DESC_                VARCHAR(100)         NULL DEFAULT NULL,
   FORM_ID_             VARCHAR(50)          NULL DEFAULT NULL,
   BO_DEF_ID_           VARCHAR(50)          NULL DEFAULT NULL,
   ENT_ID_              VARCHAR(255)         NULL DEFAULT NULL,
   GROUP_ID_            VARCHAR(50)          NULL DEFAULT NULL,
   CALCULATION_         TEXT                 NULL,
   TYPE_                VARCHAR(50)          NULL DEFAULT NULL,
   BO_ATTR_ID_          VARCHAR(50)          NULL DEFAULT NULL,
   CTRL_TYPE_           VARCHAR(50)          NULL DEFAULT NULL,
   VALID_RULE_          TEXT                 NULL,
   OPTION_              TEXT                 NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_FIELD PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_FIELD IS
'表单字段定义';

COMMENT ON COLUMN FORM_FIELD.NAME_ IS
'字段名';

COMMENT ON COLUMN FORM_FIELD.DESC_ IS
'描述';

COMMENT ON COLUMN FORM_FIELD.FORM_ID_ IS
'表单元数据ID';

COMMENT ON COLUMN FORM_FIELD.BO_DEF_ID_ IS
'BO定义ID';

COMMENT ON COLUMN FORM_FIELD.ENT_ID_ IS
'实体ID';

COMMENT ON COLUMN FORM_FIELD.GROUP_ID_ IS
'分组ID';

COMMENT ON COLUMN FORM_FIELD.CALCULATION_ IS
'计算表达式';

COMMENT ON COLUMN FORM_FIELD.TYPE_ IS
'数据类型';

COMMENT ON COLUMN FORM_FIELD.BO_ATTR_ID_ IS
'BO属性定义';

COMMENT ON COLUMN FORM_FIELD.CTRL_TYPE_ IS
'控件类型';

COMMENT ON COLUMN FORM_FIELD.VALID_RULE_ IS
'验证规则';

COMMENT ON COLUMN FORM_FIELD.OPTION_ IS
'表单配置选项';

COMMENT ON COLUMN FORM_FIELD.SN_ IS
'排序';

CREATE TABLE FORM_FIELD_AUTH (
   ID_                  VARCHAR(64)          NOT NULL,
   DS_ALIAS_            VARCHAR(64)          NULL DEFAULT NULL,
   TABLE_NAME_          VARCHAR(64)          NULL DEFAULT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   ENT_NAME_            VARCHAR(64)          NULL DEFAULT NULL,
   CLASS_NAME_          VARCHAR(64)          NULL DEFAULT NULL,
   CLASS_PATH_          VARCHAR(300)         NULL DEFAULT NULL,
   FIELD_LIST_          TEXT                 NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_FIELD_AUTH PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_FIELD_AUTH IS
'字段授权信息';

COMMENT ON COLUMN FORM_FIELD_AUTH.DS_ALIAS_ IS
'数据源别名';

COMMENT ON COLUMN FORM_FIELD_AUTH.TABLE_NAME_ IS
'表名';

COMMENT ON COLUMN FORM_FIELD_AUTH.DESC_ IS
'描述';

COMMENT ON COLUMN FORM_FIELD_AUTH.ENT_NAME_ IS
'实体别名';

COMMENT ON COLUMN FORM_FIELD_AUTH.CLASS_NAME_ IS
'类名';

COMMENT ON COLUMN FORM_FIELD_AUTH.CLASS_PATH_ IS
'类路径';

COMMENT ON COLUMN FORM_FIELD_AUTH.FIELD_LIST_ IS
'字段列表（权限设置）';

COMMENT ON COLUMN FORM_FIELD_AUTH.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN FORM_FIELD_AUTH.UPDATE_BY_ IS
'更新人';

CREATE TABLE FORM_HISTORY_RECORD (
   ID_                  VARCHAR(64)          NOT NULL,
   FORM_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   FORM_HTML_           TEXT                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   FORM_KEY_            VARCHAR(255)         NULL DEFAULT NULL,
   VERSION_             INT4                 NULL DEFAULT NULL,
   FORM_EXPAND_         TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_HISTORY_RECORD PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_HISTORY_RECORD IS
'表单历史数据';

COMMENT ON COLUMN FORM_HISTORY_RECORD.FORM_KEY_ IS
'表单key';

COMMENT ON COLUMN FORM_HISTORY_RECORD.VERSION_ IS
'版本';

COMMENT ON COLUMN FORM_HISTORY_RECORD.FORM_EXPAND_ IS
'表单 json 数据';

CREATE TABLE FORM_IMPORT_CHECK_JAR (
   ID_                  VARCHAR(64)          NOT NULL,
   CLASS_PATH_          VARCHAR(255)         NULL DEFAULT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   FILE_PATH_           VARCHAR(512)         NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_IMPORT_CHECK_JAR PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_IMPORT_CHECK_JAR IS
'校验包导入表';

COMMENT ON COLUMN FORM_IMPORT_CHECK_JAR.CLASS_PATH_ IS
'校验类路径';

COMMENT ON COLUMN FORM_IMPORT_CHECK_JAR.DESC_ IS
'描述';

COMMENT ON COLUMN FORM_IMPORT_CHECK_JAR.FILE_PATH_ IS
'校验jar包位置';

CREATE TABLE FORM_META (
   ID_                  VARCHAR(50)          NOT NULL,
   KEY_                 VARCHAR(50)          NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(50)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(50)          NULL DEFAULT NULL,
   EXPAND_              TEXT                 NULL,
   OPINION_CONF_        VARCHAR(1000)        NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(50)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(50)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   DESC_                VARCHAR(200)         NULL DEFAULT NULL,
   GANGED_              TEXT                 NULL,
   MACROALIAS_          VARCHAR(50)          NULL DEFAULT NULL,
   MAINALIAS_           VARCHAR(50)          NULL DEFAULT NULL,
   SUBENTITY_           VARCHAR(255)         NULL DEFAULT NULL,
   REV_                 INT4                 NOT NULL DEFAULT 1,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_META PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_META IS
'表单元数据定义';

COMMENT ON COLUMN FORM_META.KEY_ IS
'表单key值';

COMMENT ON COLUMN FORM_META.NAME_ IS
'定义名称';

COMMENT ON COLUMN FORM_META.TYPE_ IS
'分类名称';

COMMENT ON COLUMN FORM_META.TYPE_ID_ IS
'分类';

COMMENT ON COLUMN FORM_META.EXPAND_ IS
'扩展字段';

COMMENT ON COLUMN FORM_META.OPINION_CONF_ IS
'意见配置';

COMMENT ON COLUMN FORM_META.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN FORM_META.UPDATE_BY_ IS
'最后更新人';

COMMENT ON COLUMN FORM_META.DESC_ IS
'描述';

COMMENT ON COLUMN FORM_META.GANGED_ IS
'联动设置';

COMMENT ON COLUMN FORM_META.MACROALIAS_ IS
'宏模板';

COMMENT ON COLUMN FORM_META.MAINALIAS_ IS
'表单模板';

COMMENT ON COLUMN FORM_META.SUBENTITY_ IS
'子实体模板';

COMMENT ON COLUMN FORM_META.REV_ IS
'关联锁';

CREATE TABLE FORM_PRINT_TEMPLATE (
   ID_                  VARCHAR(64)          NOT NULL,
   FILE_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   FILE_NAME            VARCHAR(64)          NULL DEFAULT NULL,
   FORM_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   IS_MAIN              VARCHAR(10)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   DEF_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   FORM_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   PRINT_TYPE_          VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   SCRIPT_STR_          TEXT                 NULL,
   CONSTRAINT PK_FORM_PRINT_TEMPLATE PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_PRINT_TEMPLATE IS
'打印模板';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.FILE_ID_ IS
'附件ID';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.FILE_NAME IS
'打印模板名称';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.FORM_KEY_ IS
'表单Key';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.IS_MAIN IS
'是否是主版本';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.DEF_ID_ IS
'表单元数据id';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.FORM_ID_ IS
'表单id';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.PRINT_TYPE_ IS
'打印类型(word:word套打，form:表单模板)';

COMMENT ON COLUMN FORM_PRINT_TEMPLATE.TENANT_ID_ IS
'租户id';

CREATE TABLE FORM_QUERY_METAFIELD (
   ID_                  VARCHAR(50)          NOT NULL,
   SQL_ID_              VARCHAR(50)          NULL DEFAULT NULL,
   NAME_                VARCHAR(100)         NULL DEFAULT NULL,
   FIELD_NAME_          VARCHAR(50)          NULL DEFAULT NULL,
   FIELD_DESC_          VARCHAR(100)         NULL DEFAULT NULL,
   IS_SHOW_             INT2                 NULL DEFAULT NULL,
   IS_SEARCH_           INT2                 NULL DEFAULT NULL,
   IS_COMBINE_          INT2                 NULL DEFAULT NULL,
   CONTROL_TYPE_        VARCHAR(32)          NULL DEFAULT NULL,
   DATA_TYPE_           VARCHAR(32)          NULL DEFAULT NULL,
   IS_VIRTUAL_          INT2                 NULL DEFAULT NULL,
   VIRTUAL_FROM_        VARCHAR(50)          NULL DEFAULT NULL,
   RESULT_FROM_TYPE_    VARCHAR(16)          NULL DEFAULT NULL,
   RESULT_FROM_         VARCHAR(500)         NULL DEFAULT NULL,
   ALARM_SETTING_       VARCHAR(500)         NULL DEFAULT NULL,
   DATE_FORMAT_         VARCHAR(50)          NULL DEFAULT NULL,
   URL_                 VARCHAR(200)         NULL DEFAULT NULL,
   FORMATER_            TEXT                 NULL,
   CONTROL_CONTENT_     VARCHAR(500)         NULL DEFAULT NULL,
   SN_                  INT2                 NULL DEFAULT NULL,
   WIDTH_               INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_QUERY_METAFIELD PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_QUERY_METAFIELD IS
'SQL 字段元数据';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.SQL_ID_ IS
'SQL_ID_';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.NAME_ IS
'字段名';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.FIELD_NAME_ IS
'实际字段名';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.FIELD_DESC_ IS
'字段备注';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.IS_SHOW_ IS
'是否可见';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.IS_SEARCH_ IS
'是否搜索';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.IS_COMBINE_ IS
'是否合并查询';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.CONTROL_TYPE_ IS
'控件类型';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.DATA_TYPE_ IS
'数据类型';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.IS_VIRTUAL_ IS
'是否衍生列';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.VIRTUAL_FROM_ IS
'衍生列来自列';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.RESULT_FROM_TYPE_ IS
'来自类型';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.RESULT_FROM_ IS
'衍生列配置';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.ALARM_SETTING_ IS
'报警设定';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.DATE_FORMAT_ IS
'日期格式';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.URL_ IS
'连接地址';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.CONTROL_CONTENT_ IS
'控件内容';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.SN_ IS
'排序';

COMMENT ON COLUMN FORM_QUERY_METAFIELD.WIDTH_ IS
'宽度';

CREATE TABLE FORM_QUERY_SQLDEF (
   ID_                  VARCHAR(50)          NOT NULL,
   ALIAS_               VARCHAR(50)          NULL DEFAULT NULL,
   NAME_                VARCHAR(50)          NULL DEFAULT NULL,
   DS_NAME_             VARCHAR(50)          NULL DEFAULT NULL,
   SQL_                 VARCHAR(1000)        NULL DEFAULT NULL,
   CATEGORY_ID_         VARCHAR(50)          NULL DEFAULT NULL,
   SUPPORT_TAB_         INT2                 NULL DEFAULT NULL,
   BUTTON_DEF_          VARCHAR(2000)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_QUERY_SQLDEF PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_QUERY_SQLDEF IS
'自定义SQL定义';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.NAME_ IS
'sql定义名称';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.DS_NAME_ IS
'数据源名称';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.SQL_ IS
'SQL语句';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.CATEGORY_ID_ IS
'分类ID';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.SUPPORT_TAB_ IS
'是否支持TAB';

COMMENT ON COLUMN FORM_QUERY_SQLDEF.BUTTON_DEF_ IS
'按钮定义';

CREATE TABLE FORM_QUERY_VIEW (
   ID_                  VARCHAR(50)          NOT NULL,
   SQL_ALIAS_           VARCHAR(50)          NULL DEFAULT NULL,
   ALIAS_               VARCHAR(50)          NULL DEFAULT NULL,
   NAME_                VARCHAR(50)          NULL DEFAULT NULL,
   CONDITIONS_          TEXT                 NULL,
   FILTER_TYPE_         INT2                 NULL DEFAULT NULL,
   FILTER_              TEXT                 NULL,
   BUTTONS_             VARCHAR(1500)        NULL DEFAULT NULL,
   INIT_QUERY_          INT2                 NULL DEFAULT NULL,
   TEMPLATE_            TEXT                 NULL,
   SUPPORT_GROUP_       INT2                 NULL DEFAULT NULL,
   GROUP_SETTING_       VARCHAR(500)         NULL DEFAULT NULL,
   PAGE_SIZE_           INT2                 NULL DEFAULT NULL,
   SHOW_ROWS_NUM_       INT2                 NULL DEFAULT NULL,
   SN_                  INT2                 NULL DEFAULT NULL,
   NEED_PAGE_           INT2                 NULL DEFAULT NULL,
   TEMPLATE_ALIAS_      VARCHAR(50)          NULL DEFAULT NULL,
   SHOWS_               TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   SUMMARY_SETTING_     TEXT                 NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_QUERY_VIEW PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_QUERY_VIEW IS
'SQL视图定义';

COMMENT ON COLUMN FORM_QUERY_VIEW.SQL_ALIAS_ IS
'sql别名';

COMMENT ON COLUMN FORM_QUERY_VIEW.ALIAS_ IS
'视图别名';

COMMENT ON COLUMN FORM_QUERY_VIEW.NAME_ IS
'视图名称';

COMMENT ON COLUMN FORM_QUERY_VIEW.FILTER_TYPE_ IS
'过滤器类型';

COMMENT ON COLUMN FORM_QUERY_VIEW.BUTTONS_ IS
'按纽定义';

COMMENT ON COLUMN FORM_QUERY_VIEW.INIT_QUERY_ IS
'是否初始化查询';

COMMENT ON COLUMN FORM_QUERY_VIEW.SUPPORT_GROUP_ IS
'是否支持分组';

COMMENT ON COLUMN FORM_QUERY_VIEW.GROUP_SETTING_ IS
'分组设定';

COMMENT ON COLUMN FORM_QUERY_VIEW.PAGE_SIZE_ IS
'分页大小';

COMMENT ON COLUMN FORM_QUERY_VIEW.SHOW_ROWS_NUM_ IS
'显示行号';

COMMENT ON COLUMN FORM_QUERY_VIEW.SN_ IS
'排序';

COMMENT ON COLUMN FORM_QUERY_VIEW.NEED_PAGE_ IS
'是否分页';

COMMENT ON COLUMN FORM_QUERY_VIEW.TEMPLATE_ALIAS_ IS
'摸版别名';

CREATE TABLE FORM_REMIND_DATA (
   ID_                  VARCHAR(64)          NOT NULL,
   CONTENT_             TEXT                 NULL,
   COUNT_               VARCHAR(64)          NULL DEFAULT NULL,
   OBJ_ID_              VARCHAR(2000)        NULL,
   TYPE_OBJ_            VARCHAR(64)          NULL DEFAULT NULL,
   OPEM_TYPE            VARCHAR(64)          NULL DEFAULT NULL,
   OPEM_ID              VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   SUBJECT_             VARCHAR(500)         NULL,
   REF_ID_              VARCHAR(64)          NULL,
   CONSTRAINT PK_FORM_REMIND_DATA PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_REMIND_DATA IS
'提醒业务对象';

COMMENT ON COLUMN FORM_REMIND_DATA.ID_ IS
'主键';

COMMENT ON COLUMN FORM_REMIND_DATA.CONTENT_ IS
'提醒内容';

COMMENT ON COLUMN FORM_REMIND_DATA.COUNT_ IS
'提醒次数';

COMMENT ON COLUMN FORM_REMIND_DATA.OBJ_ID_ IS
'提醒对象ID';

COMMENT ON COLUMN FORM_REMIND_DATA.TYPE_OBJ_ IS
'提醒类型';

COMMENT ON COLUMN FORM_REMIND_DATA.OPEM_TYPE IS
'打开类型  数据报表 或者流程实例查看页面';

COMMENT ON COLUMN FORM_REMIND_DATA.OPEM_ID IS
'流程实例Id 或者业务对象Id';

COMMENT ON COLUMN FORM_REMIND_DATA.TENANT_ID_ IS
'租户Id';

COMMENT ON COLUMN FORM_REMIND_DATA.SUBJECT_ IS
'提醒主题';

COMMENT ON COLUMN FORM_REMIND_DATA.REF_ID_ IS
'外键';

CREATE TABLE FORM_RIGHT (
   ID_                  VARCHAR(64)          NOT NULL,
   FORM_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   FLOW_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(60)          NULL DEFAULT NULL,
   PARENT_FLOW_KEY_     VARCHAR(64)          NULL DEFAULT NULL,
   PERMISSION_          TEXT                 NULL,
   PERMISSION_TYPE_     INT4                 NULL DEFAULT NULL,
   IS_CHECK_OPINION     VARCHAR(255)         NULL DEFAULT NULL,
   DATA_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_RIGHT PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_RIGHT IS
'表单权限';

COMMENT ON COLUMN FORM_RIGHT.FORM_KEY_ IS
'表单KEY';

COMMENT ON COLUMN FORM_RIGHT.FLOW_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN FORM_RIGHT.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN FORM_RIGHT.PARENT_FLOW_KEY_ IS
'父流程key';

COMMENT ON COLUMN FORM_RIGHT.PERMISSION_ IS
'权限';

COMMENT ON COLUMN FORM_RIGHT.PERMISSION_TYPE_ IS
'权限类型 1 流程权限，2 实例权限';

COMMENT ON COLUMN FORM_RIGHT.IS_CHECK_OPINION IS
'是否隐藏审批记录';

COMMENT ON COLUMN FORM_RIGHT.DATA_KEY_ IS
'数据报表Key';

CREATE TABLE FORM_TEMPLATE (
   TEMPLATE_ID_         VARCHAR(64)          NOT NULL,
   TEMPLATE_NAME_       VARCHAR(200)         NULL DEFAULT NULL,
   TEMPLATE_TYPE_       VARCHAR(20)          NULL DEFAULT NULL,
   MACROTEMPLATE_ALIAS_ VARCHAR(50)          NULL DEFAULT NULL,
   HTML_                TEXT                 NULL,
   TEMPLATE_DESC_       VARCHAR(400)         NULL DEFAULT NULL,
   CANEDIT_             INT4                 NULL DEFAULT NULL,
   ALIAS_               VARCHAR(50)          NULL DEFAULT NULL,
   SOURCE_              VARCHAR(20)          NULL DEFAULT NULL,
   REV_                 INT4                 NOT NULL DEFAULT 1,
   IS_DEFAULT_          INT2                 NULL DEFAULT 0,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_TEMPLATE PRIMARY KEY (TEMPLATE_ID_)
);

COMMENT ON TABLE FORM_TEMPLATE IS
'表单模版';

COMMENT ON COLUMN FORM_TEMPLATE.TEMPLATE_ID_ IS
'模板id';

COMMENT ON COLUMN FORM_TEMPLATE.TEMPLATE_NAME_ IS
'模板名称';

COMMENT ON COLUMN FORM_TEMPLATE.TEMPLATE_TYPE_ IS
'模板类型';

COMMENT ON COLUMN FORM_TEMPLATE.MACROTEMPLATE_ALIAS_ IS
'模板所向';

COMMENT ON COLUMN FORM_TEMPLATE.HTML_ IS
'模板内容';

COMMENT ON COLUMN FORM_TEMPLATE.TEMPLATE_DESC_ IS
'模板描述';

COMMENT ON COLUMN FORM_TEMPLATE.CANEDIT_ IS
'是否可以编辑';

COMMENT ON COLUMN FORM_TEMPLATE.ALIAS_ IS
'别名';

COMMENT ON COLUMN FORM_TEMPLATE.REV_ IS
'关联锁';

COMMENT ON COLUMN FORM_TEMPLATE.IS_DEFAULT_ IS
'0：非默认模板 1：默认模板';

CREATE TABLE FORM_VIEW_MANAGE (
   ID_                  VARCHAR(64)          NOT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   VIEW_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   SQL_                 VARCHAR(2000)        NULL DEFAULT NULL,
   DS_ALIAS_            VARCHAR(50)          NULL DEFAULT NULL,
   STATUS_              INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_FORM_VIEW_MANAGE PRIMARY KEY (ID_)
);

COMMENT ON TABLE FORM_VIEW_MANAGE IS
'视图管理';

COMMENT ON COLUMN FORM_VIEW_MANAGE.STATUS_ IS
'状态：0未生成视图，1已生成视图';

