- 🔧 Upgrade MkDocs Material and update configs. PR #217 by @tiangolo.
- ⬆ Upgrade mypy, fix type annotations. PR #218 by @tiangolo.
SQLModel no longer creates indexes by default for every column, indexes are now opt-in. You can read more about it in PR #205.
Before this change, if you had a model like this:
from typing import Optional from sqlmodel import Field, SQLModel class Hero(SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) name: str secret_name: str age: Optional[int] = None
...when creating the tables, SQLModel version
0.0.5 and below, would also create an index for
name, one for
secret_name, and one for
id is the primary key, so it doesn't need an additional index).
If you depended on having an index for each one of those columns, now you can (and would have to) define them explicitly:
class Hero(SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) name: str = Field(index=True) secret_name: str = Field(index=True) age: Optional[int] = Field(default=None, index=True)
There's a high chance you don't need indexes for all the columns. For example, you might only need indexes for
age, but not for
secret_name. In that case, you could define the model as:
class Hero(SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) name: str = Field(index=True) secret_name: str age: Optional[int] = Field(default=None, index=True)
If you already created your database tables with SQLModel using versions
0.0.5 or below, it would have also created those indexes in the database. In that case, you might want to manually drop (remove) some of those indexes, if they are unnecessary, to avoid the extra cost in performance and space.
Depending on the database you are using, there will be a different way to find the available indexes.
For example, let's say you no longer need the index for
secret_name. You could check the current indexes in the database and find the one for
secret_name, it could be named
ix_hero_secret_name. Then you can remove it with SQL:
DROP INDEX ix_hero_secret_name
DROP INDEX ix_hero_secret_name ON hero;
Here's the new, extensive documentation explaining indexes and how to use them: Indexes - Optimize Queries.
- ✨ Document indexes and make them opt-in. Here's the new documentation: Indexes - Optimize Queries. This is the same change described above in Breaking Changes. PR #205 by @tiangolo.
- ✏ Fix typo in FastAPI tutorial. PR #192 by @yaquelinehoyos.
- 📝 Add links to the license file. PR #29 by @sobolevn.
- ✏ Fix typos in docs titles. PR #28 by @Batalex.
- ✏ Fix multiple typos and some rewording. PR #22 by @egrim.
- ✏ Fix typo in
docs/tutorial/automatic-id-none-refresh.md. PR #14 by @leynier.
- ✏ Fix typos in
docs/databases.md. PR #5 by @sebastianmarines.
- ✨ Add support for Decimal fields from Pydantic and SQLAlchemy. Original PR #103 by @robcxyz. New docs: Advanced User Guide - Decimal Numbers.
- 🔧 Split MkDocs insiders build in CI to support building from PRs. PR #186 by @tiangolo.
- 🎨 Format
expression.pyand expression template, currently needed by CI. PR #187 by @tiangolo.
- 🐛Fix docs light/dark theme switcher. PR #1 by @Lehoczky.
- 🔧 Add MkDocs Material social cards. PR #90 by @tiangolo.
- ✨ Update type annotations and upgrade mypy. PR #173 by @tiangolo.
- This includes several small bug fixes detected during the first CI runs.
- 💚 Fix CI installs and tests. PR #2 by @tiangolo.
- First release. 🎉