/*
 Navicat Premium Dump SQL

 Source Server         : 1.13.177.47,1433
 Source Server Type    : SQL Server
 Source Server Version : 16004085 (16.00.4085)
 Source Host           : 1.13.177.47:1433
 Source Catalog        : energy-visual
 Source Schema         : dbo

 Target Server Type    : SQL Server
 Target Server Version : 16004085 (16.00.4085)
 File Encoding         : 65001

 Date: 26/03/2026 09:12:29
*/


-- ----------------------------
-- Table structure for base_custom_data
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_custom_data]') AND type IN ('U'))
	DROP TABLE [dbo].[base_custom_data]
GO

CREATE TABLE [dbo].[base_custom_data] (
  [obj_id] bigint  NOT NULL,
  [custom_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [custom_function] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [custom_code] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [custom_data] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [custom_sort] int  NULL,
  [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[base_custom_data] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义数据类型（0OS数据 1EMS数据）',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'custom_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义功能',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'custom_function'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义编号',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'custom_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义数据',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'custom_data'
GO

EXEC sp_addextendedproperty
'MS_Description', N'排序',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'custom_sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否标识',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义数据维护',
'SCHEMA', N'dbo',
'TABLE', N'base_custom_data'
GO


-- ----------------------------
-- Table structure for base_device_ledger
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_device_ledger]') AND type IN ('U'))
	DROP TABLE [dbo].[base_device_ledger]
GO

CREATE TABLE [dbo].[base_device_ledger] (
  [obj_id] bigint  NOT NULL,
  [device_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [device_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [device_model] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [device_type] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [device_address] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [device_status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [used_department] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [cost_center] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [manufacturer] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [enable_date] date  NULL,
  [product_line_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [factory_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [team_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [asset_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[base_device_ledger] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备编号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'device_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备名称',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'device_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备型号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'device_model'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备类型（1生产设备 2计量设备）',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'device_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'IP地址',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'device_address'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备状态（0使用 1停用 2报废）',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'device_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'使用部门',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'used_department'
GO

EXEC sp_addextendedproperty
'MS_Description', N'成本中心',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'cost_center'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生产厂商',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'manufacturer'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用日期',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'enable_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'所属工位',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'product_line_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否标识',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工厂编号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'factory_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组编号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'team_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'资产编号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger',
'COLUMN', N'asset_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备台账',
'SCHEMA', N'dbo',
'TABLE', N'base_device_ledger'
GO


-- ----------------------------
-- Table structure for base_device_param
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_device_param]') AND type IN ('U'))
	DROP TABLE [dbo].[base_device_param]
GO

CREATE TABLE [dbo].[base_device_param] (
  [obj_id] bigint  NOT NULL,
  [param_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [param_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [param_network] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [param_address] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [param_type] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [device_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [read_frequency] decimal(18,2)  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[base_device_param] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数编号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'param_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数名称',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'param_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'网络地址',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'param_network'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数地址',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'param_address'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数类型（0int 1float）',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'param_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备编号',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'device_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'读取频率(毫秒)',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'read_frequency'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备参数',
'SCHEMA', N'dbo',
'TABLE', N'base_device_param'
GO


-- ----------------------------
-- Table structure for base_factory
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_factory]') AND type IN ('U'))
	DROP TABLE [dbo].[base_factory]
GO

CREATE TABLE [dbo].[base_factory] (
  [obj_id] bigint  NOT NULL,
  [company_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [factory_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [factory_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [factory_status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [remark] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[base_factory] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'公司名称',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'company_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工厂编号',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'factory_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工厂名称',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'factory_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工厂状态（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'factory_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_factory',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工厂管理',
'SCHEMA', N'dbo',
'TABLE', N'base_factory'
GO


-- ----------------------------
-- Table structure for base_material_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_material_info]') AND type IN ('U'))
	DROP TABLE [dbo].[base_material_info]
GO

CREATE TABLE [dbo].[base_material_info] (
  [obj_id] bigint  NOT NULL,
  [material_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [material_name] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [material_categories] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [material_subclass] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [material_type] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [material_unit] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [unit_price] decimal(18,2)  NULL,
  [material_specifications] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [factory_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [product_line_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [increment_date] datetime2(7)  NULL,
  [product_code] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [product_name] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[base_material_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物料编码',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物料名称',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物料大类',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_categories'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物料小类（1成品 2BOM）',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_subclass'
GO

EXEC sp_addextendedproperty
'MS_Description', N'SAP物料类型',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量单位（1立方米 2吨）',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_unit'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单位工资(元)',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'unit_price'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物料型号',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'material_specifications'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工厂编号',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'factory_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'所属工位',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'product_line_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否标识',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'增量日期',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'increment_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'商品编码',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'product_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'商品名称',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info',
'COLUMN', N'product_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物料信息',
'SCHEMA', N'dbo',
'TABLE', N'base_material_info'
GO


-- ----------------------------
-- Table structure for base_process_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_process_info]') AND type IN ('U'))
	DROP TABLE [dbo].[base_process_info]
GO

CREATE TABLE [dbo].[base_process_info] (
  [obj_id] bigint  NOT NULL,
  [process_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [process_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [process_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [product_line_code] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [station_codes] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [capacity_day] decimal(18,2)  NULL,
  [capacity_month] decimal(18,2)  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[base_process_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工序编号',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'process_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工序名称',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'process_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工序类型（1生产工序）',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'process_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'产线编号',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'product_line_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工位编号',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'station_codes'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日产能',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'capacity_day'
GO

EXEC sp_addextendedproperty
'MS_Description', N'月产能',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'capacity_month'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改人',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工序信息',
'SCHEMA', N'dbo',
'TABLE', N'base_process_info'
GO


-- ----------------------------
-- Table structure for base_product_line
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_product_line]') AND type IN ('U'))
	DROP TABLE [dbo].[base_product_line]
GO

CREATE TABLE [dbo].[base_product_line] (
  [obj_id] bigint  NOT NULL,
  [product_line_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [product_line_name] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [product_line_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [plant_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [parent_id] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [station_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [work_center_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [work_center_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [execution_sort] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [capacity_day] decimal(18,2)  NULL,
  [capacity_month] decimal(18,2)  NULL
)
GO

ALTER TABLE [dbo].[base_product_line] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'产线/工位编号',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'product_line_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'产线名称',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'product_line_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'类别（1产线 2工位）',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'product_line_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'所属工厂',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'plant_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父级编号',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工位类型（1生产工位 2质检工位）',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'station_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'SAP工作中心编号',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'work_center_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'SAP工作中心描述',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'work_center_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行顺序',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'execution_sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日产能(米)',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'capacity_day'
GO

EXEC sp_addextendedproperty
'MS_Description', N'月产能(米)',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line',
'COLUMN', N'capacity_month'
GO

EXEC sp_addextendedproperty
'MS_Description', N'产线/工位信息',
'SCHEMA', N'dbo',
'TABLE', N'base_product_line'
GO


-- ----------------------------
-- Table structure for base_staff_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_staff_info]') AND type IN ('U'))
	DROP TABLE [dbo].[base_staff_info]
GO

CREATE TABLE [dbo].[base_staff_info] (
  [obj_id] bigint  NOT NULL,
  [staff_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [staff_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [staff_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [card_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [team_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [phone_number] nvarchar(11) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [sex] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [pass_word] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [wage_coefficient] decimal(18,2)  NULL,
  [post_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[base_staff_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'员工ID',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'staff_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'员工名称',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'staff_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'员工类型（1班长 2组员）',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'staff_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'卡号',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'card_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组编号',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'team_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'手机号',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'phone_number'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户性别（0男 1女 2未知）',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'sex'
GO

EXEC sp_addextendedproperty
'MS_Description', N'身份证',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'pass_word'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 2代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工资系数',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'wage_coefficient'
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位编码',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info',
'COLUMN', N'post_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'员工信息',
'SCHEMA', N'dbo',
'TABLE', N'base_staff_info'
GO


-- ----------------------------
-- Table structure for base_team_members
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[base_team_members]') AND type IN ('U'))
	DROP TABLE [dbo].[base_team_members]
GO

CREATE TABLE [dbo].[base_team_members] (
  [obj_id] bigint  NOT NULL,
  [team_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [team_name] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [team_head] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [station_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [classes] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [start_time] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [end_time] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [dine_time] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [machine_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [process_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[base_team_members] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组编号',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'team_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组名称',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'team_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组负责人',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'team_head'
GO

EXEC sp_addextendedproperty
'MS_Description', N'所属工位',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'station_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班次（1早班 2晚班）',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'classes'
GO

EXEC sp_addextendedproperty
'MS_Description', N'上班时间',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'start_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下班时间',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'end_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'休息时间',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'dine_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否标识',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'机台编号',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'machine_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工序编号',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members',
'COLUMN', N'process_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'班组信息',
'SCHEMA', N'dbo',
'TABLE', N'base_team_members'
GO


-- ----------------------------
-- Table structure for daily_fault_record
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[daily_fault_record]') AND type IN ('U'))
	DROP TABLE [dbo].[daily_fault_record]
GO

CREATE TABLE [dbo].[daily_fault_record] (
  [id] bigint  NOT NULL,
  [date] nvarchar(19) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [location] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [daily_duty_supervisor] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [tenda_daily_duty_supervisor] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [fault_situation] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [handling_measures] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [fault_type] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [fault_occurrence_time] nvarchar(19) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [handling_completion_time] nvarchar(19) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [handling_duration] int  NULL,
  [remarks] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[daily_fault_record] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键，自增ID',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日期',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'位置',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'location'
GO

EXEC sp_addextendedproperty
'MS_Description', N'科室值班',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'daily_duty_supervisor'
GO

EXEC sp_addextendedproperty
'MS_Description', N'外包值班',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'tenda_daily_duty_supervisor'
GO

EXEC sp_addextendedproperty
'MS_Description', N'故障情况',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'fault_situation'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处置措施',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'handling_measures'
GO

EXEC sp_addextendedproperty
'MS_Description', N'故障类型',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'fault_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'故障发生时间',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'fault_occurrence_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处置完毕时间',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'handling_completion_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'处置时长',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'handling_duration'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record',
'COLUMN', N'remarks'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日常故障记录表',
'SCHEMA', N'dbo',
'TABLE', N'daily_fault_record'
GO


-- ----------------------------
-- Table structure for ems_alarm_action_step
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_alarm_action_step]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_alarm_action_step]
GO

CREATE TABLE [dbo].[ems_alarm_action_step] (
  [obj_id] bigint  NOT NULL,
  [rule_obj_id] bigint  NOT NULL,
  [step_sequence] int  NOT NULL,
  [description] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[ems_alarm_action_step] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键ID',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'关联的报警规则ID (逻辑关联 ems_record_alarm_rule.obj_id)',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'rule_obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'步骤顺序，从1开始',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'step_sequence'
GO

EXEC sp_addextendedproperty
'MS_Description', N'步骤文字描述',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警规则具体措施步骤表',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step'
GO


-- ----------------------------
-- Table structure for ems_alarm_action_step_image
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_alarm_action_step_image]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_alarm_action_step_image]
GO

CREATE TABLE [dbo].[ems_alarm_action_step_image] (
  [obj_id] bigint  NOT NULL,
  [action_step_obj_id] bigint  NOT NULL,
  [image_url] nvarchar(1024) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [image_sequence] int  NOT NULL,
  [description] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[ems_alarm_action_step_image] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键ID',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'关联的措施步骤ID (逻辑关联 ems_alarm_action_step.obj_id)',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'action_step_obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'图片存储URL',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'image_url'
GO

EXEC sp_addextendedproperty
'MS_Description', N'图片在当前步骤内的顺序，从1开始',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'image_sequence'
GO

EXEC sp_addextendedproperty
'MS_Description', N'图片描述 (可选)',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警措施步骤图片表',
'SCHEMA', N'dbo',
'TABLE', N'ems_alarm_action_step_image'
GO


-- ----------------------------
-- Table structure for ems_base_collect_device_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_collect_device_info]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_collect_device_info]
GO

CREATE TABLE [dbo].[ems_base_collect_device_info] (
  [obj_id] int  NOT NULL,
  [collect_device_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_device_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [energy_type_id] int  NULL,
  [model] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [manufacturer] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ip_address] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [produce_date] datetime2(7)  NULL,
  [setting_address] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[ems_base_collect_device_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'collect_device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集设备名称',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'collect_device_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'energy_type_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'型号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'model'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生产厂家',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'manufacturer'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通讯地址',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'ip_address'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生产日期',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'produce_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'安装地址',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'setting_address'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集设备信息',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_collect_device_info'
GO


-- ----------------------------
-- Table structure for ems_base_energy_price
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_energy_price]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_energy_price]
GO

CREATE TABLE [dbo].[ems_base_energy_price] (
  [obj_id] bigint  NOT NULL,
  [energy_id] int  NOT NULL,
  [energy_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [measure_unit] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [month_date] datetime2(7)  NULL,
  [price] decimal(18,6)  NULL,
  [un_tax_price] decimal(18,6)  NULL,
  [start_date] datetime2(7)  NULL,
  [end_date] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[ems_base_energy_price] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'energy_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型名称',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'energy_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单位',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'measure_unit'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采购月份',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'month_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'含税单价',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'price'
GO

EXEC sp_addextendedproperty
'MS_Description', N'不含税单价',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'un_tax_price'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始日期',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'start_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'结束日期',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'end_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人员',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人员',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源月份单价',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_price'
GO


-- ----------------------------
-- Table structure for ems_base_energy_type
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_energy_type]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_energy_type]
GO

CREATE TABLE [dbo].[ems_base_energy_type] (
  [obj_id] int  NOT NULL,
  [energy_type_id] int  NULL,
  [energy_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [measure_unit] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [price] decimal(18,6)  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[ems_base_energy_type] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'energy_type_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型名称',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'energy_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单位',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'measure_unit'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单价',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'price'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型信息',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_energy_type'
GO


-- ----------------------------
-- Table structure for ems_base_monitor_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_monitor_info]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_monitor_info]
GO

CREATE TABLE [dbo].[ems_base_monitor_info] (
  [obj_id] int  NOT NULL,
  [parent_id] int  NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [monitor_name] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [monitor_addr] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [monitor_type] int  NULL,
  [monitor_status] int  NULL,
  [collect_device_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ancestors] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [grade] int  NULL,
  [meter_type_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [correct_value] decimal(18,2)  NULL,
  [pt] decimal(18,2)  NULL,
  [ct] decimal(18,2)  NULL,
  [is_ammeter] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_key_monitor] int  NULL,
  [is_circuit] int  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [public_share_type] int  NULL,
  [monitor_hierarchy] int  NULL
)
GO

ALTER TABLE [dbo].[ems_base_monitor_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父级编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备名称',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'monitor_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备位置',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'monitor_addr'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'monitor_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备状态（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'monitor_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'collect_device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'祖级列表',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'ancestors'
GO

EXEC sp_addextendedproperty
'MS_Description', N'等级',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'grade'
GO

EXEC sp_addextendedproperty
'MS_Description', N'传感器仪表',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'meter_type_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修正值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'correct_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'PT值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'pt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'CT值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'ct'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否虚拟（0是 1否）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'is_ammeter'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通断复位',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'is_key_monitor'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否断路',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'is_circuit'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'公摊表类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'public_share_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'表具层级',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info',
'COLUMN', N'monitor_hierarchy'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备信息',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_info'
GO


-- ----------------------------
-- Table structure for ems_base_monitor_threshold
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_monitor_threshold]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_monitor_threshold]
GO

CREATE TABLE [dbo].[ems_base_monitor_threshold] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [monitor_type] int  NULL,
  [i_a_max] decimal(18,2)  NULL,
  [i_a_min] decimal(18,2)  NULL,
  [i_b_max] decimal(18,2)  NULL,
  [i_b_min] decimal(18,2)  NULL,
  [i_c_max] decimal(18,2)  NULL,
  [i_c_min] decimal(18,2)  NULL,
  [v_a_max] decimal(18,2)  NULL,
  [v_a_min] decimal(18,2)  NULL,
  [v_b_max] decimal(18,2)  NULL,
  [v_b_min] decimal(18,2)  NULL,
  [v_c_max] decimal(18,2)  NULL,
  [v_c_min] decimal(18,2)  NULL,
  [hour_consumption] decimal(18,2)  NULL,
  [day_consumption] decimal(18,2)  NULL,
  [line_loss_rate] decimal(18,2)  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[ems_base_monitor_threshold] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'monitor_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A相电流最大值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'i_a_max'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A相电流最小值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'i_a_min'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B相电流最大值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'i_b_max'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B相电流最小值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'i_b_min'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C相电流最大值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'i_c_max'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C相电流最小值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'i_c_min'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A相电压最大值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'v_a_max'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A相电压最小值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'v_a_min'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B相电压最大值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'v_b_max'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B相电压最小值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'v_b_min'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C相电压最大值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'v_c_max'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C相电压最小值',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'v_c_min'
GO

EXEC sp_addextendedproperty
'MS_Description', N'小时耗量',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'hour_consumption'
GO

EXEC sp_addextendedproperty
'MS_Description', N'天耗量',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'day_consumption'
GO

EXEC sp_addextendedproperty
'MS_Description', N'线损率(%)',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'line_loss_rate'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备阈值维护',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_threshold'
GO


-- ----------------------------
-- Table structure for ems_base_monitor_work_unit
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_monitor_work_unit]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_monitor_work_unit]
GO

CREATE TABLE [dbo].[ems_base_monitor_work_unit] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [work_unit_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [monitor_status] int  NULL,
  [monitor_type] int  NULL,
  [formula_mode] int  NULL,
  [proportion] decimal(18,2)  NULL,
  [remark] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [created_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [created_time] date  NULL,
  [updated_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [updated_time] date  NULL
)
GO

ALTER TABLE [dbo].[ems_base_monitor_work_unit] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计单元编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'work_unit_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备状态（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'monitor_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'monitor_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计算方式（0加 1减）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'formula_mode'
GO

EXEC sp_addextendedproperty
'MS_Description', N'比率',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'proportion'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识（0启用 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'created_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'created_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'updated_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit',
'COLUMN', N'updated_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计计量信息',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_monitor_work_unit'
GO


-- ----------------------------
-- Table structure for ems_base_share_price
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_share_price]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_share_price]
GO

CREATE TABLE [dbo].[ems_base_share_price] (
  [obj_id] int  NOT NULL,
  [year_month_date] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [price_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [start_hour] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [end_hour] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [dnb_price] decimal(18,6)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[ems_base_share_price] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录月份',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'year_month_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分时电价类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'price_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用电起始小时数',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'start_hour'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用电结束小时数',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'end_hour'
GO

EXEC sp_addextendedproperty
'MS_Description', N'电单价',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'dnb_price'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人员',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人员',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分时电价维护',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_share_price'
GO


-- ----------------------------
-- Table structure for ems_base_work_unit
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_base_work_unit]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_base_work_unit]
GO

CREATE TABLE [dbo].[ems_base_work_unit] (
  [obj_id] bigint  NOT NULL,
  [work_unit_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [parent_id] bigint  NULL,
  [work_unit_name] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [work_unit_address] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ancestors] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [work_unit_sort] int  NULL,
  [product_line_code] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [work_unit_type] int  NULL,
  [is_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [created_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [created_time] date  NULL,
  [updated_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [updated_time] date  NULL
)
GO

ALTER TABLE [dbo].[ems_base_work_unit] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计单元编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'work_unit_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父级编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计单元名称',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'work_unit_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计区域',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'work_unit_address'
GO

EXEC sp_addextendedproperty
'MS_Description', N'祖级编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'ancestors'
GO

EXEC sp_addextendedproperty
'MS_Description', N'排序',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'work_unit_sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'产线/工位',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'product_line_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计单元类型（1建筑）',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'work_unit_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'启用标识(0启用 1停用)',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'is_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'created_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'created_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'updated_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit',
'COLUMN', N'updated_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计单元信息',
'SCHEMA', N'dbo',
'TABLE', N'ems_base_work_unit'
GO


-- ----------------------------
-- Table structure for ems_record_alarm_data
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_record_alarm_data]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_record_alarm_data]
GO

CREATE TABLE [dbo].[ems_record_alarm_data] (
  [obj_id] int  NOT NULL,
  [monitor_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_device_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_time] datetime2(7)  NULL,
  [alarm_type] int  NULL,
  [alarm_status] int  NULL,
  [alarm_data] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [operation_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [operation_time] datetime2(7)  NULL,
  [cause] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [notify_user] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[ems_record_alarm_data] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'monitor_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'collect_device_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'异常类型（0超过阈值 1小于阈值）',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'alarm_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'异常状态（0已处理 1未处理）',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'alarm_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'异常数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'alarm_data'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作人员',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'operation_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'operation_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'cause'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知用户',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data',
'COLUMN', N'notify_user'
GO

EXEC sp_addextendedproperty
'MS_Description', N'异常数据记录',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_data'
GO


-- ----------------------------
-- Table structure for ems_record_alarm_rule
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_record_alarm_rule]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_record_alarm_rule]
GO

CREATE TABLE [dbo].[ems_record_alarm_rule] (
  [obj_id] int  NOT NULL,
  [rule_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [rule_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [monitor_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_time] datetime2(7)  NULL,
  [energy_type] int  NULL,
  [trigger_rule] int  NULL,
  [monitor_field] int  NULL,
  [time_range] int  NULL,
  [trigger_value] decimal(16,2)  NULL,
  [notify_user] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [cause] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[ems_record_alarm_rule] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'规则编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'rule_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'规则名称',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'rule_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'monitor_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'能源类型',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'energy_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'触发规则（0大于 1小于）',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'trigger_rule'
GO

EXEC sp_addextendedproperty
'MS_Description', N'监测字段（0温度，1湿度，2振动-速度(mm/s)，3振动-位移(um)，4振动-加速度(g)，5振动-温度(℃),6-噪音，7-照度，8-气体浓度）',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'monitor_field'
GO

EXEC sp_addextendedproperty
'MS_Description', N'时间范围(分)',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'time_range'
GO

EXEC sp_addextendedproperty
'MS_Description', N'触发阈值量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'trigger_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知用户',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'notify_user'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'cause'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'异常告警规则',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_alarm_rule'
GO


-- ----------------------------
-- Table structure for ems_record_dnb_instant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_record_dnb_instant]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_record_dnb_instant]
GO

CREATE TABLE [dbo].[ems_record_dnb_instant] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_time] datetime2(7)  NULL,
  [v_a] decimal(18,2)  NULL,
  [v_b] decimal(18,2)  NULL,
  [v_c] decimal(18,2)  NULL,
  [i_a] decimal(18,2)  NULL,
  [i_b] decimal(18,2)  NULL,
  [i_c] decimal(18,2)  NULL,
  [record_time] datetime2(7)  NULL,
  [glys] decimal(18,3)  NULL,
  [zxyg] decimal(18,2)  NULL,
  [active_power] decimal(18,2)  NULL,
  [reactive_power] decimal(18,2)  NULL,
  [collect_type] int  NULL
)
GO

ALTER TABLE [dbo].[ems_record_dnb_instant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A相电压',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'v_a'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B相电压',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'v_b'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C相电压',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'v_c'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A相电流',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'i_a'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B相电流',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'i_b'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C相电流',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'i_c'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'功率因数',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'glys'
GO

EXEC sp_addextendedproperty
'MS_Description', N'正向有功',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'zxyg'
GO

EXEC sp_addextendedproperty
'MS_Description', N'有功功率',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'active_power'
GO

EXEC sp_addextendedproperty
'MS_Description', N'无功功率',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'reactive_power'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集方式（0自动 1手动）',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant',
'COLUMN', N'collect_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'电实时数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_dnb_instant'
GO


-- ----------------------------
-- Table structure for ems_record_steam_instant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_record_steam_instant]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_record_steam_instant]
GO

CREATE TABLE [dbo].[ems_record_steam_instant] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_time] datetime2(7)  NULL,
  [flux_flow] decimal(18,2)  NULL,
  [steam_flow] decimal(18,2)  NULL,
  [heat_instant_value] decimal(18,2)  NULL,
  [heat_total_value] decimal(18,2)  NULL,
  [temperature] decimal(18,2)  NULL,
  [press] decimal(18,2)  NULL,
  [density] decimal(18,2)  NULL,
  [difference_press] decimal(18,2)  NULL,
  [record_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[ems_record_steam_instant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'瞬时流量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'flux_flow'
GO

EXEC sp_addextendedproperty
'MS_Description', N'累计流量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'steam_flow'
GO

EXEC sp_addextendedproperty
'MS_Description', N'瞬时热量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'heat_instant_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'累计热量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'heat_total_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'温度',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'temperature'
GO

EXEC sp_addextendedproperty
'MS_Description', N'压力',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'press'
GO

EXEC sp_addextendedproperty
'MS_Description', N'密度',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'density'
GO

EXEC sp_addextendedproperty
'MS_Description', N'压力差值',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'difference_press'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'蒸汽实时数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_steam_instant'
GO


-- ----------------------------
-- Table structure for ems_record_water_instant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_record_water_instant]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_record_water_instant]
GO

CREATE TABLE [dbo].[ems_record_water_instant] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collect_time] datetime2(7)  NULL,
  [flux_flow] decimal(18,2)  NULL,
  [water_flow] decimal(18,2)  NULL,
  [record_time] datetime2(7)  NULL,
  [collect_type] int  NULL
)
GO

ALTER TABLE [dbo].[ems_record_water_instant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'瞬时流量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'flux_flow'
GO

EXEC sp_addextendedproperty
'MS_Description', N'累计流量',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'water_flow'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集方式（0自动 1手动）',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant',
'COLUMN', N'collect_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'水实时数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_record_water_instant'
GO


-- ----------------------------
-- Table structure for ems_report_point_dnb
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_report_point_dnb]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_report_point_dnb]
GO

CREATE TABLE [dbo].[ems_report_point_dnb] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [instrument_value] decimal(18,2)  NULL,
  [expend] decimal(18,2)  NULL,
  [record_time] datetime2(7)  NULL,
  [begin_time] datetime2(7)  NULL,
  [end_time] datetime2(7)  NULL,
  [update_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] date  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] date  NULL
)
GO

ALTER TABLE [dbo].[ems_report_point_dnb] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'仪表值',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'instrument_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'耗量',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'expend'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'begin_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'结束时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'end_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改标识（0是 1否）',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'update_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'电整点数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_dnb'
GO


-- ----------------------------
-- Table structure for ems_report_point_steam
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_report_point_steam]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_report_point_steam]
GO

CREATE TABLE [dbo].[ems_report_point_steam] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [instrument_value] decimal(18,2)  NULL,
  [expend] decimal(18,2)  NULL,
  [record_time] datetime2(7)  NULL,
  [begin_time] datetime2(7)  NULL,
  [end_time] datetime2(7)  NULL,
  [update_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] date  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] date  NULL
)
GO

ALTER TABLE [dbo].[ems_report_point_steam] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'仪表值',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'instrument_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'耗量',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'expend'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'begin_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'结束时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'end_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改标识（0是 1否）',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'update_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'蒸汽整点数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_steam'
GO


-- ----------------------------
-- Table structure for ems_report_point_water
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[ems_report_point_water]') AND type IN ('U'))
	DROP TABLE [dbo].[ems_report_point_water]
GO

CREATE TABLE [dbo].[ems_report_point_water] (
  [obj_id] bigint  NOT NULL,
  [monitor_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [instrument_value] decimal(18,2)  NULL,
  [expend] decimal(18,2)  NULL,
  [record_time] datetime2(7)  NULL,
  [begin_time] datetime2(7)  NULL,
  [end_time] datetime2(7)  NULL,
  [update_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] date  NULL,
  [update_by] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] date  NULL
)
GO

ALTER TABLE [dbo].[ems_report_point_water] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'obj_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'monitor_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'仪表值',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'instrument_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'耗量',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'expend'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'begin_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'结束时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'end_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改标识（0是 1否）',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'update_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'水整点数据',
'SCHEMA', N'dbo',
'TABLE', N'ems_report_point_water'
GO


-- ----------------------------
-- Table structure for flow_category
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_category]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_category]
GO

CREATE TABLE [dbo].[flow_category] (
  [category_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [parent_id] bigint DEFAULT 0 NULL,
  [ancestors] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [category_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [order_num] int DEFAULT 0 NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[flow_category] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程分类ID',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'category_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父流程分类id',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'祖级列表',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'ancestors'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程分类名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'category_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示顺序',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'order_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_category',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程分类',
'SCHEMA', N'dbo',
'TABLE', N'flow_category'
GO


-- ----------------------------
-- Table structure for flow_definition
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_definition]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_definition]
GO

CREATE TABLE [dbo].[flow_definition] (
  [id] bigint  NOT NULL,
  [flow_code] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [flow_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [model_value] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'CLASSICS' NOT NULL,
  [category] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [version] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [is_publish] tinyint DEFAULT '0' NULL,
  [form_custom] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [form_path] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [activity_status] tinyint DEFAULT '1' NULL,
  [listener_type] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [listener_path] nvarchar(400) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ext] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_definition] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'flow_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'flow_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设计器模型（CLASSICS经典模型 MIMIC仿钉钉模型）',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'model_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程类别',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'category'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程版本',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否发布（0未发布 1已发布 9失效）',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'is_publish'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单是否自定义（Y是 N否）',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'form_custom'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单路径',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'form_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程激活状态（0挂起 1激活）',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'activity_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'监听器类型',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'listener_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'监听器路径',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'listener_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务详情 存业务表对象json字符串',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'ext'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程定义表',
'SCHEMA', N'dbo',
'TABLE', N'flow_definition'
GO


-- ----------------------------
-- Table structure for flow_his_task
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_his_task]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_his_task]
GO

CREATE TABLE [dbo].[flow_his_task] (
  [id] bigint  NOT NULL,
  [definition_id] bigint  NOT NULL,
  [instance_id] bigint  NOT NULL,
  [task_id] bigint  NOT NULL,
  [node_code] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [node_name] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [node_type] tinyint  NULL,
  [target_node_code] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [target_node_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [approver] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [cooperate_type] tinyint DEFAULT '0' NULL,
  [collaborator] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [skip_type] nvarchar(10) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [flow_status] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [form_custom] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [form_path] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [message] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [variable] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ext] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [update_time] datetime2(7)  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_his_task] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应flow_definition表的id',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'definition_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应flow_instance表的id',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'instance_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应flow_task表的id',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'task_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始节点编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始节点名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'node_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始节点类型（0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关）',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'目标节点编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'target_node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'结束节点名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'target_node_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批者',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'approver'
GO

EXEC sp_addextendedproperty
'MS_Description', N'协作方式(1审批 2转办 3委派 4会签 5票签 6加签 7减签)',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'cooperate_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'协作人',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'collaborator'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流转类型（PASS通过 REJECT退回 NONE无动作）',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'skip_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程状态（0待提交 1审批中 2审批通过 4终止 5作废 6撤销 8已完成 9已退回 10失效 11拿回）',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'flow_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单是否自定义（Y是 N否）',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'form_custom'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单路径',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'form_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批意见',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'message'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务变量',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'variable'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务详情 存业务表对象json字符串',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'ext'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务开始时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批完成时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'历史任务记录表',
'SCHEMA', N'dbo',
'TABLE', N'flow_his_task'
GO


-- ----------------------------
-- Table structure for flow_instance
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_instance]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_instance]
GO

CREATE TABLE [dbo].[flow_instance] (
  [id] bigint  NOT NULL,
  [definition_id] bigint  NOT NULL,
  [business_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [node_type] tinyint  NOT NULL,
  [node_code] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [node_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [variable] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [flow_status] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [activity_status] tinyint DEFAULT '1' NULL,
  [def_json] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ext] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_instance] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应flow_definition表的id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'definition_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'business_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点类型（0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关）',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程节点编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程节点名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'node_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务变量',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'variable'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程状态（0待提交 1审批中 2审批通过 4终止 5作废 6撤销 8已完成 9已退回 10失效 11拿回）',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'flow_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程激活状态（0挂起 1激活）',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'activity_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程定义json',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'def_json'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段，预留给业务系统使用',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'ext'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程实例表',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance'
GO


-- ----------------------------
-- Table structure for flow_instance_biz_ext
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_instance_biz_ext]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_instance_biz_ext]
GO

CREATE TABLE [dbo].[flow_instance_biz_ext] (
  [id] bigint  NOT NULL,
  [tenant_id] varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime  NULL,
  [business_code] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [business_title] varchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] char(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [instance_id] bigint  NULL,
  [business_id] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_instance_biz_ext] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'business_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务标题',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'business_title'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程实例Id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'instance_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务Id',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext',
'COLUMN', N'business_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程实例业务扩展表',
'SCHEMA', N'dbo',
'TABLE', N'flow_instance_biz_ext'
GO


-- ----------------------------
-- Table structure for flow_node
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_node]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_node]
GO

CREATE TABLE [dbo].[flow_node] (
  [id] bigint  NOT NULL,
  [node_type] tinyint  NOT NULL,
  [definition_id] bigint  NOT NULL,
  [node_code] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [node_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [permission_flag] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [node_ratio] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [coordinate] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [any_node_skip] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [listener_type] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [listener_path] nvarchar(400) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [form_custom] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [form_path] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [version] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [ext] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_node] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点类型（0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关）',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程定义id',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'definition_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程节点编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程节点名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'node_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'权限标识（权限类型:权限标识，可以多个，用@@隔开)',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'permission_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程签署比例值',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'node_ratio'
GO

EXEC sp_addextendedproperty
'MS_Description', N'坐标',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'coordinate'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任意结点跳转',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'any_node_skip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'监听器类型',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'listener_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'监听器路径',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'listener_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单是否自定义（Y是 N否）',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'form_custom'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单路径',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'form_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点扩展属性',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'ext'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_node',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程节点表',
'SCHEMA', N'dbo',
'TABLE', N'flow_node'
GO


-- ----------------------------
-- Table structure for flow_skip
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_skip]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_skip]
GO

CREATE TABLE [dbo].[flow_skip] (
  [id] bigint  NOT NULL,
  [definition_id] bigint  NOT NULL,
  [now_node_code] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [now_node_type] tinyint  NULL,
  [next_node_code] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [next_node_type] tinyint  NULL,
  [skip_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [skip_type] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [skip_condition] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [coordinate] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_skip] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程定义id',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'definition_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'当前流程节点的编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'now_node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'当前节点类型（0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关）',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'now_node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下一个流程节点的编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'next_node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下一个节点类型（0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关）',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'next_node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'跳转名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'skip_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'跳转类型（PASS审批通过 REJECT退回）',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'skip_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'跳转条件',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'skip_condition'
GO

EXEC sp_addextendedproperty
'MS_Description', N'坐标',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'coordinate'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点跳转关联表',
'SCHEMA', N'dbo',
'TABLE', N'flow_skip'
GO


-- ----------------------------
-- Table structure for flow_spel
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_spel]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_spel]
GO

CREATE TABLE [dbo].[flow_spel] (
  [id] bigint  NOT NULL,
  [component_name] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [method_name] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [method_params] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [view_spel] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [remark] varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [status] char(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [del_flag] char(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime  NULL
)
GO

ALTER TABLE [dbo].[flow_spel] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组件名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'component_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'方法名',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'method_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'method_params'
GO

EXEC sp_addextendedproperty
'MS_Description', N'预览spel表达式',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'view_spel'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程spel表达式定义表',
'SCHEMA', N'dbo',
'TABLE', N'flow_spel'
GO


-- ----------------------------
-- Table structure for flow_task
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_task]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_task]
GO

CREATE TABLE [dbo].[flow_task] (
  [id] bigint  NOT NULL,
  [definition_id] bigint  NOT NULL,
  [instance_id] bigint  NOT NULL,
  [node_code] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [node_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [node_type] tinyint  NOT NULL,
  [flow_status] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [form_custom] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [form_path] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_task] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应flow_definition表的id',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'definition_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对应flow_instance表的id',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'instance_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点编码',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'node_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点名称',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'node_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点类型（0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关）',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程状态（0待提交 1审批中 2审批通过 4终止 5作废 6撤销 8已完成 9已退回 10失效 11拿回）',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'flow_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单是否自定义（Y是 N否）',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'form_custom'
GO

EXEC sp_addextendedproperty
'MS_Description', N'审批表单路径',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'form_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_task',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'待办任务表',
'SCHEMA', N'dbo',
'TABLE', N'flow_task'
GO


-- ----------------------------
-- Table structure for flow_user
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[flow_user]') AND type IN ('U'))
	DROP TABLE [dbo].[flow_user]
GO

CREATE TABLE [dbo].[flow_user] (
  [id] bigint  NOT NULL,
  [type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [processed_by] nvarchar(80) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [associated] bigint  NOT NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [tenant_id] nvarchar(40) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[flow_user] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键id',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'人员类型（1待办任务的审批人权限 2待办任务的转办人权限 3待办任务的委托人权限）',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'权限人',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'processed_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务表id',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'associated'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'flow_user',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程用户表',
'SCHEMA', N'dbo',
'TABLE', N'flow_user'
GO


-- ----------------------------
-- Table structure for gen_table
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[gen_table]') AND type IN ('U'))
	DROP TABLE [dbo].[gen_table]
GO

CREATE TABLE [dbo].[gen_table] (
  [table_id] bigint  NOT NULL,
  [data_name] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [table_name] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [table_comment] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [sub_table_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [sub_table_fk_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [class_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [tpl_category] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'crud' NULL,
  [package_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [module_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [business_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [function_name] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [function_author] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [gen_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [gen_path] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '/' NULL,
  [options] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[gen_table] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'编号',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'table_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'数据源名称',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'data_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'表名称',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'table_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'表描述',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'table_comment'
GO

EXEC sp_addextendedproperty
'MS_Description', N'关联子表的表名',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'sub_table_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'子表关联的外键名',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'sub_table_fk_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'实体类名称',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'class_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'使用的模板（crud单表操作 tree树表操作）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'tpl_category'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成包路径',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'package_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成模块名',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'module_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成业务名',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'business_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成功能名',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'function_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成功能作者',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'function_author'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成代码方式（0zip压缩包 1自定义路径）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'gen_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'生成路径（不填默认项目路径）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'gen_path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'其它生成选项',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'options'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'gen_table',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'代码生成业务表',
'SCHEMA', N'dbo',
'TABLE', N'gen_table'
GO


-- ----------------------------
-- Table structure for gen_table_column
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[gen_table_column]') AND type IN ('U'))
	DROP TABLE [dbo].[gen_table_column]
GO

CREATE TABLE [dbo].[gen_table_column] (
  [column_id] bigint  NOT NULL,
  [table_id] bigint  NULL,
  [column_name] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [column_comment] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [column_type] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [java_type] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [java_field] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_pk] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_increment] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_required] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_insert] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_edit] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_list] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_query] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [query_type] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'EQ' NULL,
  [html_type] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [dict_type] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [sort] int  NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[gen_table_column] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'编号',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'column_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'归属表编号',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'table_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'列名称',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'column_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'列描述',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'column_comment'
GO

EXEC sp_addextendedproperty
'MS_Description', N'列类型',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'column_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'JAVA类型',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'java_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'JAVA字段名',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'java_field'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否主键（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_pk'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否自增（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_increment'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否必填（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_required'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否为插入字段（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_insert'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否编辑字段（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_edit'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否列表字段（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_list'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否查询字段（1是）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'is_query'
GO

EXEC sp_addextendedproperty
'MS_Description', N'查询方式（等于、不等于、大于、小于、范围）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'query_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示类型（文本框、文本域、下拉框、复选框、单选框、日期控件）',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'html_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典类型',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'dict_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'排序',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'代码生成业务表字段',
'SCHEMA', N'dbo',
'TABLE', N'gen_table_column'
GO


-- ----------------------------
-- Table structure for record_dnb_instant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[record_dnb_instant]') AND type IN ('U'))
	DROP TABLE [dbo].[record_dnb_instant]
GO

CREATE TABLE [dbo].[record_dnb_instant] (
  [objid] bigint  NOT NULL,
  [monitor_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [va] decimal(18,2)  NULL,
  [vb] decimal(18,2)  NULL,
  [vc] decimal(18,2)  NULL,
  [ia] decimal(18,2)  NULL,
  [ib] decimal(18,2)  NULL,
  [ic] decimal(18,2)  NULL,
  [glys] decimal(18,2)  NULL,
  [zxyg] decimal(18,2)  NULL,
  [active_power] decimal(18,2)  NULL,
  [reactive_power] decimal(18,2)  NULL,
  [collect_type] int  NULL,
  [collect_time] datetime2(7)  NULL,
  [record_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[record_dnb_instant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'编号',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'objid'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'monitor_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A项电压',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'va'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B项电压',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'vb'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C项电压',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'vc'
GO

EXEC sp_addextendedproperty
'MS_Description', N'A项电流',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'ia'
GO

EXEC sp_addextendedproperty
'MS_Description', N'B项电流',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'ib'
GO

EXEC sp_addextendedproperty
'MS_Description', N'C项电流',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'ic'
GO

EXEC sp_addextendedproperty
'MS_Description', N'功率因数',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'glys'
GO

EXEC sp_addextendedproperty
'MS_Description', N'正向有功',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'zxyg'
GO

EXEC sp_addextendedproperty
'MS_Description', N'有功功率',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'active_power'
GO

EXEC sp_addextendedproperty
'MS_Description', N'无功功率',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'reactive_power'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集方式',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'collect_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'电实时数据',
'SCHEMA', N'dbo',
'TABLE', N'record_dnb_instant'
GO


-- ----------------------------
-- Table structure for record_dnb_instant_20250702
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[record_dnb_instant_20250702]') AND type IN ('U'))
	DROP TABLE [dbo].[record_dnb_instant_20250702]
GO

CREATE TABLE [dbo].[record_dnb_instant_20250702] (
  [objid] bigint  NOT NULL,
  [monitor_id] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [va] decimal(18,4)  NOT NULL,
  [vb] decimal(18,4)  NOT NULL,
  [vc] decimal(18,4)  NOT NULL,
  [ia] decimal(18,4)  NOT NULL,
  [ib] decimal(18,4)  NOT NULL,
  [ic] decimal(18,4)  NOT NULL,
  [glys] decimal(18,4)  NOT NULL,
  [zxyg] decimal(18,4)  NOT NULL,
  [active_power] decimal(18,4)  NOT NULL,
  [reactive_power] decimal(18,4)  NOT NULL,
  [collect_type] int  NOT NULL,
  [collect_time] datetime2(7)  NOT NULL,
  [record_time] datetime2(7)  NOT NULL
)
GO

ALTER TABLE [dbo].[record_dnb_instant_20250702] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for record_fluid_instant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[record_fluid_instant]') AND type IN ('U'))
	DROP TABLE [dbo].[record_fluid_instant]
GO

CREATE TABLE [dbo].[record_fluid_instant] (
  [objid] bigint  NOT NULL,
  [monitor_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [temperature] decimal(18,2)  NULL,
  [press] decimal(18,2)  NULL,
  [frequency] decimal(18,2)  NULL,
  [density] decimal(18,2)  NULL,
  [instant_heat] decimal(18,2)  NULL,
  [total_heat] decimal(18,2)  NULL,
  [instant_flow] decimal(18,2)  NULL,
  [total_flow] decimal(18,2)  NULL,
  [collect_type] int  NULL,
  [collect_time] datetime2(7)  NULL,
  [record_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[record_fluid_instant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'自增标识',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'objid'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'monitor_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'温度值',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'temperature'
GO

EXEC sp_addextendedproperty
'MS_Description', N'压力值',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'press'
GO

EXEC sp_addextendedproperty
'MS_Description', N'频率值',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'frequency'
GO

EXEC sp_addextendedproperty
'MS_Description', N'密度值',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'density'
GO

EXEC sp_addextendedproperty
'MS_Description', N'瞬时热量',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'instant_heat'
GO

EXEC sp_addextendedproperty
'MS_Description', N'累计热量值',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'total_heat'
GO

EXEC sp_addextendedproperty
'MS_Description', N'瞬时流量',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'instant_flow'
GO

EXEC sp_addextendedproperty
'MS_Description', N'累计流量',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'total_flow'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集方式',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'collect_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'collect_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant',
'COLUMN', N'record_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流体实时数据',
'SCHEMA', N'dbo',
'TABLE', N'record_fluid_instant'
GO


-- ----------------------------
-- Table structure for record_fluid_instant_20250702
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[record_fluid_instant_20250702]') AND type IN ('U'))
	DROP TABLE [dbo].[record_fluid_instant_20250702]
GO

CREATE TABLE [dbo].[record_fluid_instant_20250702] (
  [objid] bigint  NOT NULL,
  [monitor_id] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [temperature] decimal(18,4)  NOT NULL,
  [press] decimal(18,4)  NOT NULL,
  [frequency] decimal(18,4)  NOT NULL,
  [density] decimal(18,4)  NOT NULL,
  [instant_heat] decimal(18,4)  NOT NULL,
  [total_heat] decimal(18,4)  NOT NULL,
  [instant_flow] decimal(18,4)  NOT NULL,
  [total_flow] decimal(18,4)  NOT NULL,
  [collect_type] int  NOT NULL,
  [collect_time] datetime2(7)  NOT NULL,
  [record_time] datetime2(7)  NOT NULL
)
GO

ALTER TABLE [dbo].[record_fluid_instant_20250702] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for record_iotenv_instant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[record_iotenv_instant]') AND type IN ('U'))
	DROP TABLE [dbo].[record_iotenv_instant]
GO

CREATE TABLE [dbo].[record_iotenv_instant] (
  [objid] bigint  NOT NULL,
  [monitorId] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [temperature] decimal(18,2)  NULL,
  [humidity] decimal(18,2)  NULL,
  [illuminance] decimal(18,2)  NULL,
  [noise] decimal(18,2)  NULL,
  [concentration] decimal(18,2)  NULL,
  [vibration_speed] decimal(18,2)  NULL,
  [vibration_displacement] decimal(18,2)  NULL,
  [vibration_acceleration] decimal(18,2)  NULL,
  [vibration_temp] decimal(18,2)  NULL,
  [collectTime] datetime2(7)  NULL,
  [recodeTime] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[record_iotenv_instant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'objid'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'monitorId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'温度',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'temperature'
GO

EXEC sp_addextendedproperty
'MS_Description', N'湿度',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'humidity'
GO

EXEC sp_addextendedproperty
'MS_Description', N'照度',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'illuminance'
GO

EXEC sp_addextendedproperty
'MS_Description', N'噪声',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'noise'
GO

EXEC sp_addextendedproperty
'MS_Description', N'硫化氢浓度',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'concentration'
GO

EXEC sp_addextendedproperty
'MS_Description', N'振动-速度(mm/s)',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'vibration_speed'
GO

EXEC sp_addextendedproperty
'MS_Description', N'振动-位移(um)',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'vibration_displacement'
GO

EXEC sp_addextendedproperty
'MS_Description', N'振动-加速度(g)',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'vibration_acceleration'
GO

EXEC sp_addextendedproperty
'MS_Description', N'振动-温度(℃)',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'vibration_temp'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'collectTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant',
'COLUMN', N'recodeTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'物联网数据',
'SCHEMA', N'dbo',
'TABLE', N'record_iotenv_instant'
GO


-- ----------------------------
-- Table structure for record_iotenv_instant_20260326
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[record_iotenv_instant_20260326]') AND type IN ('U'))
	DROP TABLE [dbo].[record_iotenv_instant_20260326]
GO

CREATE TABLE [dbo].[record_iotenv_instant_20260326] (
  [objid] bigint  NOT NULL,
  [monitorId] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [temperature] decimal(18,4)  NOT NULL,
  [humidity] decimal(18,4)  NOT NULL,
  [illuminance] decimal(18,4)  NOT NULL,
  [noise] decimal(18,4)  NOT NULL,
  [concentration] decimal(18,4)  NOT NULL,
  [vibration_speed] decimal(18,4)  NOT NULL,
  [vibration_displacement] decimal(18,4)  NOT NULL,
  [vibration_acceleration] decimal(18,4)  NOT NULL,
  [vibration_temp] decimal(18,4)  NOT NULL,
  [collectTime] datetime2(7)  NOT NULL,
  [recodeTime] datetime2(7)  NOT NULL
)
GO

ALTER TABLE [dbo].[record_iotenv_instant_20260326] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for sj_distributed_lock
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_distributed_lock]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_distributed_lock]
GO

CREATE TABLE [dbo].[sj_distributed_lock] (
  [name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [lock_until] datetime2(7) DEFAULT getdate() NOT NULL,
  [locked_at] datetime2(7) DEFAULT getdate() NOT NULL,
  [locked_by] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_distributed_lock] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'锁名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock',
'COLUMN', N'name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'锁定时长',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock',
'COLUMN', N'lock_until'
GO

EXEC sp_addextendedproperty
'MS_Description', N'锁定时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock',
'COLUMN', N'locked_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'锁定者',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock',
'COLUMN', N'locked_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'锁定表',
'SCHEMA', N'dbo',
'TABLE', N'sj_distributed_lock'
GO


-- ----------------------------
-- Table structure for sj_group_config
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_group_config]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_group_config]
GO

CREATE TABLE [dbo].[sj_group_config] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [token] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'SJ_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT' NOT NULL,
  [group_status] tinyint DEFAULT 0 NOT NULL,
  [version] int  NOT NULL,
  [group_partition] int  NOT NULL,
  [id_generator_mode] tinyint DEFAULT 1 NOT NULL,
  [init_scene] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_group_config] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'token',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'token'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组状态 0、未启用 1、启用',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'group_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本号',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分区',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'group_partition'
GO

EXEC sp_addextendedproperty
'MS_Description', N'唯一id生成模式 默认号段模式',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'id_generator_mode'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否初始化场景 0:否 1:是',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'init_scene'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组配置',
'SCHEMA', N'dbo',
'TABLE', N'sj_group_config'
GO


-- ----------------------------
-- Table structure for sj_job
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_job]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_job]
GO

CREATE TABLE [dbo].[sj_job] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [job_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [args_str] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [args_type] tinyint DEFAULT 1 NOT NULL,
  [next_trigger_at] bigint  NOT NULL,
  [job_status] tinyint DEFAULT 1 NOT NULL,
  [task_type] tinyint DEFAULT 1 NOT NULL,
  [route_key] tinyint DEFAULT 4 NOT NULL,
  [executor_type] tinyint DEFAULT 1 NOT NULL,
  [executor_info] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [trigger_type] tinyint  NOT NULL,
  [trigger_interval] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [block_strategy] tinyint DEFAULT 1 NOT NULL,
  [executor_timeout] int DEFAULT 0 NOT NULL,
  [max_retry_times] int DEFAULT 0 NOT NULL,
  [parallel_num] int DEFAULT 1 NOT NULL,
  [retry_interval] int DEFAULT 0 NOT NULL,
  [bucket_index] int DEFAULT 0 NOT NULL,
  [resident] tinyint DEFAULT 0 NOT NULL,
  [notify_ids] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [owner_id] bigint DEFAULT NULL NULL,
  [labels] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [deleted] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_job] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'job_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行方法参数',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'args_str'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数类型 ',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'args_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下次触发时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'next_trigger_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务状态 0、关闭、1、开启',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'job_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务类型 1、集群 2、广播 3、切片',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'task_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'路由策略',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'route_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行器类型',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'executor_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行器名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'executor_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'触发类型 1.CRON 表达式 2. 固定时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'trigger_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'间隔时长',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'trigger_interval'
GO

EXEC sp_addextendedproperty
'MS_Description', N'阻塞策略 1、丢弃 2、覆盖 3、并行 4、恢复',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'block_strategy'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行超时时间，单位秒',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'executor_timeout'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最大重试次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'max_retry_times'
GO

EXEC sp_addextendedproperty
'MS_Description', N'并行数',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'parallel_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试间隔 ( s)',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'retry_interval'
GO

EXEC sp_addextendedproperty
'MS_Description', N'bucket',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'bucket_index'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否是常驻任务',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'resident'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知告警场景配置id列表',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'notify_ids'
GO

EXEC sp_addextendedproperty
'MS_Description', N'负责人id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'owner_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'标签',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'labels'
GO

EXEC sp_addextendedproperty
'MS_Description', N'描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除 1、删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务信息',
'SCHEMA', N'dbo',
'TABLE', N'sj_job'
GO


-- ----------------------------
-- Table structure for sj_job_executor
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_job_executor]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_job_executor]
GO

CREATE TABLE [dbo].[sj_job_executor] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [executor_info] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [executor_type] nvarchar(3) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_job_executor] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行器名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'executor_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'1:java 2:python 3:go',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'executor_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行器信息',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_executor'
GO


-- ----------------------------
-- Table structure for sj_job_log_message
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_job_log_message]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_job_log_message]
GO

CREATE TABLE [dbo].[sj_job_log_message] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [job_id] bigint  NOT NULL,
  [task_batch_id] bigint  NOT NULL,
  [task_id] bigint  NOT NULL,
  [message] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [log_num] int DEFAULT 1 NOT NULL,
  [real_time] bigint DEFAULT 0 NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_job_log_message] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务信息id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'job_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务批次id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'task_batch_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'调度任务id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'task_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'调度信息',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'message'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'log_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'上报时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'real_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'调度日志',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_log_message'
GO


-- ----------------------------
-- Table structure for sj_job_summary
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_job_summary]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_job_summary]
GO

CREATE TABLE [dbo].[sj_job_summary] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [business_id] bigint  NOT NULL,
  [system_task_type] tinyint DEFAULT 3 NOT NULL,
  [trigger_at] datetime2(7) DEFAULT getdate() NOT NULL,
  [success_num] int DEFAULT 0 NOT NULL,
  [fail_num] int DEFAULT 0 NOT NULL,
  [fail_reason] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [stop_num] int DEFAULT 0 NOT NULL,
  [stop_reason] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [cancel_num] int DEFAULT 0 NOT NULL,
  [cancel_reason] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_job_summary] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务id  ( job_id或workflow_id)',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'business_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务类型 3、JOB任务 4、WORKFLOW任务',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'system_task_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'trigger_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行成功-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'success_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行失败-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'fail_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'失败原因',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'fail_reason'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行失败-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'stop_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'失败原因',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'stop_reason'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行失败-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'cancel_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'失败原因',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'cancel_reason'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'DashBoard_Job',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_summary'
GO


-- ----------------------------
-- Table structure for sj_job_task
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_job_task]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_job_task]
GO

CREATE TABLE [dbo].[sj_job_task] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [job_id] bigint  NOT NULL,
  [task_batch_id] bigint  NOT NULL,
  [parent_id] bigint DEFAULT 0 NOT NULL,
  [task_status] tinyint DEFAULT 0 NOT NULL,
  [retry_count] int DEFAULT 0 NOT NULL,
  [mr_stage] tinyint DEFAULT NULL NULL,
  [leaf] tinyint DEFAULT '1' NOT NULL,
  [task_name] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [client_info] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [wf_context] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [result_message] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [args_str] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [args_type] tinyint DEFAULT 1 NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_job_task] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务信息id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'job_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'调度任务id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'task_batch_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父执行器id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行的状态 0、失败 1、成功',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'task_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'retry_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'动态分片所处阶段 1:map 2:reduce 3:mergeReduce',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'mr_stage'
GO

EXEC sp_addextendedproperty
'MS_Description', N'叶子节点',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'leaf'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'task_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'客户端地址 clientId#ip:port',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'client_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流全局上下文',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'wf_context'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行结果',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'result_message'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行方法参数',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'args_str'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数类型 ',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'args_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务实例',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task'
GO


-- ----------------------------
-- Table structure for sj_job_task_batch
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_job_task_batch]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_job_task_batch]
GO

CREATE TABLE [dbo].[sj_job_task_batch] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [job_id] bigint  NOT NULL,
  [workflow_node_id] bigint DEFAULT 0 NOT NULL,
  [parent_workflow_node_id] bigint DEFAULT 0 NOT NULL,
  [workflow_task_batch_id] bigint DEFAULT 0 NOT NULL,
  [task_batch_status] tinyint DEFAULT 0 NOT NULL,
  [operation_reason] tinyint DEFAULT 0 NOT NULL,
  [execution_at] bigint DEFAULT 0 NOT NULL,
  [system_task_type] tinyint DEFAULT 3 NOT NULL,
  [parent_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [deleted] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_job_task_batch] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'job_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流节点id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'workflow_node_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流任务父批次id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'parent_workflow_node_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流任务批次id',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'workflow_task_batch_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务批次状态 0、失败 1、成功',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'task_batch_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作原因',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'operation_reason'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'execution_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务类型 3、JOB任务 4、WORKFLOW任务',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'system_task_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父节点',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除 1、删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务批次',
'SCHEMA', N'dbo',
'TABLE', N'sj_job_task_batch'
GO


-- ----------------------------
-- Table structure for sj_namespace
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_namespace]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_namespace]
GO

CREATE TABLE [dbo].[sj_namespace] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [unique_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [deleted] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_namespace] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'唯一id',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'unique_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除 1、删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间',
'SCHEMA', N'dbo',
'TABLE', N'sj_namespace'
GO


-- ----------------------------
-- Table structure for sj_notify_config
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_notify_config]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_notify_config]
GO

CREATE TABLE [dbo].[sj_notify_config] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [notify_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [system_task_type] tinyint DEFAULT 3 NOT NULL,
  [notify_status] tinyint DEFAULT 0 NOT NULL,
  [recipient_ids] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [notify_threshold] int DEFAULT 0 NOT NULL,
  [notify_scene] tinyint DEFAULT 0 NOT NULL,
  [rate_limiter_status] tinyint DEFAULT 0 NOT NULL,
  [rate_limiter_threshold] int DEFAULT 0 NOT NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_notify_config] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'notify_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务类型 1. 重试任务 2. 重试回调 3、JOB任务 4、WORKFLOW任务',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'system_task_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知状态 0、未启用 1、启用',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'notify_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'接收人id列表',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'recipient_ids'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知阈值',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'notify_threshold'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知场景',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'notify_scene'
GO

EXEC sp_addextendedproperty
'MS_Description', N'限流状态 0、未启用 1、启用',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'rate_limiter_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'每秒限流阈值',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'rate_limiter_threshold'
GO

EXEC sp_addextendedproperty
'MS_Description', N'描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知配置',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_config'
GO


-- ----------------------------
-- Table structure for sj_notify_recipient
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_notify_recipient]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_notify_recipient]
GO

CREATE TABLE [dbo].[sj_notify_recipient] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [recipient_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [notify_type] tinyint DEFAULT 0 NOT NULL,
  [notify_attribute] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_notify_recipient] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'接收人名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'recipient_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'notify_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'配置属性',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'notify_attribute'
GO

EXEC sp_addextendedproperty
'MS_Description', N'描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'告警通知接收人',
'SCHEMA', N'dbo',
'TABLE', N'sj_notify_recipient'
GO


-- ----------------------------
-- Table structure for sj_retry
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_retry]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_retry]
GO

CREATE TABLE [dbo].[sj_retry] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [group_id] bigint  NOT NULL,
  [scene_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [scene_id] bigint  NOT NULL,
  [idempotent_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [biz_no] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [executor_name] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [args_str] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [ext_attrs] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [serializer_name] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'jackson' NOT NULL,
  [next_trigger_at] bigint  NOT NULL,
  [retry_count] int DEFAULT 0 NOT NULL,
  [retry_status] tinyint DEFAULT 0 NOT NULL,
  [task_type] tinyint DEFAULT 1 NOT NULL,
  [bucket_index] int DEFAULT 0 NOT NULL,
  [parent_id] bigint DEFAULT 0 NOT NULL,
  [deleted] bigint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_retry] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组Id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'scene_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景ID',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'scene_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'幂等id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'idempotent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务编号',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'biz_no'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行器名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'executor_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行方法参数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'args_str'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行方法参数序列化器名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'serializer_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下次触发时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'next_trigger_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'retry_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试状态 0、重试中 1、成功 2、最大重试次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'retry_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务类型 1、重试数据 2、回调数据',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'task_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'bucket',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'bucket_index'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父节点id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试信息表',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry'
GO


-- ----------------------------
-- Table structure for sj_retry_dead_letter
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_retry_dead_letter]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_retry_dead_letter]
GO

CREATE TABLE [dbo].[sj_retry_dead_letter] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [group_id] bigint  NOT NULL,
  [scene_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [scene_id] bigint  NOT NULL,
  [idempotent_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [biz_no] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [executor_name] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [serializer_name] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'jackson' NOT NULL,
  [args_str] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [ext_attrs] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_retry_dead_letter] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组Id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'scene_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景ID',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'scene_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'幂等id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'idempotent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务编号',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'biz_no'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行器名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'executor_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行方法参数序列化器名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'serializer_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'执行方法参数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'args_str'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'死信队列表',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_dead_letter'
GO


-- ----------------------------
-- Table structure for sj_retry_scene_config
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_retry_scene_config]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_retry_scene_config]
GO

