Skip to content

Commit

Permalink
Merge pull request apache#15 from john-bodley/john-bodley-sync-apache…
Browse files Browse the repository at this point in the history
…-master

[hotfix] resolve utf-8 encoding issue in db migration (apache#4461)
  • Loading branch information
john-bodley authored Feb 22, 2018
2 parents be48008 + d2bd3ee commit 19ea5f0
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 19ea5f0

Please sign in to comment.