You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by zh...@apache.org on 2022/12/12 14:37:57 UTC

[shenyu] branch master updated: [ISSUE #4029] add api doc upgrade sql (#4257)

This is an automated email from the ASF dual-hosted git repository.

zhangzicheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new d6b3de859 [ISSUE #4029] add api doc upgrade sql (#4257)
d6b3de859 is described below

commit d6b3de859880622873c8ef6618744a5f1612da37
Author: dragon-zhang <zh...@apache.org>
AuthorDate: Mon Dec 12 22:37:51 2022 +0800

    [ISSUE #4029] add api doc upgrade sql (#4257)
    
    Co-authored-by: hailang <a1...@hotmail.com>
    Co-authored-by: likeguo <33...@users.noreply.github.com>
---
 db/init/oracle/schema.sql                 |   3 +-
 db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql  | 126 +++++++++++++-
 db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql | 266 +++++++++++++++++++++++++++++-
 db/upgrade/2.5.0-upgrade-2.5.1-pg.sql     | 189 ++++++++++++++++++++-
 4 files changed, 577 insertions(+), 7 deletions(-)

diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql
index 6dec8aab4..a523296be 100644
--- a/db/init/oracle/schema.sql
+++ b/db/init/oracle/schema.sql
@@ -332,7 +332,7 @@ create table model
     model_desc VARCHAR2(1024) not null,
     date_created timestamp(3) default SYSDATE not null,
     date_updated timestamp(3) default SYSDATE not null
-)
+);
 -- Add comments to the table
 comment on table MODEL
   is 'model desc table';
@@ -2101,6 +2101,7 @@ on column TAG.tag_desc
 comment
 on column TAG.parent_tag_id
   is 'parent tag id';
+comment
 on column TAG.ext
   is 'extension info';
 comment
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql b/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
index feb9568f2..56708b16c 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
@@ -274,8 +274,7 @@ INSERT INTO `plugin` VALUES ('40', 'keyAuth', NULL, 'Authentication', 150, 0, '2
 -- ----------------------------
 -- Table structure for mock_request_record
 -- ----------------------------
-DROP TABLE IF EXISTS `mock_request_record`;
-CREATE TABLE `mock_request_record`  (
+CREATE TABLE IF NOT EXISTS `mock_request_record`  (
     `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
     `api_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the api id',
     `host` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the request host',
@@ -288,4 +287,125 @@ CREATE TABLE `mock_request_record`  (
     `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
     `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
     PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
\ No newline at end of file
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for api
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `api` (
+    `id`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `context_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the context_path',
+    `api_path`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the api_path',
+    `http_method`  int(0) NOT NULL COMMENT '0-get,1-head,2-post,3-put,4-patch,5-delete,6-options,7-trace',
+    `consume`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'consume content-type',
+    `produce`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'produce content-type',
+    `version`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api version,for example V0.01',
+    `rpc_type`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc',
+    `state`        tinyint(4) NOT NULL COMMENT '0-unpublished,1-published,2-offline',
+    `ext`          varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'extended fields',
+    `api_owner`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  NOT NULL COMMENT 'api_owner',
+    `api_desc`     varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the api description',
+    `api_source`   int(0) NOT NULL COMMENT '0-swagger,1-annotation generation,2-create manually,3-import swagger,4-import yapi',
+    `document`     text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'complete documentation of the api, including request parameters and response parameters',
+    `document_md5` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'document_md5',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for api_rule_relation
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `api_rule_relation`  (
+    `id`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `api_id`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the table api primary key id',
+    `rule_id`      varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the table rule primary key id',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for tag
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `tag`  (
+    `id`            varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `name`          varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'tag name',
+    `tag_desc`      varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'tag description',
+    `parent_tag_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'parent tag_id',
+    `ext`           varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'extension info',
+    `date_created`  timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated`  timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP (3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'api doc tag table' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for tag_relation
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `tag_relation`  (
+    `id`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `api_id`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'api id',
+    `tag_id`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'tag id',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP (3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'api doc and tag bind table' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for param
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `param`  (
+    `id`           varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `api_id`       varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the api id',
+    `model_id`     varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the model id, empty if not a model',
+    `type`         int(0) NOT NULL COMMENT '0-requestPathVariable,1-requestUrlParam,2-requestHeader,3-requestBody,4-responseHeader,5-responseBody',
+    `name`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the param name',
+    `param_desc`   varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the param description',
+    `required`     tinyint(0) NOT NULL COMMENT 'whether to require (0 not required, 1 required)',
+    `ext`          varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'extended fields',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for model
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `model`  (
+    `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the model name',
+    `model_desc`   varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the model description',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for field
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `field`  (
+    `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `model_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'this field belongs to which model',
+    `self_model_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'which model of this field is',
+    `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'field name',
+    `field_desc` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'field description',
+    `required`     tinyint(0) NOT NULL COMMENT 'whether to require (0 not required, 1 required)',
+    `ext`          varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'extended fields,can store genericTypes,eg..{"genericTypes":[model_id1,model_id2]}',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'field document table' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Table structure for detail
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `detail`  (
+    `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id',
+    `field_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the field id',
+    `is_example` tinyint(0) NOT NULL COMMENT 'is example or not (0 not, 1 is)',
+    `field_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the field value',
+    `value_desc` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'field value description',
+    `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time',
+    `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'field value detail table' ROW_FORMAT = Dynamic;
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql b/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
index 1aefb5423..f97f164bb 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
@@ -324,4 +324,268 @@ comment on column MOCK_REQUEST_RECORD.date_created
   is 'create time';
 comment on column MOCK_REQUEST_RECORD.date_updated
   is 'update time';
--- create mock_request_record table end
\ No newline at end of file
+-- create mock_request_record table end
+
+create table api
+(
+    id VARCHAR2 (128) not null,
+    context_path VARCHAR2 (255) not null,
+    api_path VARCHAR2 (255) not null,
+    http_method NUMBER (10) not null,
+    consume VARCHAR2 (255) not null,
+    produce VARCHAR2 (255) not null,
+    version VARCHAR2 (255) not null,
+    rpc_type VARCHAR2 (64) not null,
+    state NUMBER (10) not null,
+    ext VARCHAR2 (1025) not null,
+    api_owner VARCHAR2 (255) not null,
+    api_desc VARCHAR2 (1024) not null,
+    document CLOB not null,
+    document_md5 VARCHAR2 (32) not null,
+    api_source NUMBER (10) not null,
+    date_created timestamp(3) default SYSDATE not null,
+    date_updated timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the table
+comment on table API
+    is 'api document';
+-- Add comments to the columns
+comment on column API.id
+    is 'primary key id';
+comment on column API.context_path
+    is 'the context_path';
+comment on column API.api_path
+    is 'the api_path';
+comment on column API.http_method
+    is '0-get,1-head,2-post,3-put,4-patch,5-delete,6-options,7-trace';
+comment on column API.consume
+    is 'consume content-type';
+comment on column API.produce
+    is 'produce content-type';
+comment on column API.version
+    is 'api version,for example V0.01';
+comment on column API.rpc_type
+    is 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc';
+comment on column API.state
+    is '0-unpublished,1-published,2-offline';
+comment on column API.ext
+    is 'extended fields';
+comment on column API.api_owner
+    is 'api_owner';
+comment on column API.api_desc
+    is 'the api description';
+comment on column API.api_source
+    is '0-swagger,1-annotation generation,2-create manually,3-import swagger,4-import yapi';
+comment on column API.document
+    is 'complete documentation of the api, including request parameters and response parameters';
+comment on column API.document_md5
+    is 'document_md5';
+comment on column API.date_created
+    is 'create time';
+comment on column API.date_updated
+    is 'update time';
+
+create table api_rule_relation
+(
+    id VARCHAR2 (128) not null,
+    api_id VARCHAR2 (128) not null,
+    rule_id VARCHAR2 (128) not null,
+    date_created timestamp(3) default SYSDATE not null,
+    date_updated timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the columns
+comment on column API_RULE_RELATION.id
+    is 'primary key id';
+comment on column API_RULE_RELATION.api_id
+    is 'the table api primary key id';
+comment on column API_RULE_RELATION.rule_id
+    is 'the table rule primary key id';
+comment on column API_RULE_RELATION.date_created
+    is 'create time';
+comment on column API_RULE_RELATION.date_updated
+    is 'update time';
+
+create table tag
+(
+    id            VARCHAR2(128) not null,
+    name          VARCHAR2(255) not null,
+    tag_desc      VARCHAR2(255) not null,
+    parent_tag_id VARCHAR2(128) not null,
+    ext           VARCHAR2(1024) not null,
+    date_created  timestamp(3) default SYSDATE not null,
+    date_updated  timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the columns
+comment
+    on column TAG.id
+    is 'primary key id';
+comment
+    on column TAG.name
+    is 'tag name';
+comment
+    on column TAG.tag_desc
+    is 'tag desc';
+comment
+    on column TAG.parent_tag_id
+    is 'parent tag id';
+comment
+    on column TAG.ext
+    is 'extension info';
+comment
+    on column TAG.date_created
+    is 'create time';
+comment
+    on column TAG.date_updated
+    is 'update time';
+
+create table tag_relation
+(
+    id                VARCHAR2(128) not null,
+    api_id            VARCHAR2(128) not null,
+    tag_id            VARCHAR2(128) not null,
+    date_created      timestamp(3) default SYSDATE not null,
+    date_updated      timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the columns
+comment on column TAG_RELATION.id
+    is 'primary key id';
+comment on column TAG_RELATION.api_id
+    is 'api_id';
+comment on column TAG_RELATION.tag_id
+    is 'parent tag id';
+comment on column TAG_RELATION.date_created
+    is 'create time';
+comment on column TAG_RELATION.date_updated
+    is 'update time';
+
+create table param
+(
+    id           VARCHAR2(128) not null,
+    api_id       VARCHAR2(128) not null,
+    model_id     VARCHAR2(128) not null,
+    type         NUMBER(10) not null,
+    name         VARCHAR2(255) not null,
+    param_desc   VARCHAR2(1024) not null,
+    required     NUMBER(3) not null,
+    ext          VARCHAR2(1024) not null,
+    date_created timestamp(3) default SYSDATE not null,
+    date_updated timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the table
+comment on table PARAM
+    is 'param document';
+-- Add comments to the columns
+comment on column PARAM.id
+    is 'primary key id';
+comment on column PARAM.api_id
+    is 'the api id';
+comment on column PARAM.model_id
+    is 'the model id, empty if not a model';
+comment on column PARAM.type
+    is '0-requestPathVariable,1-requestUrlParam,2-requestHeader,3-requestBody,4-responseHeader,5-responseBody';
+comment on column PARAM.name
+    is 'the param name';
+comment on column PARAM.param_desc
+    is 'the param description';
+comment on column PARAM.required
+    is 'whether to require (0 not required, 1 required)';
+comment on column PARAM.ext
+    is 'extended fields';
+comment on column PARAM.date_created
+    is 'create time';
+comment on column PARAM.date_updated
+    is 'update time';
+
+create table model
+(
+    id VARCHAR2(128) not null PRIMARY KEY,
+    name VARCHAR2(128) not null,
+    model_desc VARCHAR2(1024) not null,
+    date_created timestamp(3) default SYSDATE not null,
+    date_updated timestamp(3) default SYSDATE not null
+);
+-- Add comments to the table
+comment on table MODEL
+    is 'model desc table';
+-- Add comments to the columns
+comment on column MODEL.id
+    is 'id';
+comment on column MODEL.name
+    is 'the model name';
+comment on column MODEL.model_desc
+    is 'the model description';
+comment on column MODEL.date_created
+    is 'create time';
+comment on column MODEL.date_updated
+    is 'update time';
+
+create table field
+(
+    id           VARCHAR2(128) not null,
+    model_id     VARCHAR2(128) not null,
+    self_model_id VARCHAR2(128) not null,
+    name         VARCHAR2(128) not null,
+    field_desc   VARCHAR2(1024) not null,
+    required     NUMBER(3) not null,
+    ext          VARCHAR2(1024) not null,
+    date_created timestamp(3) default SYSDATE not null,
+    date_updated timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the table
+comment on table field
+    is 'field document table';
+-- Add comments to the columns
+comment on column FIELD.id
+    is 'primary key id';
+comment on column FIELD.model_id
+    is 'this field belongs to which model';
+comment on column FIELD.self_model_id
+    is 'which model of this field is';
+comment on column FIELD.name
+    is 'field name';
+comment on column FIELD.field_desc
+    is 'field description';
+comment on column FIELD.required
+    is 'whether to require (0 not required, 1 required)';
+comment on column FIELD.ext
+    is 'extended fields,can store genericTypes,eg..{"genericTypes":[model_id1,model_id2]}';
+comment on column FIELD.date_created
+    is 'create time';
+comment on column FIELD.date_updated
+    is 'update time';
+
+create table detail
+(
+    id           VARCHAR2(128) not null,
+    field_id     VARCHAR2(128) not null,
+    is_example   NUMBER(3) not null,
+    field_value  CLOB not null,
+    value_desc   VARCHAR2(1024) not null,
+    date_created timestamp(3) default SYSDATE not null,
+    date_updated timestamp(3) default SYSDATE not null,
+    PRIMARY KEY (id)
+);
+-- Add comments to the table
+comment on table DETAIL
+    is 'field value detail table';
+-- Add comments to the columns
+comment on column DETAIL.id
+    is 'primary key id';
+comment on column DETAIL.field_id
+    is 'the field id';
+comment on column DETAIL.is_example
+    is 'is example or not (0 not, 1 is)';
+comment on column DETAIL.field_value
+    is 'the field value';
+comment on column DETAIL.value_desc
+    is 'field value description';
+comment on column DETAIL.date_created
+    is 'create time';
+comment on column DETAIL.date_updated
+    is 'update time';
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql b/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
index b25f04261..4b3c517ed 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
@@ -277,7 +277,6 @@ INSERT INTO "public"."plugin" VALUES ('40', 'keyAuth', NULL, 'Authentication', 1
 -- ----------------------------
 -- Table structure for mock_request_record
 -- ----------------------------
-DROP TABLE IF EXISTS "public"."mock_request_record";
 CREATE TABLE "public"."mock_request_record"  (
      "id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
      "api_id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
@@ -302,4 +301,190 @@ COMMENT ON COLUMN "public"."mock_request_record"."query" IS 'the request param a
 COMMENT ON COLUMN "public"."mock_request_record"."header" IS 'the request param in header';
 COMMENT ON COLUMN "public"."mock_request_record"."body" IS 'the request body';
 COMMENT ON COLUMN "public"."mock_request_record"."date_created" IS 'create time';
-COMMENT ON COLUMN "public"."mock_request_record"."date_updated" IS 'update time';
\ No newline at end of file
+COMMENT ON COLUMN "public"."mock_request_record"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for api
+-- ----------------------------
+CREATE TABLE "public"."api" (
+    "id"           varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "context_path" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_path"     varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "http_method" int4 NOT NULL,
+    "consume"      varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "produce"      varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "version"      varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "rpc_type"     varchar(64) COLLATE "pg_catalog"."default"  NOT NULL,
+    "state" int2 NOT NULL,
+    "ext"          varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_owner"    varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_desc"     varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_source" int4 NOT NULL,
+    "document"     text COLLATE "pg_catalog"."default"         NOT NULL,
+    "document_md5" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now()):: timestamp (0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now()):: timestamp (0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."api"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."api"."context_path" IS 'the context_path';
+COMMENT ON COLUMN "public"."api"."api_path" IS 'the api_path';
+COMMENT ON COLUMN "public"."api"."http_method" IS '0-get,1-head,2-post,3-put,4-patch,5-delete,6-options,7-trace';
+COMMENT ON COLUMN "public"."api"."consume" IS 'consume content-type';
+COMMENT ON COLUMN "public"."api"."produce" IS 'produce content-type';
+COMMENT ON COLUMN "public"."api"."version" IS 'api version,for example V0.01';
+COMMENT ON COLUMN "public"."api"."rpc_type" IS 'http,dubbo,sofa,tars,websocket,springCloud,motan,grpc';
+COMMENT ON COLUMN "public"."api"."state" IS '0-unpublished,1-published,2-offline';
+COMMENT ON COLUMN "public"."api"."ext" IS 'extended fields';
+COMMENT ON COLUMN "public"."api"."api_owner" IS 'api_owner';
+COMMENT ON COLUMN "public"."api"."api_desc" IS 'the api description';
+COMMENT ON COLUMN "public"."api"."api_source" IS '0-swagger,1-annotation generation,2-create manually,3-import swagger,4-import yapi';
+COMMENT ON COLUMN "public"."api"."document" IS 'complete documentation of the api, including request parameters and response parameters';
+COMMENT ON COLUMN "public"."api"."document_md5" IS 'document_md5';
+COMMENT ON COLUMN "public"."api"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."api"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for api_rule_relation
+-- ----------------------------
+CREATE TABLE "public"."api_rule_relation" (
+    "id"           varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_id"       varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "rule_id"      varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now()):: timestamp (0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now()):: timestamp (0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."api_rule_relation"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."api_rule_relation"."api_id" IS 'the table api primary key id';
+COMMENT ON COLUMN "public"."api_rule_relation"."rule_id" IS 'the table rule primary key id';
+COMMENT ON COLUMN "public"."api_rule_relation"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."api_rule_relation"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for tag
+-- ----------------------------
+CREATE TABLE "public"."tag" (
+    "id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "tag_desc" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "parent_tag_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "ext" varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."tag"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."tag"."name" IS 'tag name';
+COMMENT ON COLUMN "public"."tag"."tag_desc" IS 'tag desc';
+COMMENT ON COLUMN "public"."tag"."parent_tag_id" IS 'parent tag id';
+COMMENT ON COLUMN "public"."tag"."ext" IS 'extension';
+COMMENT ON COLUMN "public"."tag"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."tag"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for tag_relation
+-- ----------------------------
+CREATE TABLE "public"."tag_relation" (
+    "id"           varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_id"       varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "tag_id"      varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."tag_relation"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."tag_relation"."api_id" IS 'the table api primary key id';
+COMMENT ON COLUMN "public"."tag_relation"."tag_id" IS 'tag id';
+COMMENT ON COLUMN "public"."tag_relation"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."tag_relation"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for param
+-- ----------------------------
+CREATE TABLE "public"."param" (
+    "id"           varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "api_id"       varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "model_id"     varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "type"         int4 NOT NULL,
+    "name"         varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
+    "param_desc"   varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "required"     int2 NOT NULL,
+    "ext"          varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."param"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."param"."api_id" IS 'the api id';
+COMMENT ON COLUMN "public"."param"."model_id" IS 'the model id, empty if not a model';
+COMMENT ON COLUMN "public"."param"."type" IS '0-requestPathVariable,1-requestUrlParam,2-requestHeader,3-requestBody,4-responseHeader,5-responseBody';
+COMMENT ON COLUMN "public"."param"."name" IS 'the param name';
+COMMENT ON COLUMN "public"."param"."param_desc" IS 'the param description';
+COMMENT ON COLUMN "public"."param"."required" IS 'whether to require (0 not required, 1 required)';
+COMMENT ON COLUMN "public"."param"."ext" IS 'extended fields';
+COMMENT ON COLUMN "public"."param"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."param"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for model
+-- ----------------------------
+CREATE TABLE "public"."model"  (
+    "id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "name" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "model_desc" varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."model"."id" IS 'id';
+COMMENT ON COLUMN "public"."model"."name" IS 'the model name';
+COMMENT ON COLUMN "public"."model"."model_desc" IS 'the model description';
+COMMENT ON COLUMN "public"."model"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."model"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for field
+-- ----------------------------
+CREATE TABLE "public"."field" (
+    "id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "model_id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "self_model_id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "name" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "field_desc" varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "required" int2 NOT NULL,
+    "ext" varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."field"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."field"."model_id" IS 'this field belongs to which model';
+COMMENT ON COLUMN "public"."field"."self_model_id" IS 'which model of this field is';
+COMMENT ON COLUMN "public"."field"."name" IS 'field name';
+COMMENT ON COLUMN "public"."field"."field_desc" IS 'field description';
+COMMENT ON COLUMN "public"."field"."required" IS 'whether to require (0 not required, 1 required)';
+COMMENT ON COLUMN "public"."field"."ext" IS 'extended fields,can store genericTypes,eg..{"genericTypes":[model_id1,model_id2]}';
+COMMENT ON COLUMN "public"."field"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."field"."date_updated" IS 'update time';
+
+-- ----------------------------
+-- Table structure for detail
+-- ----------------------------
+CREATE TABLE "public"."detail" (
+    "id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "field_id" varchar(128) COLLATE "pg_catalog"."default" NOT NULL,
+    "is_example" int2 NOT NULL,
+    "field_value" text COLLATE "pg_catalog"."default" NOT NULL,
+    "value_desc" varchar(1024) COLLATE "pg_catalog"."default" NOT NULL,
+    "date_created" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone),
+    "date_updated" timestamp(6) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone)
+)
+;
+COMMENT ON COLUMN "public"."detail"."id" IS 'primary key id';
+COMMENT ON COLUMN "public"."detail"."field_id" IS 'the field id';
+COMMENT ON COLUMN "public"."detail"."is_example" IS 'is example or not (0 not, 1 is)';
+COMMENT ON COLUMN "public"."detail"."field_value" IS 'the field value';
+COMMENT ON COLUMN "public"."detail"."value_desc" IS 'field value description';
+COMMENT ON COLUMN "public"."detail"."date_created" IS 'create time';
+COMMENT ON COLUMN "public"."detail"."date_updated" IS 'update time';