CREATE TABLE [dbo].[sj_retry_scene_config] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [scene_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [scene_status] tinyint DEFAULT 0 NOT NULL,
  [max_retry_count] int DEFAULT 5 NOT NULL,
  [back_off] tinyint DEFAULT 1 NOT NULL,
  [trigger_interval] nvarchar(16) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [notify_ids] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [deadline_request] bigint DEFAULT 60000 NOT NULL,
  [executor_timeout] int DEFAULT 5 NOT NULL,
  [route_key] tinyint DEFAULT 4 NOT NULL,
  [block_strategy] tinyint DEFAULT 1 NOT NULL,
  [cb_status] tinyint DEFAULT 0 NOT NULL,
  [cb_trigger_type] tinyint DEFAULT 1 NOT NULL,
  [cb_max_count] int DEFAULT 16 NOT NULL,
  [cb_trigger_interval] nvarchar(16) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [owner_id] bigint DEFAULT NULL NULL,
  [labels] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_retry_scene_config] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'scene_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组状态 0、未启用 1、启用',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'scene_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最大重试次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'max_retry_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'1、默认等级 2、固定间隔时间 3、CRON 表达式',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'back_off'
GO

EXEC sp_addextendedproperty
'MS_Description', N'间隔时长',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'trigger_interval'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知告警场景配置id列表',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'notify_ids'
GO

