I am using flask-migrate to handle migrations. After adding a new column to the db and running the migration, what is the best approach to set the value of the new column for old users?
Right now I am temporarily adding this snippet for a url:
def test():
res = ""
users = User.query.all()
for u in users:
res += f"{u.username} {u.is_blocked}<br>"
u.is_blocked = False
db.session.commit()
return res
I think this is far from best practices. Should I create a small script that does the same work by directly connecting to the sql db, without using flask? Can anyone point me in the right direction?