-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Fixed timseries structure for storing signal metric #586
Updated timeseries migration script to also handle signal metrics. Fixes #586 Signed-off-by: Gagan Deep <[email protected]>
- Loading branch information
Showing
5 changed files
with
159 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
openwisp_monitoring/monitoring/migrations/0012_migrate_signal_metrics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Manually created | ||
|
||
import logging | ||
|
||
from django.db import migrations | ||
|
||
from .influxdb.influxdb_alter_structure_0006 import ( | ||
update_metric_timeseries_structure_forward_migration, | ||
update_metric_timeseries_structure_reverse_migration, | ||
) | ||
|
||
CHUNK_SIZE = 1000 | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def forward_migration(apps, schema_editor): | ||
update_metric_timeseries_structure_forward_migration(apps, schema_editor) | ||
from ..tasks import migrate_timeseries_database | ||
|
||
migrate_timeseries_database.delay() | ||
|
||
|
||
def reverse_migration(apps, schema_editor): | ||
update_metric_timeseries_structure_reverse_migration( | ||
apps, schema_editor, metric_keys=['signal'] | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [('monitoring', '0011_alter_metric_field_name')] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
forward_migration, | ||
reverse_code=reverse_migration, | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters