문제

I have Data Model (class) for example looking like this:

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True)
    password = db.Column(db.String(30))

I have a lot of records in this table now and I want to add a field, for example to save the email address.

I have searched the documentation and have not found a recommended way to do this. I have updated my MySql manually and added the field to the model and works most of the time if I declare the fields correctly.

Is there a "Best Practice" how to do this? Does SQLAlchemy have built in support to make updates to the table definition?

도움이 되었습니까?

해결책

Short answer is "No".

But check out alembic.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top