Fixing a potential FK error when doing bulk updates (#606)

I hit this upgrade issue in production where the FK for user wasn't
allowing null. Perhaps it is specific to our environment but I'd rather
fix this.
This commit is contained in:
Maxime Beauchemin 2016-06-12 21:39:06 -07:00 committed by GitHub
parent c58fd63efc
commit 1a4c7afbef

View File

@ -23,12 +23,11 @@ def upgrade():
bind = op.get_bind()
session = db.Session(bind=bind)
session.query(models.DruidMetric).update({
'is_restricted': False
})
session.query(models.SqlMetric).update({
'is_restricted': False
})
for obj in session.query(models.DruidMetric).all():
obj.is_restricted = False
for obj in session.query(models.SqlMetric).all():
obj.is_restricted = False
session.commit()
session.close()