Skip to content

Commit

Permalink
update flask-alembic docs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jun 16, 2024
1 parent 60c2667 commit e664ac2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions docs/alembic.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use Alembic directly, but it will require a little more setup.

## Flask-Alembic

[Flask-Alembic] currently expects Flask-SQLAlchemy, not Flask-SQLAlchemy-Lite. The
only difference is that it expects `db.metadata` to exist. You can assign this
after defining your base model.
[Flask-Alembic] will use the engines configured by Flask-SQLAlchemy-Lite. You
need to tell it about the metadata object for your base model. Multiple
databases are also supported, see the Flask-Alembic docs for details.

```python
from flask import Flask
Expand All @@ -30,12 +30,11 @@ class User(Model):
name: Mapped[str]

db = SQLAlchemy()
db.metadata = Model.metadata
alembic = Alembic()
alembic = Alembic(metadatas=Model.metadata)

def create_app():
app = Flask(__name__)
app.config |= {"SQLALCHEMY_ENGINES": {"default": "sqlite:///default.sqlite"}}
app.config["SQLALCHEMY_ENGINES"] = {"default": "sqlite:///default.sqlite"}
app.config.from_prefixed_env()
db.init_app(app)
alembic.init_app(app)
Expand Down

0 comments on commit e664ac2

Please sign in to comment.