EXEC sp_addextendedproperty
'MS_Description', N'Deadline Request 调用链超时 单位毫秒',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'deadline_request'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行超时时间，单位秒',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'executor_timeout'
GO

EXEC sp_addextendedproperty
'MS_Description', N'路由策略',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'route_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'阻塞策略 1、丢弃 2、覆盖 3、并行',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'block_strategy'
GO

EXEC sp_addextendedproperty
'MS_Description', N'回调状态 0、不开启 1、开启',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'cb_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'1、默认等级 2、固定间隔时间 3、CRON 表达式',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'cb_trigger_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'回调的最大执行次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'cb_max_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'回调的最大执行次数',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'cb_trigger_interval'
GO

EXEC sp_addextendedproperty
'MS_Description', N'负责人id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'owner_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'标签',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'labels'
GO

EXEC sp_addextendedproperty
'MS_Description', N'描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景配置',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_scene_config'
GO


-- ----------------------------
-- Table structure for sj_retry_summary
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_retry_summary]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_retry_summary]
GO

CREATE TABLE [dbo].[sj_retry_summary] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [scene_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [trigger_at] datetime2(7) DEFAULT getdate() NOT NULL,
  [running_num] int DEFAULT 0 NOT NULL,
  [finish_num] int DEFAULT 0 NOT NULL,
  [max_count_num] int DEFAULT 0 NOT NULL,
  [suspend_num] int DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_retry_summary] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'scene_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统计时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'trigger_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试中-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'running_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试完成-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'finish_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试到达最大次数-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'max_count_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'暂停重试-日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'suspend_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'DashBoard_Retry',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_summary'
