diff --git a/libs/models/aggregation-watermark.js b/libs/models/aggregation-watermark.js index eee9a0d..63f7416 100644 --- a/libs/models/aggregation-watermark.js +++ b/libs/models/aggregation-watermark.js @@ -14,7 +14,13 @@ module.exports = ({ DataTypes, options }) => { }, options: { comment: '聚合水位线', - indexes: [{ name: 'idx_aggregation_watermark_period', unique: true, fields: ['period'] }] + indexes: [ + { + name: `idx${options.modelPrefix || ''}_aggregation_watermark_period`, + unique: true, + fields: ['period'] + } + ] } }; }; diff --git a/libs/models/channel-meta.js b/libs/models/channel-meta.js index a9f075d..5f86815 100644 --- a/libs/models/channel-meta.js +++ b/libs/models/channel-meta.js @@ -18,7 +18,7 @@ module.exports = ({ DataTypes, options }) => { }, options: { comment: '通道元数据', - indexes: [{ name: 'idx_channel_meta_channel', unique: true, fields: ['channel'] }] + indexes: [{ name: `idx${options.modelPrefix || ''}_channel_meta_channel`, unique: true, fields: ['channel'] }] } }; }; diff --git a/libs/models/data-record.js b/libs/models/data-record.js index 122c741..3f4fe2f 100644 --- a/libs/models/data-record.js +++ b/libs/models/data-record.js @@ -35,11 +35,23 @@ module.exports = ({ DataTypes, options }) => { options: { comment: '数据采集记录', indexes: [ - { name: 'idx_data_record_channel', fields: ['channel'] }, - { name: 'idx_data_record_time', fields: ['time'] }, - { name: 'idx_data_record_channel_time', fields: ['channel', 'time'] }, - { name: 'idx_data_record_channel_attr_time', fields: ['channel', 'attribute_name', 'time'] }, - { name: 'idx_data_record_attr_name', fields: ['attribute_name'] } + { + name: `idx${options.modelPrefix || ''}_data_record_channel`, + fields: ['channel'] + }, + { + name: `idx${options.modelPrefix || ''}_data_record_time`, + fields: ['time'] + }, + { + name: `idx${options.modelPrefix || ''}_data_record_channel_time`, + fields: ['channel', 'time'] + }, + { + name: `idx${options.modelPrefix || ''}_data_record_channel_attr_time`, + fields: ['channel', 'attribute_name', 'time'] + }, + { name: `idx${options.modelPrefix || ''}_idx_data_record_attr_name`, fields: ['attribute_name'] } ] } }; diff --git a/libs/models/period-stat.js b/libs/models/period-stat.js index 3f347c0..2000cd1 100644 --- a/libs/models/period-stat.js +++ b/libs/models/period-stat.js @@ -45,10 +45,10 @@ module.exports = ({ DataTypes, options }) => { options: { comment: '周期统计', indexes: [ - { name: 'idx_period_stat_unique', unique: true, fields: ['period', 'channel', 'attribute_name', 'aggregate', 'time'] }, - { name: 'idx_period_stat_channel_attr_time', fields: ['channel', 'attribute_name', 'time'] }, - { name: 'idx_period_stat_period_time', fields: ['period', 'time'] }, - { name: 'idx_period_stat_attr_name', fields: ['attribute_name'] } + { name: `idx${options.modelPrefix || ''}_period_stat_unique`, unique: true, fields: ['period', 'channel', 'attribute_name', 'aggregate', 'time'] }, + { name: `idx${options.modelPrefix || ''}_period_stat_channel_attr_time`, fields: ['channel', 'attribute_name', 'time'] }, + { name: `idx${options.modelPrefix || ''}_period_stat_period_time`, fields: ['period', 'time'] }, + { name: `idx${options.modelPrefix || ''}_period_stat_attr_name`, fields: ['attribute_name'] } ] } }; diff --git a/package.json b/package.json index dc9eb4e..b5c8fff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kne/fastify-statistics", - "version": "0.1.0-alpha.11", + "version": "0.1.0", "description": "基于 Fastify 的数据采集与多周期聚合统计插件,支持缓冲写入、时区查询和自动 Cron 聚合", "main": "index.js", "scripts": {