Hà Link
Hà Link

Reputation: 377

Flask migrate does not detect column autoincrement changes?

I have change my model class with id from autoincrement=False to autoincrement=True but Flask Migrate package does not dectect change to apply to the database? How can I fix this?

class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, unique=True, primary_key=True, autoincrement=True)

The migrate command log:

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.env] No changes in schema detected.

Upvotes: 1

Views: 1221

Answers (1)

Miguel Grinberg
Miguel Grinberg

Reputation: 67479

The autogenerated migration scripts are not meant to be 100% correct every time, they are meant just as a starter. You should review it, and add or correct anything that is not accurate. So I'd say just add the autoincrement to the script and that should be it.

Upvotes: 3

Related Questions