GO


-- ----------------------------
-- Table structure for sj_retry_task
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_retry_task]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_retry_task]
GO

CREATE TABLE [dbo].[sj_retry_task] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [scene_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [retry_id] bigint  NOT NULL,
  [ext_attrs] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [task_status] tinyint DEFAULT 1 NOT NULL,
  [task_type] tinyint DEFAULT 1 NOT NULL,
  [operation_reason] tinyint DEFAULT 0 NOT NULL,
  [client_info] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_retry_task] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'场景名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'scene_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试信息Id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'retry_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试状态',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'task_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务类型 1、重试数据 2、回调数据',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'task_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作原因',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'operation_reason'
GO

EXEC sp_addextendedproperty
'MS_Description', N'客户端地址 clientId#ip:port',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'client_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试任务表',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task'
GO


-- ----------------------------
-- Table structure for sj_retry_task_log_message
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_retry_task_log_message]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_retry_task_log_message]
GO

CREATE TABLE [dbo].[sj_retry_task_log_message] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [retry_id] bigint  NOT NULL,
  [retry_task_id] bigint  NOT NULL,
  [message] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [log_num] int DEFAULT 1 NOT NULL,
  [real_time] bigint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_retry_task_log_message] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试信息Id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'retry_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'重试任务Id',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'retry_task_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'异常信息',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'message'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日志数量',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'log_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'上报时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'real_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务调度日志信息记录表',
