Skip to content

Commit

Permalink
[hotfix] resolve utf-8 encoding issue in db migration (#4461)
Browse files Browse the repository at this point in the history
* [hotfix] resolve utf-8 encoding issue in db migration

* make python string unicode

* Update e866bd2d4976_smaller_grid.py

* Update e866bd2d4976_smaller_grid.py

* rearrange the debug message

* Update e866bd2d4976_smaller_grid.py
  • Loading branch information
timifasubaa authored and mistercrunch committed Feb 22, 2018
1 parent 0eecec1 commit 5830846
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions superset/migrations/versions/e866bd2d4976_smaller_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def upgrade():

dashboards = session.query(Dashboard).all()
for i, dashboard in enumerate(dashboards):
print('Upgrading ({}/{}): {}'.format(
i, len(dashboards), dashboard.id))
positions = json.loads(dashboard.position_json or '{}')
for pos in positions:
if pos.get('v', 0) == 0:
Expand All @@ -44,8 +46,6 @@ def upgrade():
dashboard.position_json = json.dumps(positions, indent=2)
session.merge(dashboard)
session.commit()
print('Upgraded ({}/{}): {}'.format(
i, len(dashboards), dashboard.dashboard_title))

session.close()

Expand All @@ -56,6 +56,8 @@ def downgrade():

dashboards = session.query(Dashboard).all()
for i, dashboard in enumerate(dashboards):
print('Downgrading ({}/{}): {}'.format(
i, len(dashboards), dashboard.id))
positions = json.loads(dashboard.position_json or '{}')
for pos in positions:
if pos.get('v', 0) == 1:
Expand All @@ -68,6 +70,4 @@ def downgrade():
dashboard.position_json = json.dumps(positions, indent=2)
session.merge(dashboard)
session.commit()
print('Downgraded ({}/{}): {}'.format(
i, len(dashboards), dashboard.dashboard_title))
pass

0 comments on commit 5830846

Please sign in to comment.