Skip to content

Commit

Permalink
docs: improve Alembic integration guidance and resources
Browse files Browse the repository at this point in the history
Generated-by: aiautocommit
  • Loading branch information
iloveitaly committed Feb 8, 2025
1 parent 88573bd commit 1206278
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class User(
* Use your DB URL from the ENV
* Target sqlalchemy metadata to the sqlmodel-generated metadata

[Take a look at these scripts for an example of how to fully integrate Alembic into your development workflow.](https://github.com/iloveitaly/python-starter-template/blob/0af2c7e95217e34bde7357cc95be048900000e48/Justfile#L618-L712)

Here's a diff from the bare `alembic init` from version `1.14.1`.

```diff
diff --git i/test/migrations/alembic.ini w/test/migrations/alembic.ini
index 0d07420..a63631c 100644
Expand Down Expand Up @@ -112,6 +116,11 @@ index fbc4b07..9dc78bb 100644
# revision identifiers, used by Alembic.
```

Here are some useful resources around Alembic + SQLModel:

* https://github.com/fastapi/sqlmodel/issues/85
* https://testdriven.io/blog/fastapi-sqlmodel/

### Query Wrapper

This tool is added to all `BaseModel`s and makes it easy to write SQL queries. Some examples:
Expand Down
11 changes: 1 addition & 10 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
Docs are bad:

- JSON field, specifically JSONB https://github.com/tiangolo/sqlmodel/discussions/696
- Alembic migrations https://github.com/tiangolo/sqlmodel/issues/85 and https://testdriven.io/blog/fastapi-sqlmodel/
- JSON field, specifically JSONB https://github.com/tiangolo/sqlmodel/discussions/696 and https://github.com/fastapi/sqlmodel/discussions/1105
- One-to-many relationships
- Data validation https://github.com/tiangolo/sqlmodel/issues/52
- Aggregate functions, like count
- __tablename__, maybe as a function?
- Created at https://github.com/tiangolo/sqlmodel/issues/252
- Select on joined data
- One-to-one and one-to-many at the same time
- Comments on columns + tables https://github.com/tiangolo/sqlmodel/issues/492

TODO

Expand Down Expand Up @@ -53,8 +49,3 @@ clear engine
# _engine = None
# _connection = None
```

TODO

https://github.com/fastapi/sqlmodel/issues/492#issuecomment-2489858633 comments on models, table and field comments
https://github.com/zhanymkanov/fastapi-best-practices?tab=readme-ov-file#set-db-keys-naming-conventions there was another error around this as well

0 comments on commit 1206278

Please sign in to comment.