Browse Source

2.0 数据库更新 user project

master
CODE 1 year ago
parent
commit
10d6e2c961
  1. 50
      api/app/lib/models/project.js
  2. 17
      api/app/lib/models/user.js
  3. 2
      api/sequelize-automate.config.js
  4. 5
      script/2.0.0/schema/3.update_project.sql
  5. 5
      script/2.0.0/schema/4.update_user.sql

50
api/app/lib/models/project.js

@ -12,30 +12,11 @@ module.exports = dc => {
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "project_id_uindex"
},
img: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "img",
autoIncrement: false
},
userId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "user_id",
autoIncrement: false
autoIncrement: true
},
name: {
type: DataTypes.STRING,
allowNull: false,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
@ -78,6 +59,24 @@ module.exports = dc => {
field: "describe",
autoIncrement: false
},
userId: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "user_id",
autoIncrement: false
},
img: {
type: array,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,
field: "img",
autoIncrement: false
},
qrCode: {
type: DataTypes.STRING,
allowNull: true,
@ -87,6 +86,15 @@ module.exports = dc => {
field: "qr_code",
autoIncrement: false
},
subType: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "子类型-子系统",
primaryKey: false,
field: "sub_type",
autoIncrement: false
}
}, {
tableName: "project",
comment: "",

17
api/app/lib/models/user.js

@ -12,8 +12,7 @@ module.exports = dc => {
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "user_id_uindex"
autoIncrement: true
},
name: {
type: DataTypes.STRING,
@ -97,20 +96,28 @@ module.exports = dc => {
autoIncrement: false
},
structure: {
type: DataTypes.JSON,
type: DataTypes.JSONB,
allowNull: true,
defaultValue: null,
comment: "结构物",
comment: null,
primaryKey: false,
field: "structure",
autoIncrement: false
},
role: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "角色",
primaryKey: false,
field: "role",
autoIncrement: false
}
}, {
tableName: "user",
comment: "",
indexes: []
});
dc.models.User = User;
return User;
};

2
api/sequelize-automate.config.js

@ -26,7 +26,7 @@ module.exports = {
dir: './app/lib/models', // 指定输出 models 文件的目录
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
tables: ['device', 'point_device'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
tables: ['user', 'project'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
ignorePrefix: ['t_',], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面

5
script/2.0.0/schema/3.update_project.sql

@ -0,0 +1,5 @@
alter table project
add sub_type varchar(255);
comment on column project.sub_type is '子类型-子系统';

5
script/2.0.0/schema/4.update_user.sql

@ -0,0 +1,5 @@
alter table "user"
add role varchar(64);
comment on column "user".role is '角色';
Loading…
Cancel
Save