Skip to content

Commit 4d4ca5b

Browse files
committed
docs(migrations): address review comments on alembic config and package layouts
- Drop redundant prepend_sys_path from alembic.ini (env.py handles sys.path) - Pin db.sqlite path in alembic.ini using %(here)s to avoid cwd dependency - Add missing __init__.py files in multi-app package layout - Add noqa: E402 annotations to env.py snippets after sys.path manipulation
1 parent f7d5fed commit 4d4ca5b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

docs/models/migrations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ class Book(ormar.Model):
157157
[alembic]
158158
script_location = %(here)s/alembic
159159

160-
prepend_sys_path = .
161-
162-
sqlalchemy.url = sqlite:///db.sqlite
160+
sqlalchemy.url = sqlite:///%(here)s/db.sqlite
163161
```
164162

165163
`alembic/env.py`:
@@ -180,7 +178,7 @@ if config.config_file_name is not None:
180178
fileConfig(config.config_file_name)
181179

182180
# Import the shared metadata (and models, so the metaclass registers the tables).
183-
from my_project.models import metadata
181+
from my_project.models import metadata # noqa: E402
184182

185183
target_metadata = metadata
186184

@@ -246,8 +244,10 @@ my_project/
246244
│ ├── models/
247245
│ │ └── __init__.py
248246
│ ├── authors/
247+
│ │ ├── __init__.py
249248
│ │ └── models.py
250249
│ └── books/
250+
│ ├── __init__.py
251251
│ └── models.py
252252
└── alembic.ini
253253
```
@@ -316,7 +316,7 @@ __all__ = ["Author", "Book", "metadata"]
316316
Then in `alembic/env.py`:
317317

318318
```python
319-
from my_project.models import metadata, Author, Book # noqa: F401
319+
from my_project.models import Author, Book, metadata # noqa: E402, F401
320320

321321
target_metadata = metadata
322322
```

0 commit comments

Comments
 (0)