redash/old_migrations/0013_update_counter_options.py
Arik Fraimovich 70d545410d Add Flask-Migrate to the project
Also moved old migrations to old_migrations folder (before deleting them entirely).
2016-12-07 17:59:01 +02:00

24 lines
779 B
Python

import json
from redash import models
if __name__ == '__main__':
for vis in models.Visualization.select():
if vis.type == 'COUNTER':
options = json.loads(vis.options)
print "Before: ", options
if 'rowNumber' in options and options['rowNumber'] is not None:
options['rowNumber'] += 1
else:
options['rowNumber'] = 1
if 'counterColName' not in options:
options['counterColName'] = 'counter'
if 'targetColName' not in options:
options['targetColName'] = 'target'
options['targetRowNumber'] = options['rowNumber']
print "After: ", options
vis.options = json.dumps(options)
vis.save()