'SCHEMA', N'dbo',
'TABLE', N'sj_retry_task_log_message'
GO


-- ----------------------------
-- Table structure for sj_server_node
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_server_node]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_server_node]
GO

CREATE TABLE [dbo].[sj_server_node] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [host_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [host_ip] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [host_port] int  NOT NULL,
  [expire_at] datetime2(7)  NOT NULL,
  [node_type] tinyint  NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [labels] nvarchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_server_node] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'主机id',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'host_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'机器ip',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'host_ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'机器端口',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'host_port'
GO

EXEC sp_addextendedproperty
'MS_Description', N'过期时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'expire_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点类型 1、客户端 2、是服务端',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'标签',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'labels'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'服务器节点',
'SCHEMA', N'dbo',
'TABLE', N'sj_server_node'
GO


-- ----------------------------
-- Table structure for sj_system_user
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_system_user]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_system_user]
GO

CREATE TABLE [dbo].[sj_system_user] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [username] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [password] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [role] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_system_user] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'账号',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user',
'COLUMN', N'username'
GO

EXEC sp_addextendedproperty
'MS_Description', N'密码',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user',
'COLUMN', N'password'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色：1-普通用户、2-管理员',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user',
'COLUMN', N'role'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统用户表',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user'
GO


-- ----------------------------
-- Table structure for sj_system_user_permission
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_system_user_permission]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_system_user_permission]
GO

CREATE TABLE [dbo].[sj_system_user_permission] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [system_user_id] bigint  NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_system_user_permission] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统用户id',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission',
'COLUMN', N'system_user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统用户权限表',
'SCHEMA', N'dbo',
'TABLE', N'sj_system_user_permission'
GO


-- ----------------------------
-- Table structure for sj_workflow
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_workflow]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_workflow]
GO

CREATE TABLE [dbo].[sj_workflow] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [workflow_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [workflow_status] tinyint DEFAULT 1 NOT NULL,
  [trigger_type] tinyint  NOT NULL,
  [trigger_interval] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [next_trigger_at] bigint  NOT NULL,
  [block_strategy] tinyint DEFAULT 1 NOT NULL,
  [executor_timeout] int DEFAULT 0 NOT NULL,
  [description] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [flow_info] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [wf_context] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [notify_ids] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [bucket_index] int DEFAULT 0 NOT NULL,
  [version] int  NOT NULL,
  [owner_id] bigint DEFAULT NULL NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [deleted] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_workflow] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'workflow_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流状态 0、关闭、1、开启',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'workflow_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'触发类型 1.CRON 表达式 2. 固定时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'trigger_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'间隔时长',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'trigger_interval'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下次触发时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'next_trigger_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'阻塞策略 1、丢弃 2、覆盖 3、并行',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'block_strategy'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行超时时间，单位秒',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'executor_timeout'
GO

EXEC sp_addextendedproperty
'MS_Description', N'描述',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'description'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程信息',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'flow_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'上下文',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'wf_context'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知告警场景配置id列表',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'notify_ids'
GO

EXEC sp_addextendedproperty
'MS_Description', N'bucket',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'bucket_index'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本号',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'负责人id',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'owner_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除 1、删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow'
GO


-- ----------------------------
-- Table structure for sj_workflow_node
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_workflow_node]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_workflow_node]
GO

CREATE TABLE [dbo].[sj_workflow_node] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [node_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [job_id] bigint  NOT NULL,
  [workflow_id] bigint  NOT NULL,
  [node_type] tinyint DEFAULT 1 NOT NULL,
  [expression_type] tinyint DEFAULT 0 NOT NULL,
  [fail_strategy] tinyint DEFAULT 1 NOT NULL,
  [workflow_node_status] tinyint DEFAULT 1 NOT NULL,
  [priority_level] int DEFAULT 1 NOT NULL,
  [node_info] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [version] int  NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [deleted] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_workflow_node] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'node_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务信息id',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'job_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流ID',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'workflow_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'1、任务节点 2、条件节点',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'node_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'1、SpEl、2、Aviator 3、QL',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'expression_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'失败策略 1、跳过 2、阻塞',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'fail_strategy'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流节点状态 0、关闭、1、开启',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'workflow_node_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'优先级',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'priority_level'
GO

EXEC sp_addextendedproperty
'MS_Description', N'节点信息 ',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'node_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本号',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除 1、删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流节点',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_node'
GO


-- ----------------------------
-- Table structure for sj_workflow_task_batch
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sj_workflow_task_batch]') AND type IN ('U'))
	DROP TABLE [dbo].[sj_workflow_task_batch]
GO

CREATE TABLE [dbo].[sj_workflow_task_batch] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [namespace_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' NOT NULL,
  [group_name] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [workflow_id] bigint  NOT NULL,
  [task_batch_status] tinyint DEFAULT 0 NOT NULL,
  [operation_reason] tinyint DEFAULT 0 NOT NULL,
  [flow_info] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [wf_context] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT NULL NULL,
  [execution_at] bigint DEFAULT 0 NOT NULL,
  [ext_attrs] nvarchar(256) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [version] int DEFAULT 1 NOT NULL,
  [deleted] tinyint DEFAULT 0 NOT NULL,
  [create_dt] datetime2(7) DEFAULT getdate() NOT NULL,
  [update_dt] datetime2(7) DEFAULT getdate() NOT NULL
)
GO

ALTER TABLE [dbo].[sj_workflow_task_batch] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'命名空间id',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'namespace_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组名称',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'group_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流任务id',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'workflow_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务批次状态 0、失败 1、成功',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'task_batch_status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作原因',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'operation_reason'
GO

EXEC sp_addextendedproperty
'MS_Description', N'流程信息',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'flow_info'
GO

EXEC sp_addextendedproperty
'MS_Description', N'全局上下文',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'wf_context'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'execution_at'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'ext_attrs'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本号',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'逻辑删除 1、删除',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'deleted'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'create_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch',
'COLUMN', N'update_dt'
GO

EXEC sp_addextendedproperty
'MS_Description', N'工作流批次',
'SCHEMA', N'dbo',
'TABLE', N'sj_workflow_task_batch'
GO


-- ----------------------------
-- Table structure for sys_client
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_client]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_client]
GO

CREATE TABLE [dbo].[sys_client] (
  [id] bigint  NOT NULL,
  [client_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [client_key] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [client_secret] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [grant_type] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [device_type] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [active_timeout] int DEFAULT 1800 NULL,
  [timeout] int DEFAULT 604800 NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[sys_client] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'客户端id',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'client_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'客户端key',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'client_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'客户端秘钥',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'client_secret'
GO

EXEC sp_addextendedproperty
'MS_Description', N'授权类型',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'grant_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备类型',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'device_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'token活跃超时时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'active_timeout'
GO

EXEC sp_addextendedproperty
'MS_Description', N'token固定超时',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'timeout'
GO

EXEC sp_addextendedproperty
'MS_Description', N'状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_client',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统授权表',
'SCHEMA', N'dbo',
'TABLE', N'sys_client'
GO


-- ----------------------------
-- Table structure for sys_config
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_config]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_config]
GO

CREATE TABLE [dbo].[sys_config] (
  [config_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [config_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [config_key] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [config_value] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [config_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_config] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'config_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'config_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数键名',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'config_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数键值',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'config_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统内置（Y是 N否）',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'config_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_config',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'参数配置表',
'SCHEMA', N'dbo',
'TABLE', N'sys_config'
GO


-- ----------------------------
-- Table structure for sys_dept
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_dept]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_dept]
GO

CREATE TABLE [dbo].[sys_dept] (
  [dept_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [parent_id] bigint DEFAULT 0 NULL,
  [ancestors] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [dept_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [dept_category] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [order_num] int DEFAULT 0 NULL,
  [leader] bigint  NULL,
  [phone] nvarchar(11) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [email] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[sys_dept] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门id',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'dept_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父部门id',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'祖级列表',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'ancestors'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'dept_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门类别编码',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'dept_category'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示顺序',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'order_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'负责人',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'leader'
GO

EXEC sp_addextendedproperty
'MS_Description', N'联系电话',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'phone'
GO

EXEC sp_addextendedproperty
'MS_Description', N'邮箱',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'email'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门表',
'SCHEMA', N'dbo',
'TABLE', N'sys_dept'
GO


-- ----------------------------
-- Table structure for sys_dict_data
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_dict_data]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_dict_data]
GO

CREATE TABLE [dbo].[sys_dict_data] (
  [dict_code] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [dict_sort] int DEFAULT 0 NULL,
  [dict_label] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [dict_value] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [dict_type] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [css_class] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [list_class] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_default] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_dict_data] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典编码',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'dict_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典编码',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典排序',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'dict_sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典标签',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'dict_label'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典键值',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'dict_value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典类型',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'dict_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'样式属性（其他样式扩展）',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'css_class'
GO

EXEC sp_addextendedproperty
'MS_Description', N'表格回显样式',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'list_class'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否默认（Y是 N否）',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'is_default'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典数据表',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_data'
GO


-- ----------------------------
-- Table structure for sys_dict_type
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_dict_type]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_dict_type]
GO

CREATE TABLE [dbo].[sys_dict_type] (
  [dict_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [dict_name] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [dict_type] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_dict_type] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'dict_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'dict_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典类型',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'dict_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'字典类型表',
'SCHEMA', N'dbo',
'TABLE', N'sys_dict_type'
GO


-- ----------------------------
-- Table structure for sys_logininfor
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_logininfor]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_logininfor]
GO

CREATE TABLE [dbo].[sys_logininfor] (
  [info_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [user_name] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [client_key] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [device_type] nvarchar(32) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [ipaddr] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [login_location] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [browser] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [os] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [msg] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [login_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[sys_logininfor] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'访问ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'info_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户账号',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'user_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'客户端',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'client_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'设备类型',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'device_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'登录IP地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'ipaddr'
GO

EXEC sp_addextendedproperty
'MS_Description', N'登录地点',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'login_location'
GO

EXEC sp_addextendedproperty
'MS_Description', N'浏览器类型',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'browser'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作系统',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'os'
GO

EXEC sp_addextendedproperty
'MS_Description', N'登录状态（0成功 1失败）',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'提示消息',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'msg'
GO

EXEC sp_addextendedproperty
'MS_Description', N'访问时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor',
'COLUMN', N'login_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统访问记录',
'SCHEMA', N'dbo',
'TABLE', N'sys_logininfor'
GO


-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_menu]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_menu]
GO

CREATE TABLE [dbo].[sys_menu] (
  [menu_id] bigint  NOT NULL,
  [menu_name] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [parent_id] bigint DEFAULT 0 NULL,
  [order_num] int DEFAULT 0 NULL,
  [path] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [component] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [query_param] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [is_frame] int DEFAULT 1 NULL,
  [is_cache] int DEFAULT 0 NULL,
  [menu_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [visible] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 0 NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 0 NULL,
  [perms] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [icon] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '#' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL
)
GO

ALTER TABLE [dbo].[sys_menu] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'menu_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'menu_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父菜单ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示顺序',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'order_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'路由地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'path'
GO

EXEC sp_addextendedproperty
'MS_Description', N'组件路径',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'component'
GO

EXEC sp_addextendedproperty
'MS_Description', N'路由参数',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'query_param'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否为外链（0是 1否）',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'is_frame'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否缓存（0缓存 1不缓存）',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'is_cache'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单类型（M目录 C菜单 F按钮）',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'menu_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示状态（0显示 1隐藏）',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'visible'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'权限标识',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'perms'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单图标',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'icon'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单权限表',
'SCHEMA', N'dbo',
'TABLE', N'sys_menu'
GO


-- ----------------------------
-- Table structure for sys_notice
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_notice]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_notice]
GO

CREATE TABLE [dbo].[sys_notice] (
  [notice_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [notice_title] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [notice_type] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [notice_content] nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_notice] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'公告ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'notice_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'公告标题',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'notice_title'
GO

EXEC sp_addextendedproperty
'MS_Description', N'公告类型（1通知 2公告）',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'notice_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'公告内容',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'notice_content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'公告状态（0正常 1关闭）',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'通知公告表',
'SCHEMA', N'dbo',
'TABLE', N'sys_notice'
GO


-- ----------------------------
-- Table structure for sys_oper_log
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_oper_log]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_oper_log]
GO

CREATE TABLE [dbo].[sys_oper_log] (
  [oper_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [title] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [business_type] int DEFAULT 0 NULL,
  [method] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [request_method] nvarchar(10) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [operator_type] int DEFAULT 0 NULL,
  [oper_name] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [dept_name] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [oper_url] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [oper_ip] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [oper_location] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [oper_param] nvarchar(4000) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [json_result] nvarchar(4000) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [status] int DEFAULT 0 NULL,
  [error_msg] nvarchar(4000) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [oper_time] datetime2(7)  NULL,
  [cost_time] bigint DEFAULT 0 NULL
)
GO

ALTER TABLE [dbo].[sys_oper_log] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'日志主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'模块标题',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'title'
GO

EXEC sp_addextendedproperty
'MS_Description', N'业务类型（0其它 1新增 2修改 3删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'business_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'方法名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'method'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请求方式',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'request_method'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作类别（0其它 1后台用户 2手机端用户）',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'operator_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作人员',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'dept_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请求URL',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_url'
GO

EXEC sp_addextendedproperty
'MS_Description', N'主机地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作地点',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_location'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请求参数',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_param'
GO

EXEC sp_addextendedproperty
'MS_Description', N'返回参数',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'json_result'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作状态（0正常 1异常）',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'错误消息',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'error_msg'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'oper_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消耗时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log',
'COLUMN', N'cost_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作日志记录',
'SCHEMA', N'dbo',
'TABLE', N'sys_oper_log'
GO


-- ----------------------------
-- Table structure for sys_oss
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_oss]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_oss]
GO

CREATE TABLE [dbo].[sys_oss] (
  [oss_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [file_name] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [original_name] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [file_suffix] nvarchar(10) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [url] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [ext1] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [create_dept] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [create_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [service] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'minio' NOT NULL
)
GO

ALTER TABLE [dbo].[sys_oss] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'对象存储主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'oss_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'文件名',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'file_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'原名',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'original_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'文件后缀名',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'file_suffix'
GO

EXEC sp_addextendedproperty
'MS_Description', N'URL地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'url'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'ext1'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'上传人',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'服务商',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss',
'COLUMN', N'service'
GO

EXEC sp_addextendedproperty
'MS_Description', N'OSS对象存储表',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss'
GO


-- ----------------------------
-- Table structure for sys_oss_config
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_oss_config]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_oss_config]
GO

CREATE TABLE [dbo].[sys_oss_config] (
  [oss_config_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [config_key] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NOT NULL,
  [access_key] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [secret_key] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [bucket_name] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [prefix] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [endpoint] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [domain] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [is_https] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'N' NULL,
  [region] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [access_policy] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '1' NOT NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '1' NULL,
  [ext1] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_oss_config] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'oss_config_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'配置key',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'config_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'accessKey',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'access_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'秘钥',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'secret_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'桶名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'bucket_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'前缀',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'prefix'
GO

EXEC sp_addextendedproperty
'MS_Description', N'访问站点',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'endpoint'
GO

EXEC sp_addextendedproperty
'MS_Description', N'自定义域名',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'domain'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否https（Y=是,N=否）',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'is_https'
GO

EXEC sp_addextendedproperty
'MS_Description', N'域',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'region'
GO

EXEC sp_addextendedproperty
'MS_Description', N'桶权限类型(0=private 1=public 2=custom)',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'access_policy'
GO

EXEC sp_addextendedproperty
'MS_Description', N'是否默认（0=是,1=否）',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'扩展字段',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'ext1'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'对象存储配置表',
'SCHEMA', N'dbo',
'TABLE', N'sys_oss_config'
GO


-- ----------------------------
-- Table structure for sys_post
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_post]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_post]
GO

CREATE TABLE [dbo].[sys_post] (
  [post_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [dept_id] bigint  NOT NULL,
  [post_code] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [post_category] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [post_name] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [post_sort] int  NOT NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_post] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'post_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门id',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'dept_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位编码',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'post_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位类别编码',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'post_category'
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'post_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示顺序',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'post_sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_post',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位信息表',
'SCHEMA', N'dbo',
'TABLE', N'sys_post'
GO


-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_role]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_role]
GO

CREATE TABLE [dbo].[sys_role] (
  [role_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [role_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [role_key] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [role_sort] int  NOT NULL,
  [data_scope] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '1' NULL,
  [menu_check_strictly] tinyint DEFAULT 1 NULL,
  [dept_check_strictly] tinyint DEFAULT 1 NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_role] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'role_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'role_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色权限字符串',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'role_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'显示顺序',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'role_sort'
GO

EXEC sp_addextendedproperty
'MS_Description', N'数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限 5：仅本人数据权限 6：部门及以下或本人数据权限）',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'data_scope'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单树选择项是否关联显示',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'menu_check_strictly'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门树选择项是否关联显示',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'dept_check_strictly'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_role',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色信息表',
'SCHEMA', N'dbo',
'TABLE', N'sys_role'
GO


-- ----------------------------
-- Table structure for sys_role_dept
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_role_dept]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_role_dept]
GO

CREATE TABLE [dbo].[sys_role_dept] (
  [role_id] bigint  NOT NULL,
  [dept_id] bigint  NOT NULL
)
GO

ALTER TABLE [dbo].[sys_role_dept] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_role_dept',
'COLUMN', N'role_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_role_dept',
'COLUMN', N'dept_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色和部门关联表',
'SCHEMA', N'dbo',
'TABLE', N'sys_role_dept'
GO


-- ----------------------------
-- Table structure for sys_role_menu
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_role_menu]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_role_menu]
GO

CREATE TABLE [dbo].[sys_role_menu] (
  [role_id] bigint  NOT NULL,
  [menu_id] bigint  NOT NULL
)
GO

ALTER TABLE [dbo].[sys_role_menu] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_role_menu',
'COLUMN', N'role_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'菜单ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_role_menu',
'COLUMN', N'menu_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色和菜单关联表',
'SCHEMA', N'dbo',
'TABLE', N'sys_role_menu'
GO


-- ----------------------------
-- Table structure for sys_social
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_social]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_social]
GO

CREATE TABLE [dbo].[sys_social] (
  [id] bigint  NOT NULL,
  [user_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [auth_id] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [source] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [open_id] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [user_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [nick_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [email] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [avatar] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [access_token] nvarchar(2000) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [expire_in] bigint  NULL,
  [refresh_token] nvarchar(2000) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [access_code] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [union_id] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [scope] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [token_type] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [id_token] nvarchar(2000) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [mac_algorithm] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [mac_key] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [code] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [oauth_token] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [oauth_token_secret] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL
)
GO

ALTER TABLE [dbo].[sys_social] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'平台+平台唯一id',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'auth_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户来源',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'source'
GO

EXEC sp_addextendedproperty
'MS_Description', N'平台编号唯一id',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'open_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'登录账号',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'user_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户昵称',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'nick_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户邮箱',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'email'
GO

EXEC sp_addextendedproperty
'MS_Description', N'头像地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'avatar'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户的授权令牌',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'access_token'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户的授权令牌的有效期，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'expire_in'
GO

EXEC sp_addextendedproperty
'MS_Description', N'刷新令牌，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'refresh_token'
GO

EXEC sp_addextendedproperty
'MS_Description', N'平台的授权信息，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'access_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户的 unionid',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'union_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'授予的权限，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'scope'
GO

EXEC sp_addextendedproperty
'MS_Description', N'个别平台的授权信息，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'token_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'id token，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'id_token'
GO

EXEC sp_addextendedproperty
'MS_Description', N'小米平台用户的附带属性，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'mac_algorithm'
GO

EXEC sp_addextendedproperty
'MS_Description', N'小米平台用户的附带属性，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'mac_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户的授权code，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'Twitter平台用户的附带属性，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'oauth_token'
GO

EXEC sp_addextendedproperty
'MS_Description', N'Twitter平台用户的附带属性，部分平台可能没有',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'oauth_token_secret'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_social',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'社会化关系表',
'SCHEMA', N'dbo',
'TABLE', N'sys_social'
GO


-- ----------------------------
-- Table structure for sys_tenant
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_tenant]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_tenant]
GO

CREATE TABLE [dbo].[sys_tenant] (
  [id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [contact_user_name] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [contact_phone] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [company_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [license_number] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [address] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [intro] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [domain] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [remark] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [package_id] bigint  NULL,
  [expire_time] datetime2(7)  NULL,
  [account_count] int DEFAULT -1 NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[sys_tenant] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'联系人',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'contact_user_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'联系电话',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'contact_phone'
GO

EXEC sp_addextendedproperty
'MS_Description', N'企业名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'company_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'统一社会信用代码',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'license_number'
GO

EXEC sp_addextendedproperty
'MS_Description', N'地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'address'
GO

EXEC sp_addextendedproperty
'MS_Description', N'企业简介',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'intro'
GO

EXEC sp_addextendedproperty
'MS_Description', N'域名',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'domain'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户套餐编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'package_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'过期时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'expire_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户数量（-1不限制）',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'account_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户表',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant'
GO


-- ----------------------------
-- Table structure for sys_tenant_package
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_tenant_package]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_tenant_package]
GO

CREATE TABLE [dbo].[sys_tenant_package] (
  [package_id] bigint  NOT NULL,
  [package_name] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [menu_ids] nvarchar(3000) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [remark] nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [menu_check_strictly] tinyint DEFAULT 1 NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[sys_tenant_package] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户套餐id',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'package_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'套餐名称',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'package_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'关联菜单id',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'menu_ids'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户套餐表',
'SCHEMA', N'dbo',
'TABLE', N'sys_tenant_package'
GO


-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_user]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_user]
GO

CREATE TABLE [dbo].[sys_user] (
  [user_id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [dept_id] bigint  NULL,
  [user_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [nick_name] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [user_type] nvarchar(10) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT 'sys_user' NULL,
  [email] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [phonenumber] nvarchar(11) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [sex] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [avatar] bigint  NULL,
  [password] nvarchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [status] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [del_flag] nchar(1) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '0' NULL,
  [login_ip] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '' NULL,
  [login_date] datetime2(7)  NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL,
  [remark] nvarchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[sys_user] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'dept_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户账号',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'user_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户昵称',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'nick_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户类型（sys_user系统用户）',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'user_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户邮箱',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'email'
GO

EXEC sp_addextendedproperty
'MS_Description', N'手机号码',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'phonenumber'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户性别（0男 1女 2未知）',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'sex'
GO

EXEC sp_addextendedproperty
'MS_Description', N'头像地址',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'avatar'
GO

EXEC sp_addextendedproperty
'MS_Description', N'密码',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'password'
GO

EXEC sp_addextendedproperty
'MS_Description', N'账号状态（0正常 1停用）',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志（0代表存在 1代表删除）',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后登录IP',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'login_ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后登录时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'login_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'sys_user',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户信息表',
'SCHEMA', N'dbo',
'TABLE', N'sys_user'
GO


-- ----------------------------
-- Table structure for sys_user_post
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_user_post]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_user_post]
GO

CREATE TABLE [dbo].[sys_user_post] (
  [user_id] bigint  NOT NULL,
  [post_id] bigint  NOT NULL
)
GO

ALTER TABLE [dbo].[sys_user_post] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_user_post',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'岗位ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_user_post',
'COLUMN', N'post_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户与岗位关联表',
'SCHEMA', N'dbo',
'TABLE', N'sys_user_post'
GO


-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[sys_user_role]') AND type IN ('U'))
	DROP TABLE [dbo].[sys_user_role]
GO

CREATE TABLE [dbo].[sys_user_role] (
  [user_id] bigint  NOT NULL,
  [role_id] bigint  NOT NULL
)
GO

ALTER TABLE [dbo].[sys_user_role] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_user_role',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'角色ID',
'SCHEMA', N'dbo',
'TABLE', N'sys_user_role',
'COLUMN', N'role_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户和角色关联表',
'SCHEMA', N'dbo',
'TABLE', N'sys_user_role'
GO


-- ----------------------------
-- Table structure for t_sys_collectdevice_log
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_sys_collectdevice_log]') AND type IN ('U'))
	DROP TABLE [dbo].[t_sys_collectdevice_log]
GO

CREATE TABLE [dbo].[t_sys_collectdevice_log] (
  [CollectDeviceID] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [Online] datetime2(7)  NULL,
  [Offline] datetime2(7)  NULL,
  [State] int  NULL
)
GO

ALTER TABLE [dbo].[t_sys_collectdevice_log] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for t_vibrationsensor_data
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_vibrationsensor_data]') AND type IN ('U'))
	DROP TABLE [dbo].[t_vibrationsensor_data]
GO

CREATE TABLE [dbo].[t_vibrationsensor_data] (
  [objId] bigint  NOT NULL,
  [collectTime] datetime2(7)  NULL,
  [sensor_id] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [speed] decimal(18,2)  NULL,
  [displacement] decimal(18,2)  NULL,
  [acceleration] decimal(18,2)  NULL,
  [temperature] decimal(18,2)  NULL,
  [recodeTime] datetime2(7)  NULL,
  [remark] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[t_vibrationsensor_data] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'objId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'collectTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'振动传感器编号',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'sensor_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'速度(mm/s)',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'speed'
GO

EXEC sp_addextendedproperty
'MS_Description', N'位移(um)',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'displacement'
GO

EXEC sp_addextendedproperty
'MS_Description', N'加速度(g)',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'acceleration'
GO

EXEC sp_addextendedproperty
'MS_Description', N'温度(℃)',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'temperature'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'recodeTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'振动传感器数据',
'SCHEMA', N'dbo',
'TABLE', N't_vibrationsensor_data'
GO


-- ----------------------------
-- Table structure for t_w_temperturedata
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_w_temperturedata]') AND type IN ('U'))
	DROP TABLE [dbo].[t_w_temperturedata]
GO

CREATE TABLE [dbo].[t_w_temperturedata] (
  [objid] bigint  NOT NULL,
  [monitorId] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [collectTime] datetime2(7)  NULL,
  [tempreture] decimal(18,2)  NULL,
  [humidity] decimal(18,2)  NULL,
  [illuminance] decimal(18,2)  NULL,
  [noise] decimal(18,2)  NULL,
  [concentration] decimal(18,2)  NULL,
  [recodeTime] datetime2(7)  NULL,
  [alarmType] int  NULL,
  [confirmPersonID] int  NULL,
  [confirmTime] datetime2(7)  NULL,
  [confirmFlag] int  NULL
)
GO

ALTER TABLE [dbo].[t_w_temperturedata] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键标识',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'objid'
GO

EXEC sp_addextendedproperty
'MS_Description', N'计量设备编号',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'monitorId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'采集时间',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'collectTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'温度',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'tempreture'
GO

EXEC sp_addextendedproperty
'MS_Description', N'湿度',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'humidity'
GO

EXEC sp_addextendedproperty
'MS_Description', N'照度',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'illuminance'
GO

