CODE
1 year ago
5 changed files with 206 additions and 33 deletions
@ -0,0 +1,88 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const Device = sequelize.define("device", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "device_id_uindex" |
|||
}, |
|||
name: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "name", |
|||
autoIncrement: false |
|||
}, |
|||
type: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "type", |
|||
autoIncrement: false |
|||
}, |
|||
specification: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "规格\r\n", |
|||
primaryKey: false, |
|||
field: "specification", |
|||
autoIncrement: false |
|||
}, |
|||
dateProduced: { |
|||
type: DataTypes.DATEONLY, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "生产日期", |
|||
primaryKey: false, |
|||
field: "date_produced", |
|||
autoIncrement: false |
|||
}, |
|||
dateInstall: { |
|||
type: DataTypes.DATEONLY, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "安装日期", |
|||
primaryKey: false, |
|||
field: "date_install", |
|||
autoIncrement: false |
|||
}, |
|||
dateGuarantee: { |
|||
type: DataTypes.DATEONLY, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "质保期", |
|||
primaryKey: false, |
|||
field: "date_guarantee", |
|||
autoIncrement: false |
|||
}, |
|||
dateMainten: { |
|||
type: DataTypes.DATEONLY, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "维保期", |
|||
primaryKey: false, |
|||
field: "date_mainten", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "device", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.Device = Device; |
|||
return Device; |
|||
}; |
@ -0,0 +1,43 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const PointDevice = sequelize.define("pointDevice", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true, |
|||
unique: "point_device_id_uindex" |
|||
}, |
|||
pointId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "point_id", |
|||
autoIncrement: false |
|||
}, |
|||
deviceId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "device_id", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "point_device", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.PointDevice = PointDevice; |
|||
return PointDevice; |
|||
}; |
@ -0,0 +1,28 @@ |
|||
create table if not exists device |
|||
( |
|||
id serial not null |
|||
constraint device_pk |
|||
primary key, |
|||
name varchar(256) not null, |
|||
type varchar(128) not null, |
|||
specification varchar(256), |
|||
date_produced date, |
|||
date_install date, |
|||
date_guarantee date, |
|||
date_mainten date |
|||
); |
|||
|
|||
comment on column device.specification is '规格 |
|||
'; |
|||
|
|||
comment on column device.date_produced is '生产日期'; |
|||
|
|||
comment on column device.date_install is '安装日期'; |
|||
|
|||
comment on column device.date_guarantee is '质保期'; |
|||
|
|||
comment on column device.date_mainten is '维保期'; |
|||
|
|||
create unique index if not exists device_id_uindex |
|||
on device (id); |
|||
|
@ -0,0 +1,14 @@ |
|||
create table if not exists point_device |
|||
( |
|||
id serial not null |
|||
constraint point_device_pk |
|||
primary key, |
|||
point_id integer not null, |
|||
device_id integer |
|||
); |
|||
|
|||
comment on table point_device is '点位-设备关联表'; |
|||
|
|||
create unique index if not exists point_device_id_uindex |
|||
on point_device (id); |
|||
|
Loading…
Reference in new issue