unable to create autoincrementing primary key with flask-sqlalchemy

前端 未结 6 2143
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 03:47

I want my model\'s primary key to be an autoincrementing integer. Here is how my model looks like

class Region(db.Model):
    __tablename__ = \'regions\'
            


        
6条回答
  •  天命终不由人
    2020-12-13 04:24

    I had the same error, even after adding autoincrement=True.

    The problem was I already had the migration created. So I downgraded to the previous migration, deleted the migration, created the migration again and upgraded.

    Then the error was gone.

    Hope it helps someone stuck on this.

    Wrapping off: Add autoincrement=True, and ensure your migration is updated and applied.

提交回复
热议问题