|
|
@ -332,13 +332,6 @@ func (sr *scrutinyRepository) Migrate(ctx context.Context) error {
|
|
|
|
SettingDataType: "string",
|
|
|
|
SettingDataType: "string",
|
|
|
|
SettingValueString: "smooth",
|
|
|
|
SettingValueString: "smooth",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
SettingKeyName: "powered_on_hours_unit",
|
|
|
|
|
|
|
|
SettingKeyDescription: "Presentation format for device powered on time ('humanize' | 'device_hours')",
|
|
|
|
|
|
|
|
SettingDataType: "string",
|
|
|
|
|
|
|
|
SettingValueString: "humanize",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SettingKeyName: "metrics.notify_level",
|
|
|
|
SettingKeyName: "metrics.notify_level",
|
|
|
|
SettingKeyDescription: "Determines which device status will cause a notification (fail or warn)",
|
|
|
|
SettingKeyDescription: "Determines which device status will cause a notification (fail or warn)",
|
|
|
@ -391,6 +384,21 @@ func (sr *scrutinyRepository) Migrate(ctx context.Context) error {
|
|
|
|
return tx.Create(&defaultSettings).Error
|
|
|
|
return tx.Create(&defaultSettings).Error
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ID: "m20240722082740", // add powered_on_hours_unit setting.
|
|
|
|
|
|
|
|
Migrate: func(tx *gorm.DB) error {
|
|
|
|
|
|
|
|
//add powered_on_hours_unit setting default.
|
|
|
|
|
|
|
|
var defaultSettings = []m20220716214900.Setting{
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SettingKeyName: "powered_on_hours_unit",
|
|
|
|
|
|
|
|
SettingKeyDescription: "Presentation format for device powered on time ('humanize' | 'device_hours')",
|
|
|
|
|
|
|
|
SettingDataType: "string",
|
|
|
|
|
|
|
|
SettingValueString: "humanize",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tx.Create(&defaultSettings).Error
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if err := m.Migrate(); err != nil {
|
|
|
|
if err := m.Migrate(); err != nil {
|
|
|
@ -427,8 +435,8 @@ func (sr *scrutinyRepository) Migrate(ctx context.Context) error {
|
|
|
|
|
|
|
|
|
|
|
|
// helpers
|
|
|
|
// helpers
|
|
|
|
|
|
|
|
|
|
|
|
//When adding data to influxdb, an error may be returned if the data point is outside the range of the retention policy.
|
|
|
|
// When adding data to influxdb, an error may be returned if the data point is outside the range of the retention policy.
|
|
|
|
//This function will ignore retention policy errors, and allow the migration to continue.
|
|
|
|
// This function will ignore retention policy errors, and allow the migration to continue.
|
|
|
|
func ignorePastRetentionPolicyError(err error) error {
|
|
|
|
func ignorePastRetentionPolicyError(err error) error {
|
|
|
|
var influxDbWriteError *http.Error
|
|
|
|
var influxDbWriteError *http.Error
|
|
|
|
if errors.As(err, &influxDbWriteError) {
|
|
|
|
if errors.As(err, &influxDbWriteError) {
|
|
|
|