SQLAlchemy create_all() does not add new columns to existing SQLite tables

12 hours ago 2
ARTICLE AD BOX

I added a new column to an existing SQLAlchemy ORM model in a SQLite-backed application.

For example, my model now looks like this:

class User(Base): __tablename__ = "users" id = Column(String(36), primary_key=True) name = Column(String(100)) daily_blessing_enabled = Column( Boolean, nullable=False, default=True, server_default="1" )

On startup I run:

Base.metadata.create_all(bind=engine)

There is no error during startup, but later I get:

OperationalError: table users has no column named daily_blessing_enabled

My assumption was that create_all() would update the existing table schema when the ORM model changed.

Does create_all() only create missing tables? If so, what is the correct lightweight approach for handling this in a SQLite development setup without introducing Alembic yet? class User(Base): _tablename_ = "users" id = Column(String(36), primary_key=True) name = Column(String(100)) daily_blessing_enabled = Column( Boolean, nullable=False, default=True, server_default="1" )

Base.metadata.create_all(bind=engine) OperationalError: table users has no column named daily_blessing_enabled
Read Entire Article