EXEC sp_addextendedproperty
'MS_Description', N'噪声',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'noise'
GO

EXEC sp_addextendedproperty
'MS_Description', N'硫化氢浓度',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'concentration'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'recodeTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'报警类型',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata',
'COLUMN', N'alarmType'
GO

EXEC sp_addextendedproperty
'MS_Description', N'动力环境数据',
'SCHEMA', N'dbo',
'TABLE', N't_w_temperturedata'
GO


-- ----------------------------
-- Table structure for test_demo
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[test_demo]') AND type IN ('U'))
	DROP TABLE [dbo].[test_demo]
GO

CREATE TABLE [dbo].[test_demo] (
  [id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [dept_id] bigint  NULL,
  [user_id] bigint  NULL,
  [order_num] int DEFAULT 0 NULL,
  [test_key] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [value] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [version] int DEFAULT 0 NULL,
  [create_dept] bigint  NULL,
  [create_time] datetime2(0)  NULL,
  [create_by] bigint  NULL,
  [update_time] datetime2(0)  NULL,
  [update_by] bigint  NULL,
  [del_flag] int DEFAULT 0 NULL
)
GO

ALTER TABLE [dbo].[test_demo] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门id',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'dept_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户id',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'排序号',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'order_num'
GO

EXEC sp_addextendedproperty
'MS_Description', N'key键',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'test_key'
GO

EXEC sp_addextendedproperty
'MS_Description', N'值',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'value'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'test_demo',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'测试单表',
'SCHEMA', N'dbo',
'TABLE', N'test_demo'
GO


-- ----------------------------
-- Table structure for test_leave
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[test_leave]') AND type IN ('U'))
	DROP TABLE [dbo].[test_leave]
GO

CREATE TABLE [dbo].[test_leave] (
  [id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [apply_code] nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [leave_type] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
  [start_date] datetime2(7)  NOT NULL,
  [end_date] datetime2(7)  NOT NULL,
  [leave_days] int  NOT NULL,
  [remark] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [status] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [create_dept] bigint  NULL,
  [create_by] bigint  NULL,
  [create_time] datetime2(7)  NULL,
  [update_by] bigint  NULL,
  [update_time] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[test_leave] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户编号',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'申请编号',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'apply_code'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请假类型',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'leave_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'开始时间',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'start_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'结束时间',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'end_date'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请假天数',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'leave_days'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请假原因',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'状态',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建者',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新者',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'test_leave',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'请假申请表',
'SCHEMA', N'dbo',
'TABLE', N'test_leave'
GO


-- ----------------------------
-- Table structure for test_tree
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[test_tree]') AND type IN ('U'))
	DROP TABLE [dbo].[test_tree]
GO

CREATE TABLE [dbo].[test_tree] (
  [id] bigint  NOT NULL,
  [tenant_id] nvarchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS DEFAULT '000000' NULL,
  [parent_id] bigint DEFAULT 0 NULL,
  [dept_id] bigint  NULL,
  [user_id] bigint  NULL,
  [tree_name] nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
  [version] int DEFAULT 0 NULL,
  [create_dept] bigint  NULL,
  [create_time] datetime2(0)  NULL,
  [create_by] bigint  NULL,
  [update_time] datetime2(0)  NULL,
  [update_by] bigint  NULL,
  [del_flag] int DEFAULT 0 NULL
)
GO

ALTER TABLE [dbo].[test_tree] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户id',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'父id',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'parent_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'部门id',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'dept_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'用户id',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'user_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'值',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'tree_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'版本',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'version'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建部门',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'create_dept'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'create_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'create_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新时间',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'update_time'
GO

EXEC sp_addextendedproperty
'MS_Description', N'更新人',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'update_by'
GO

EXEC sp_addextendedproperty
'MS_Description', N'删除标志',
'SCHEMA', N'dbo',
'TABLE', N'test_tree',
'COLUMN', N'del_flag'
GO

EXEC sp_addextendedproperty
'MS_Description', N'测试树表',
'SCHEMA', N'dbo',
'TABLE', N'test_tree'
GO


-- ----------------------------
-- Primary Key structure for table base_custom_data
-- ----------------------------
ALTER TABLE [dbo].[base_custom_data] ADD CONSTRAINT [PK__base_cus__9FA083C3FE7DCE2D] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table base_device_ledger
-- ----------------------------
ALTER TABLE [dbo].[base_device_ledger] ADD CONSTRAINT [PK__base_dev__9FA083C3AD7AB2AB] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table base_device_param
-- ----------------------------
ALTER TABLE [dbo].[base_device_param] ADD CONSTRAINT [PK__base_dev__9FA083C3F4F0FEE3] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table base_factory
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [base_factory_obj_id_uindex]
ON [dbo].[base_factory] (
  [obj_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table base_factory
-- ----------------------------
ALTER TABLE [dbo].[base_factory] ADD CONSTRAINT [PK__base_fac__9FA083C3310E85ED] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table base_material_info
-- ----------------------------
ALTER TABLE [dbo].[base_material_info] ADD CONSTRAINT [PK__base_mat__9FA083C335899EF2] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table base_process_info
-- ----------------------------
ALTER TABLE [dbo].[base_process_info] ADD CONSTRAINT [PK__base_pro__9FA083C3AA28FC6E] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table base_product_line
-- ----------------------------
ALTER TABLE [dbo].[base_product_line] ADD CONSTRAINT [PK__base_pro__9FA083C36BC6F8C2] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table base_staff_info
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [base_staff_info_staff_id_card_id_uindex]
ON [dbo].[base_staff_info] (
  [staff_id] ASC,
  [card_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table base_staff_info
-- ----------------------------
ALTER TABLE [dbo].[base_staff_info] ADD CONSTRAINT [PK__base_sta__9FA083C3B9361809] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table base_team_members
-- ----------------------------
ALTER TABLE [dbo].[base_team_members] ADD CONSTRAINT [PK__base_tea__9FA083C31D505877] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table daily_fault_record
-- ----------------------------
ALTER TABLE [dbo].[daily_fault_record] ADD CONSTRAINT [PK__daily_fa__3213E83F5FD2E7A4] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table ems_alarm_action_step
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_rule_obj_id]
ON [dbo].[ems_alarm_action_step] (
  [rule_obj_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table ems_alarm_action_step
-- ----------------------------
ALTER TABLE [dbo].[ems_alarm_action_step] ADD CONSTRAINT [PK__ems_alar__9FA083C38D6DF365] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table ems_alarm_action_step_image
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_action_step_obj_id]
ON [dbo].[ems_alarm_action_step_image] (
  [action_step_obj_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table ems_alarm_action_step_image
-- ----------------------------
ALTER TABLE [dbo].[ems_alarm_action_step_image] ADD CONSTRAINT [PK__ems_alar__9FA083C3B9842672] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_collect_device_info
-- ----------------------------
ALTER TABLE [dbo].[ems_base_collect_device_info] ADD CONSTRAINT [PK__ems_base__9FA083C356F5A06D] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_energy_price
-- ----------------------------
ALTER TABLE [dbo].[ems_base_energy_price] ADD CONSTRAINT [PK__ems_base__9FA083C3714CB72B] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_energy_type
-- ----------------------------
ALTER TABLE [dbo].[ems_base_energy_type] ADD CONSTRAINT [PK__ems_base__9FA083C3DE51BEE2] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table ems_base_monitor_info
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [idx_monitor_id_unique]
ON [dbo].[ems_base_monitor_info] (
  [monitor_code] ASC,
  [monitor_type] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_parent_id]
ON [dbo].[ems_base_monitor_info] (
  [parent_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table ems_base_monitor_info
-- ----------------------------
ALTER TABLE [dbo].[ems_base_monitor_info] ADD CONSTRAINT [PK__ems_base__9FA083C34F9F5413] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_monitor_threshold
-- ----------------------------
ALTER TABLE [dbo].[ems_base_monitor_threshold] ADD CONSTRAINT [PK__ems_base__9FA083C3B9A884E2] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_monitor_work_unit
-- ----------------------------
ALTER TABLE [dbo].[ems_base_monitor_work_unit] ADD CONSTRAINT [PK__ems_base__9FA083C39D6A87E8] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_share_price
-- ----------------------------
ALTER TABLE [dbo].[ems_base_share_price] ADD CONSTRAINT [PK__ems_base__9FA083C3F0F67B7C] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_base_work_unit
-- ----------------------------
ALTER TABLE [dbo].[ems_base_work_unit] ADD CONSTRAINT [PK__ems_base__9FA083C3D4CC8531] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_record_alarm_data
-- ----------------------------
ALTER TABLE [dbo].[ems_record_alarm_data] ADD CONSTRAINT [PK__ems_reco__9FA083C396DF82F9] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_record_alarm_rule
-- ----------------------------
ALTER TABLE [dbo].[ems_record_alarm_rule] ADD CONSTRAINT [PK__ems_reco__9FA083C3A1D53611] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table ems_record_dnb_instant
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_collect_time]
ON [dbo].[ems_record_dnb_instant] (
  [collect_time] ASC
)
GO

CREATE NONCLUSTERED INDEX [ems_record_dnb_instant_monitor_id_index]
ON [dbo].[ems_record_dnb_instant] (
  [monitor_code] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table ems_record_dnb_instant
-- ----------------------------
ALTER TABLE [dbo].[ems_record_dnb_instant] ADD CONSTRAINT [PK__ems_reco__9FA083C390257C69] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_record_steam_instant
-- ----------------------------
ALTER TABLE [dbo].[ems_record_steam_instant] ADD CONSTRAINT [PK__ems_reco__9FA083C3999C9423] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table ems_record_water_instant
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_collect_time]
ON [dbo].[ems_record_water_instant] (
  [collect_time] ASC
)
GO

CREATE NONCLUSTERED INDEX [ems_record_water_instant_monitor_id_index]
ON [dbo].[ems_record_water_instant] (
  [monitor_code] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table ems_record_water_instant
-- ----------------------------
ALTER TABLE [dbo].[ems_record_water_instant] ADD CONSTRAINT [PK__ems_reco__9FA083C37DEDDB2D] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_report_point_dnb
-- ----------------------------
ALTER TABLE [dbo].[ems_report_point_dnb] ADD CONSTRAINT [PK__ems_repo__9FA083C32E5150CA] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_report_point_steam
-- ----------------------------
ALTER TABLE [dbo].[ems_report_point_steam] ADD CONSTRAINT [PK__ems_repo__9FA083C3F5708FEA] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table ems_report_point_water
-- ----------------------------
ALTER TABLE [dbo].[ems_report_point_water] ADD CONSTRAINT [PK__ems_repo__9FA083C31D852166] PRIMARY KEY CLUSTERED ([obj_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_category
-- ----------------------------
ALTER TABLE [dbo].[flow_category] ADD CONSTRAINT [PK__flow_cat__D54EE9B4AE98B9C1] PRIMARY KEY CLUSTERED ([category_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_definition
-- ----------------------------
ALTER TABLE [dbo].[flow_definition] ADD CONSTRAINT [PK__flow_def__3213E83FEE39AE33] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_his_task
-- ----------------------------
ALTER TABLE [dbo].[flow_his_task] ADD CONSTRAINT [PK__flow_his__3213E83F67951564] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_instance
-- ----------------------------
ALTER TABLE [dbo].[flow_instance] ADD CONSTRAINT [PK__flow_ins__3213E83F5190FEE1] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_instance_biz_ext
-- ----------------------------
ALTER TABLE [dbo].[flow_instance_biz_ext] ADD CONSTRAINT [PK__fi_biz_ext__D54EE9B4AE98B9C1] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_node
-- ----------------------------
ALTER TABLE [dbo].[flow_node] ADD CONSTRAINT [PK__flow_nod__3213E83F372470DE] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_skip
-- ----------------------------
ALTER TABLE [dbo].[flow_skip] ADD CONSTRAINT [PK__flow_ski__3213E83F073FEE6E] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_spel
-- ----------------------------
ALTER TABLE [dbo].[flow_spel] ADD CONSTRAINT [PK__flow_spel__D54EE9B4AE98B9C1] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table flow_task
-- ----------------------------
ALTER TABLE [dbo].[flow_task] ADD CONSTRAINT [PK__flow_tas__3213E83F5AE1F1BA] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table flow_user
-- ----------------------------
CREATE NONCLUSTERED INDEX [user_processed_type]
ON [dbo].[flow_user] (
  [processed_by] ASC,
  [type] ASC
)
GO

CREATE NONCLUSTERED INDEX [user_associated_idx]
ON [dbo].[flow_user] (
  [associated] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table flow_user
-- ----------------------------
ALTER TABLE [dbo].[flow_user] ADD CONSTRAINT [PK__flow_use__3213E83FFA38CA8B] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table gen_table
-- ----------------------------
ALTER TABLE [dbo].[gen_table] ADD CONSTRAINT [PK__gen_tabl__B21E8F2427725F8A] PRIMARY KEY CLUSTERED ([table_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table gen_table_column
-- ----------------------------
ALTER TABLE [dbo].[gen_table_column] ADD CONSTRAINT [PK__gen_tabl__E301851F2E68B4E8] PRIMARY KEY CLUSTERED ([column_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table record_dnb_instant
-- ----------------------------
ALTER TABLE [dbo].[record_dnb_instant] ADD CONSTRAINT [PK__record_d__530D6FE4D3BD416D] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table record_dnb_instant_20250702
-- ----------------------------
ALTER TABLE [dbo].[record_dnb_instant_20250702] ADD CONSTRAINT [PK__record_d__530D6FE4268646E8] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table record_fluid_instant
-- ----------------------------
ALTER TABLE [dbo].[record_fluid_instant] ADD CONSTRAINT [PK__record_f__530D6FE4DF3A9CD1] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table record_fluid_instant_20250702
-- ----------------------------
ALTER TABLE [dbo].[record_fluid_instant_20250702] ADD CONSTRAINT [PK__record_f__530D6FE4A2E286F8] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table record_iotenv_instant
-- ----------------------------
ALTER TABLE [dbo].[record_iotenv_instant] ADD CONSTRAINT [PK__record_i__530D6FE4B3ECB058] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table record_iotenv_instant_20260326
-- ----------------------------
ALTER TABLE [dbo].[record_iotenv_instant_20260326] ADD CONSTRAINT [PK__record_i__530D6FE4C6EFF375] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sj_distributed_lock
-- ----------------------------
ALTER TABLE [dbo].[sj_distributed_lock] ADD CONSTRAINT [PK__sj_distr__72E12F1A31E41FD2] PRIMARY KEY CLUSTERED ([name])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_group_config
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_group_config]', RESEED, 2)
GO


-- ----------------------------
-- Indexes structure for table sj_group_config
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_group_config_01]
ON [dbo].[sj_group_config] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_group_config
-- ----------------------------
ALTER TABLE [dbo].[sj_group_config] ADD CONSTRAINT [PK__sj_group__3213E83F9E5F8F46] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_job
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_job]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_job
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_job_01]
ON [dbo].[sj_job] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_02]
ON [dbo].[sj_job] (
  [job_status] ASC,
  [bucket_index] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_03]
ON [dbo].[sj_job] (
  [create_dt] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_job
-- ----------------------------
ALTER TABLE [dbo].[sj_job] ADD CONSTRAINT [PK__sj_job__3213E83F85203662] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_job_executor
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_job_executor]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_job_executor
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_job_executor_01]
ON [dbo].[sj_job_executor] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_executor_02]
ON [dbo].[sj_job_executor] (
  [create_dt] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_job_executor
-- ----------------------------
ALTER TABLE [dbo].[sj_job_executor] ADD CONSTRAINT [PK__sj_job_e__3213E83F7EEB822C] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_job_log_message
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_job_log_message]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_job_log_message
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_job_log_message_01]
ON [dbo].[sj_job_log_message] (
  [task_batch_id] ASC,
  [task_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_log_message_02]
ON [dbo].[sj_job_log_message] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_log_message_03]
ON [dbo].[sj_job_log_message] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_job_log_message
-- ----------------------------
ALTER TABLE [dbo].[sj_job_log_message] ADD CONSTRAINT [PK__sj_job_l__3213E83FB6806C04] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_job_summary
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_job_summary]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_job_summary
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_job_summary_01]
ON [dbo].[sj_job_summary] (
  [trigger_at] ASC,
  [system_task_type] ASC,
  [business_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_summary_01]
ON [dbo].[sj_job_summary] (
  [namespace_id] ASC,
  [group_name] ASC,
  [business_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_job_summary
-- ----------------------------
ALTER TABLE [dbo].[sj_job_summary] ADD CONSTRAINT [PK__sj_job_s__3213E83F7F79D8C8] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_job_task
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_job_task]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_job_task
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_job_task_01]
ON [dbo].[sj_job_task] (
  [task_batch_id] ASC,
  [task_status] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_task_02]
ON [dbo].[sj_job_task] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_task_03]
ON [dbo].[sj_job_task] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_job_task
-- ----------------------------
ALTER TABLE [dbo].[sj_job_task] ADD CONSTRAINT [PK__sj_job_t__3213E83F9E4412D4] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_job_task_batch
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_job_task_batch]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_job_task_batch
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_job_task_batch_01]
ON [dbo].[sj_job_task_batch] (
  [job_id] ASC,
  [task_batch_status] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_task_batch_02]
ON [dbo].[sj_job_task_batch] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_task_batch_03]
ON [dbo].[sj_job_task_batch] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_job_task_batch_04]
ON [dbo].[sj_job_task_batch] (
  [workflow_task_batch_id] ASC,
  [workflow_node_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_job_task_batch
-- ----------------------------
ALTER TABLE [dbo].[sj_job_task_batch] ADD CONSTRAINT [PK__sj_job_t__3213E83F6555F498] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_namespace
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_namespace]', RESEED, 2)
GO


-- ----------------------------
-- Indexes structure for table sj_namespace
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_namespace_01]
ON [dbo].[sj_namespace] (
  [name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_namespace
-- ----------------------------
ALTER TABLE [dbo].[sj_namespace] ADD CONSTRAINT [PK__sj_names__3213E83F1E681344] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_notify_config
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_notify_config]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_notify_config
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_notify_config_01]
ON [dbo].[sj_notify_config] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_notify_config
-- ----------------------------
ALTER TABLE [dbo].[sj_notify_config] ADD CONSTRAINT [PK__sj_notif__3213E83FB2E77FC9] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_notify_recipient
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_notify_recipient]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_notify_recipient
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_notify_recipient_01]
ON [dbo].[sj_notify_recipient] (
  [namespace_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_notify_recipient
-- ----------------------------
ALTER TABLE [dbo].[sj_notify_recipient] ADD CONSTRAINT [PK__sj_notif__3213E83F2928A282] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_retry
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_retry]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_retry
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_retry_01]
ON [dbo].[sj_retry] (
  [scene_id] ASC,
  [task_type] ASC,
  [idempotent_id] ASC,
  [deleted] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_01]
ON [dbo].[sj_retry] (
  [biz_no] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_02]
ON [dbo].[sj_retry] (
  [idempotent_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_03]
ON [dbo].[sj_retry] (
  [retry_status] ASC,
  [bucket_index] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_04]
ON [dbo].[sj_retry] (
  [parent_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_05]
ON [dbo].[sj_retry] (
  [create_dt] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_retry
-- ----------------------------
ALTER TABLE [dbo].[sj_retry] ADD CONSTRAINT [PK__sj_retry__3213E83F19A03737] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_retry_dead_letter
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_retry_dead_letter]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_retry_dead_letter
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_retry_dead_letter_01]
ON [dbo].[sj_retry_dead_letter] (
  [namespace_id] ASC,
  [group_name] ASC,
  [scene_name] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_dead_letter_02]
ON [dbo].[sj_retry_dead_letter] (
  [idempotent_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_dead_letter_03]
ON [dbo].[sj_retry_dead_letter] (
  [biz_no] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_dead_letter_04]
ON [dbo].[sj_retry_dead_letter] (
  [create_dt] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_retry_dead_letter
-- ----------------------------
ALTER TABLE [dbo].[sj_retry_dead_letter] ADD CONSTRAINT [PK__sj_retry__3213E83F09E091CD] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_retry_scene_config
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_retry_scene_config]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_retry_scene_config
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_retry_scene_config_01]
ON [dbo].[sj_retry_scene_config] (
  [namespace_id] ASC,
  [group_name] ASC,
  [scene_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_retry_scene_config
-- ----------------------------
ALTER TABLE [dbo].[sj_retry_scene_config] ADD CONSTRAINT [PK__sj_retry__3213E83F86ABC48D] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_retry_summary
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_retry_summary]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_retry_summary
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_retry_summary_01]
ON [dbo].[sj_retry_summary] (
  [namespace_id] ASC,
  [group_name] ASC,
  [scene_name] ASC,
  [trigger_at] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_summary_01]
ON [dbo].[sj_retry_summary] (
  [trigger_at] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_retry_summary
-- ----------------------------
ALTER TABLE [dbo].[sj_retry_summary] ADD CONSTRAINT [PK__sj_retry__3213E83FE6F71A3B] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_retry_task
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_retry_task]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_retry_task
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_retry_task_01]
ON [dbo].[sj_retry_task] (
  [namespace_id] ASC,
  [group_name] ASC,
  [scene_name] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_task_02]
ON [dbo].[sj_retry_task] (
  [task_status] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_task_03]
ON [dbo].[sj_retry_task] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_task_04]
ON [dbo].[sj_retry_task] (
  [retry_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_retry_task
-- ----------------------------
ALTER TABLE [dbo].[sj_retry_task] ADD CONSTRAINT [PK__sj_retry__3213E83F4A9EC9E3] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_retry_task_log_message
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_retry_task_log_message]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_retry_task_log_message
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_retry_task_log_message_01]
ON [dbo].[sj_retry_task_log_message] (
  [namespace_id] ASC,
  [group_name] ASC,
  [retry_task_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_retry_task_log_message_02]
ON [dbo].[sj_retry_task_log_message] (
  [create_dt] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_retry_task_log_message
-- ----------------------------
ALTER TABLE [dbo].[sj_retry_task_log_message] ADD CONSTRAINT [PK__sj_retry__3213E83F43AEAF93] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_server_node
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_server_node]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_server_node
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_server_node_01]
ON [dbo].[sj_server_node] (
  [host_id] ASC,
  [host_ip] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_server_node_01]
ON [dbo].[sj_server_node] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_server_node_02]
ON [dbo].[sj_server_node] (
  [expire_at] ASC,
  [node_type] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_server_node
-- ----------------------------
ALTER TABLE [dbo].[sj_server_node] ADD CONSTRAINT [PK__sj_serve__3213E83F9433E2B8] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_system_user
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_system_user]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table sj_system_user
-- ----------------------------
ALTER TABLE [dbo].[sj_system_user] ADD CONSTRAINT [PK__sj_syste__3213E83FE86D0646] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_system_user_permission
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_system_user_permission]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_system_user_permission
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_sj_system_user_permission_01]
ON [dbo].[sj_system_user_permission] (
  [namespace_id] ASC,
  [group_name] ASC,
  [system_user_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_system_user_permission
-- ----------------------------
ALTER TABLE [dbo].[sj_system_user_permission] ADD CONSTRAINT [PK__sj_syste__3213E83F439040AF] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_workflow
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_workflow]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_workflow
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_workflow_01]
ON [dbo].[sj_workflow] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_workflow_02]
ON [dbo].[sj_workflow] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_workflow
-- ----------------------------
ALTER TABLE [dbo].[sj_workflow] ADD CONSTRAINT [PK__sj_workf__3213E83FFBD61D24] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_workflow_node
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_workflow_node]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_workflow_node
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_workflow_node_01]
ON [dbo].[sj_workflow_node] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_workflow_node_02]
ON [dbo].[sj_workflow_node] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_workflow_node
-- ----------------------------
ALTER TABLE [dbo].[sj_workflow_node] ADD CONSTRAINT [PK__sj_workf__3213E83F7207E695] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for sj_workflow_task_batch
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[sj_workflow_task_batch]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table sj_workflow_task_batch
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sj_workflow_task_batch_01]
ON [dbo].[sj_workflow_task_batch] (
  [workflow_id] ASC,
  [task_batch_status] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_workflow_task_batch_02]
