|
| 1 | +create table "Praise" |
| 2 | +( |
| 3 | +); |
| 4 | + |
| 5 | +alter table "Praise" |
| 6 | + owner to postgres; |
| 7 | + |
| 8 | +create table "Random" |
| 9 | +( |
| 10 | +); |
| 11 | + |
| 12 | +alter table "Random" |
| 13 | + owner to postgres; |
| 14 | + |
| 15 | +create table "_Visit" |
| 16 | +( |
| 17 | +); |
| 18 | + |
| 19 | +alter table "_Visit" |
| 20 | + owner to postgres; |
| 21 | + |
| 22 | +create table "Method" |
| 23 | +( |
| 24 | +); |
| 25 | + |
| 26 | +alter table "Method" |
| 27 | + owner to postgres; |
| 28 | + |
| 29 | +create table "Document" |
| 30 | +( |
| 31 | + id bigint, |
| 32 | + debug smallint, |
| 33 | + "userId" bigint, |
| 34 | + "testAccountId" bigint, |
| 35 | + version smallint, |
| 36 | + name varchar(100), |
| 37 | + type varchar(5), |
| 38 | + url varchar(250), |
| 39 | + request text, |
| 40 | + apijson text, |
| 41 | + sqlauto text, |
| 42 | + standard text, |
| 43 | + header text, |
| 44 | + date timestamp, |
| 45 | + detail text |
| 46 | +); |
| 47 | + |
| 48 | +alter table "Document" |
| 49 | + owner to postgres; |
| 50 | + |
| 51 | +create table apijson_privacy |
| 52 | +( |
| 53 | + id bigint not null |
| 54 | + primary key, |
| 55 | + certified smallint not null, |
| 56 | + phone varchar(64) not null, |
| 57 | + balance numeric(10, 2) not null, |
| 58 | + _password varchar(20) not null, |
| 59 | + "_payPassword" varchar(32) not null |
| 60 | +); |
| 61 | + |
| 62 | +comment on table apijson_privacy is '用户隐私信息表。\n对安全要求高,不想泄漏真实名称。对外名称为 Privacy'; |
| 63 | + |
| 64 | +comment on column apijson_privacy.id is '唯一标识'; |
| 65 | + |
| 66 | +comment on column apijson_privacy.certified is '已认证'; |
| 67 | + |
| 68 | +comment on column apijson_privacy.phone is '手机号,仅支持 11 位数的。不支持 +86 这种国家地区开头的。如果要支持就改为 VARCHAR(14)'; |
| 69 | + |
| 70 | +comment on column apijson_privacy.balance is '余额'; |
| 71 | + |
| 72 | +comment on column apijson_privacy._password is '登录密码'; |
| 73 | + |
| 74 | +comment on column apijson_privacy."_payPassword" is '支付密码'; |
| 75 | + |
| 76 | +alter table apijson_privacy |
| 77 | + owner to postgres; |
| 78 | + |
| 79 | +create index "phone_UNIQUE" |
| 80 | + on apijson_privacy (phone); |
| 81 | + |
| 82 | +create table apijson_user |
| 83 | +( |
| 84 | + id bigint not null |
| 85 | + primary key, |
| 86 | + sex smallint not null, |
| 87 | + name varchar(20), |
| 88 | + tag varchar(45), |
| 89 | + head varchar(300), |
| 90 | + "contactIdList" jsonb, |
| 91 | + "pictureList" jsonb, |
| 92 | + date timestamp(6) |
| 93 | +); |
| 94 | + |
| 95 | +comment on table apijson_user is '用户公开信息表。对安全要求高,不想泄漏真实名称。对外名称为 User'; |
| 96 | + |
| 97 | +comment on column apijson_user.id is '唯一标识'; |
| 98 | + |
| 99 | +comment on column apijson_user.sex is '性别: |
| 100 | +0-男 |
| 101 | +1-女'; |
| 102 | + |
| 103 | +comment on column apijson_user.name is '名称'; |
| 104 | + |
| 105 | +comment on column apijson_user.tag is '标签'; |
| 106 | + |
| 107 | +comment on column apijson_user.head is '头像url'; |
| 108 | + |
| 109 | +comment on column apijson_user."contactIdList" is '联系人id列表'; |
| 110 | + |
| 111 | +comment on column apijson_user."pictureList" is '照片列表'; |
| 112 | + |
| 113 | +comment on column apijson_user.date is '创建日期'; |
| 114 | + |
| 115 | +alter table apijson_user |
| 116 | + owner to postgres; |
| 117 | + |
| 118 | +create table "Comment" |
| 119 | +( |
| 120 | + id bigint not null |
| 121 | + primary key, |
| 122 | + "toId" bigint default 0 not null, |
| 123 | + "userId" bigint not null, |
| 124 | + "momentId" bigint not null, |
| 125 | + date timestamp(6), |
| 126 | + content varchar(1000) not null |
| 127 | +); |
| 128 | + |
| 129 | +comment on table "Comment" is '评论'; |
| 130 | + |
| 131 | +comment on column "Comment".id is '唯一标识'; |
| 132 | + |
| 133 | +comment on column "Comment"."toId" is '被回复的id'; |
| 134 | + |
| 135 | +comment on column "Comment"."userId" is '评论人id'; |
| 136 | + |
| 137 | +comment on column "Comment"."momentId" is '动态id'; |
| 138 | + |
| 139 | +comment on column "Comment".date is '创建日期'; |
| 140 | + |
| 141 | +comment on column "Comment".content is '内容'; |
| 142 | + |
| 143 | +alter table "Comment" |
| 144 | + owner to postgres; |
| 145 | + |
| 146 | +create table "Moment" |
| 147 | +( |
| 148 | + id bigint not null |
| 149 | + primary key, |
| 150 | + "userId" bigint not null, |
| 151 | + date timestamp(6), |
| 152 | + content varchar(300), |
| 153 | + "praiseUserIdList" jsonb not null, |
| 154 | + "pictureList" jsonb not null |
| 155 | +); |
| 156 | + |
| 157 | +comment on table "Moment" is '动态'; |
| 158 | + |
| 159 | +comment on column "Moment".id is '唯一标识'; |
| 160 | + |
| 161 | +comment on column "Moment"."userId" is '用户id'; |
| 162 | + |
| 163 | +comment on column "Moment".date is '创建日期'; |
| 164 | + |
| 165 | +comment on column "Moment".content is '内容'; |
| 166 | + |
| 167 | +comment on column "Moment"."praiseUserIdList" is '点赞的用户id列表'; |
| 168 | + |
| 169 | +comment on column "Moment"."pictureList" is '图片列表'; |
| 170 | + |
| 171 | +alter table "Moment" |
| 172 | + owner to postgres; |
| 173 | + |
| 174 | +create table "TestRecord" |
| 175 | +( |
| 176 | + id bigint not null |
| 177 | + primary key, |
| 178 | + "userId" bigint not null, |
| 179 | + "documentId" bigint not null, |
| 180 | + response text not null, |
| 181 | + date timestamp(6) default CURRENT_TIMESTAMP not null, |
| 182 | + compare text, |
| 183 | + standard text, |
| 184 | + "randomId" bigint default 0, |
| 185 | + headless smallint default 0 not null, |
| 186 | + "reportId" bigint default 0 not null, |
| 187 | + "testAccountId" bigint default 0 not null, |
| 188 | + duration bigint default 0 not null, |
| 189 | + "minDuration" bigint default 0 not null, |
| 190 | + "maxDuration" bigint default 0 not null, |
| 191 | + host varchar(200) |
| 192 | +); |
| 193 | + |
| 194 | +comment on column "TestRecord".id is '唯一标识'; |
| 195 | + |
| 196 | +comment on column "TestRecord"."userId" is '用户id'; |
| 197 | + |
| 198 | +comment on column "TestRecord"."documentId" is '测试用例文档id'; |
| 199 | + |
| 200 | +comment on column "TestRecord".response is '接口返回结果JSON'; |
| 201 | + |
| 202 | +comment on column "TestRecord".date is '创建日期'; |
| 203 | + |
| 204 | +comment on column "TestRecord".compare is '对比结果'; |
| 205 | + |
| 206 | +comment on column "TestRecord".standard is 'response 的校验标准,是一个 JSON 格式的 AST ,描述了正确 Response 的结构、里面的字段名称、类型、长度、取值范围 等属性。'; |
| 207 | + |
| 208 | +comment on column "TestRecord"."randomId" is '随机配置 id'; |
| 209 | + |
| 210 | +comment on column "TestRecord".headless is '是否为无 UI 的 Headless 模式:0-否 1-是'; |
| 211 | + |
| 212 | +comment on column "TestRecord"."reportId" is '测试报告 ID'; |
| 213 | + |
| 214 | +comment on column "TestRecord"."testAccountId" is '测试账号 id'; |
| 215 | + |
| 216 | +alter table "TestRecord" |
| 217 | + owner to postgres; |
| 218 | + |
| 219 | +create table "Function" |
| 220 | +( |
| 221 | + id bigint not null |
| 222 | + primary key, |
| 223 | + language varchar, |
| 224 | + name varchar(30) not null, |
| 225 | + "returnType" varchar(45) default 'Object'::character varying, |
| 226 | + arguments varchar(100), |
| 227 | + demo text not null, |
| 228 | + detail varchar(1000), |
| 229 | + date timestamp(6) default CURRENT_TIMESTAMP not null, |
| 230 | + "userId" bigint default 0, |
| 231 | + version integer default 0, |
| 232 | + tag varchar, |
| 233 | + methods varchar, |
| 234 | + return integer |
| 235 | +); |
| 236 | + |
| 237 | +comment on column "Function".language is '语言:Java(java), JavaScript(js), Lua(lua), Python(py), Ruby(ruby), PHP(php) 等,NULL 默认为 Java,JDK 1.6-11 默认支持 JavaScript,JDK 12+ 需要额外依赖 Nashron/Rhiro 等 js 引擎库,其它的语言需要依赖对应的引擎库,并在 ScriptEngineManager 中注册'; |
| 238 | + |
| 239 | +comment on column "Function".name is '方法名'; |
| 240 | + |
| 241 | +comment on column "Function"."returnType" is '返回类型'; |
| 242 | + |
| 243 | +comment on column "Function".arguments is '参数列表,每个参数的类型都是 String。 |
| 244 | +用 , 分割的字符串 比 [JSONArray] 更好,例如 array,item ,更直观,还方便拼接函数。'; |
| 245 | + |
| 246 | +comment on column "Function".demo is '可用的示例。'; |
| 247 | + |
| 248 | +comment on column "Function".detail is '详细描述'; |
| 249 | + |
| 250 | +comment on column "Function".date is '创建时间'; |
| 251 | + |
| 252 | +comment on column "Function"."userId" is '用户id'; |
| 253 | + |
| 254 | +comment on column "Function".version is '允许的最低版本号,只限于GET,HEAD外的操作方法。\nTODO 使用 requestIdList 替代 version,tag,methods'; |
| 255 | + |
| 256 | +comment on column "Function".tag is '允许的标签.\nnull - 允许全部\nTODO 使用 requestIdList 替代 version,tag,methods'; |
| 257 | + |
| 258 | +comment on column "Function".methods is '允许的操作方法。\nnull - 允许全部\nTODO 使用 requestIdList 替代 version,tag,methods'; |
| 259 | + |
| 260 | +comment on column "Function".return is '返回值示例'; |
| 261 | + |
| 262 | +alter table "Function" |
| 263 | + owner to postgres; |
| 264 | + |
| 265 | +create table "Request" |
| 266 | +( |
| 267 | + id bigint, |
| 268 | + debug smallint, |
| 269 | + version smallint, |
| 270 | + method varchar(10), |
| 271 | + tag varchar(30), |
| 272 | + structure json, |
| 273 | + detail varchar(10000), |
| 274 | + date timestamp |
| 275 | +); |
| 276 | + |
| 277 | +alter table "Request" |
| 278 | + owner to postgres; |
| 279 | + |
| 280 | +create table "Script" |
| 281 | +( |
| 282 | + id bigint, |
| 283 | + "userId" bigint, |
| 284 | + "testAccountId" bigint, |
| 285 | + "documentId" bigint, |
| 286 | + simple smallint, |
| 287 | + ahead smallint, |
| 288 | + title varchar(100), |
| 289 | + name varchar(100), |
| 290 | + script text, |
| 291 | + date timestamp, |
| 292 | + detail varchar(1000) |
| 293 | +); |
| 294 | + |
| 295 | +alter table "Script" |
| 296 | + owner to postgres; |
| 297 | + |
| 298 | +create table "Access" |
| 299 | +( |
| 300 | + id integer not null |
| 301 | + primary key, |
| 302 | + schema varchar(100) default NULL::character varying, |
| 303 | + debug integer default 0 not null, |
| 304 | + name varchar(50) default '实际表名,例如 apijson_user'::character varying not null, |
| 305 | + alias text, |
| 306 | + get text default '["UNKNOWN", "LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]'::text not null, |
| 307 | + head text default '["UNKNOWN", "LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]'::text not null, |
| 308 | + gets text default '["LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]'::text not null, |
| 309 | + heads text default '["LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]'::text not null, |
| 310 | + post text default '["OWNER", "ADMIN"]'::text not null, |
| 311 | + put text default '["OWNER", "ADMIN"]'::text not null, |
| 312 | + delete text default '["OWNER", "ADMIN"]'::text not null, |
| 313 | + date text default CURRENT_TIMESTAMP not null, |
| 314 | + detail text |
| 315 | +); |
| 316 | + |
| 317 | +comment on column "Access".id is '唯一标识'; |
| 318 | + |
| 319 | +comment on column "Access".debug is '是否为调试表,只允许在开发环境使用,测试和线上环境禁用'; |
| 320 | + |
| 321 | +comment on column "Access".alias is '外部调用的表别名,例如 User'; |
| 322 | + |
| 323 | +comment on column "Access".get is '允许 get 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"] |
| 324 | +用 JSON 类型不能设置默认值,反正权限对应的需求是明确的,也不需要自动转 JSONArray。 |
| 325 | +TODO: 直接 LOGIN,CONTACT,CIRCLE,OWNER 更简单,反正是开发内部用,不需要复杂查询。'; |
| 326 | + |
| 327 | +comment on column "Access".head is '允许 head 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"]'; |
| 328 | + |
| 329 | +comment on column "Access".gets is '允许 gets 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"]'; |
| 330 | + |
| 331 | +comment on column "Access".heads is '允许 heads 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"]'; |
| 332 | + |
| 333 | +comment on column "Access".post is '允许 post 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"]'; |
| 334 | + |
| 335 | +comment on column "Access".put is '允许 put 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"]'; |
| 336 | + |
| 337 | +comment on column "Access".delete is '允许 delete 的角色列表,例如 ["LOGIN", "CONTACT", "CIRCLE", "OWNER"]'; |
| 338 | + |
| 339 | +comment on column "Access".date is '创建时间'; |
| 340 | + |
| 341 | +alter table "Access" |
| 342 | + owner to postgres; |
| 343 | + |
| 344 | +create table "Verify" |
| 345 | +( |
| 346 | + id bigint, |
| 347 | + type integer, |
| 348 | + phone bigint, |
| 349 | + verify integer, |
| 350 | + date timestamp |
| 351 | +); |
| 352 | + |
| 353 | +alter table "Verify" |
| 354 | + owner to postgres; |
| 355 | + |
0 commit comments