ON [dbo].[sj_workflow_task_batch] (
  [create_dt] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sj_workflow_task_batch_03]
ON [dbo].[sj_workflow_task_batch] (
  [namespace_id] ASC,
  [group_name] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sj_workflow_task_batch
-- ----------------------------
ALTER TABLE [dbo].[sj_workflow_task_batch] ADD CONSTRAINT [PK__sj_workf__3213E83F515F5B79] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_client
-- ----------------------------
ALTER TABLE [dbo].[sys_client] ADD CONSTRAINT [PK__sys_client___BFBDE87009ED2882] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_config
-- ----------------------------
ALTER TABLE [dbo].[sys_config] ADD CONSTRAINT [PK__sys_conf__4AD1BFF182643682] PRIMARY KEY CLUSTERED ([config_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_dept
-- ----------------------------
ALTER TABLE [dbo].[sys_dept] ADD CONSTRAINT [PK__sys_dept__DCA659747DE13804] PRIMARY KEY CLUSTERED ([dept_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_dict_data
-- ----------------------------
ALTER TABLE [dbo].[sys_dict_data] ADD CONSTRAINT [PK__sys_dict__19CBC34B661AF3B3] PRIMARY KEY CLUSTERED ([dict_code])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table sys_dict_type
-- ----------------------------
CREATE NONCLUSTERED INDEX [sys_dict_type_index1]
ON [dbo].[sys_dict_type] (
  [tenant_id] ASC,
  [dict_type] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sys_dict_type
-- ----------------------------
ALTER TABLE [dbo].[sys_dict_type] ADD CONSTRAINT [PK__sys_dict__3BD4186C409C5391] PRIMARY KEY CLUSTERED ([dict_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table sys_logininfor
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sys_logininfor_s]
ON [dbo].[sys_logininfor] (
  [status] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sys_logininfor_lt]
ON [dbo].[sys_logininfor] (
  [login_time] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sys_logininfor
-- ----------------------------
ALTER TABLE [dbo].[sys_logininfor] ADD CONSTRAINT [PK__sys_logi__3D8A9C1A1854AE10] PRIMARY KEY CLUSTERED ([info_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_menu
-- ----------------------------
ALTER TABLE [dbo].[sys_menu] ADD CONSTRAINT [PK__sys_menu__4CA0FADCF8545C58] PRIMARY KEY CLUSTERED ([menu_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_notice
-- ----------------------------
ALTER TABLE [dbo].[sys_notice] ADD CONSTRAINT [PK__sys_noti__3E82A5DB0EC94801] PRIMARY KEY CLUSTERED ([notice_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table sys_oper_log
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_sys_oper_log_bt]
ON [dbo].[sys_oper_log] (
  [business_type] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sys_oper_log_s]
ON [dbo].[sys_oper_log] (
  [status] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_sys_oper_log_ot]
ON [dbo].[sys_oper_log] (
  [oper_time] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table sys_oper_log
-- ----------------------------
ALTER TABLE [dbo].[sys_oper_log] ADD CONSTRAINT [PK__sys_oper__34723BF9BD954573] PRIMARY KEY CLUSTERED ([oper_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_oss
-- ----------------------------
ALTER TABLE [dbo].[sys_oss] ADD CONSTRAINT [PK__sys_oss__91241EA442389F0D] PRIMARY KEY CLUSTERED ([oss_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_oss_config
-- ----------------------------
ALTER TABLE [dbo].[sys_oss_config] ADD CONSTRAINT [PK__sys_oss___BFBDE87009ED2882] PRIMARY KEY CLUSTERED ([oss_config_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_post
-- ----------------------------
ALTER TABLE [dbo].[sys_post] ADD CONSTRAINT [PK__sys_post__3ED7876668E2D081] PRIMARY KEY CLUSTERED ([post_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_role
-- ----------------------------
ALTER TABLE [dbo].[sys_role] ADD CONSTRAINT [PK__sys_role__760965CCF9383145] PRIMARY KEY CLUSTERED ([role_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_role_dept
-- ----------------------------
ALTER TABLE [dbo].[sys_role_dept] ADD CONSTRAINT [PK__sys_role__2BC3005BABBCA08A] PRIMARY KEY CLUSTERED ([role_id], [dept_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_role_menu
-- ----------------------------
ALTER TABLE [dbo].[sys_role_menu] ADD CONSTRAINT [PK__sys_role__A2C36A6187BA4B17] PRIMARY KEY CLUSTERED ([role_id], [menu_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_social
-- ----------------------------
ALTER TABLE [dbo].[sys_social] ADD CONSTRAINT [PK__sys_social__B21E8F2427725F8A] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_tenant
-- ----------------------------
ALTER TABLE [dbo].[sys_tenant] ADD CONSTRAINT [PK__sys_tenant__B21E8F2427725F8A] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_tenant_package
-- ----------------------------
ALTER TABLE [dbo].[sys_tenant_package] ADD CONSTRAINT [PK__sys_tenant_package__B21E8F2427725F8A] PRIMARY KEY CLUSTERED ([package_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_user
-- ----------------------------
ALTER TABLE [dbo].[sys_user] ADD CONSTRAINT [PK__sys_user__B9BE370F79170B6A] PRIMARY KEY CLUSTERED ([user_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_user_post
-- ----------------------------
ALTER TABLE [dbo].[sys_user_post] ADD CONSTRAINT [PK__sys_user__CA534F799C04589B] PRIMARY KEY CLUSTERED ([user_id], [post_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table sys_user_role
-- ----------------------------
ALTER TABLE [dbo].[sys_user_role] ADD CONSTRAINT [PK__sys_user__6EDEA153FB34D8F0] PRIMARY KEY CLUSTERED ([user_id], [role_id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table t_vibrationsensor_data
-- ----------------------------
ALTER TABLE [dbo].[t_vibrationsensor_data] ADD CONSTRAINT [PK__t_vibrat__530A638CF7414CB4] PRIMARY KEY CLUSTERED ([objId])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table t_w_temperturedata
-- ----------------------------
ALTER TABLE [dbo].[t_w_temperturedata] ADD CONSTRAINT [PK__t_w_temp__530D6FE4AEDDB7C7] PRIMARY KEY CLUSTERED ([objid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table test_demo
-- ----------------------------
ALTER TABLE [dbo].[test_demo] ADD CONSTRAINT [PK__test_dem__3213E83F176051C8] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table test_leave
-- ----------------------------
ALTER TABLE [dbo].[test_leave] ADD CONSTRAINT [PK__test_lea__3213E83F348788FA] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Primary Key structure for table test_tree
-- ----------------------------
ALTER TABLE [dbo].[test_tree] ADD CONSTRAINT [PK__test_tre__3213E83FC75A1B63] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO

