|
3 | 3 | import sys |
4 | 4 | from logging.config import fileConfig |
5 | 5 |
|
6 | | -from sqlalchemy import engine_from_config |
7 | | -from sqlalchemy import pool |
| 6 | +from sqlalchemy import engine_from_config, pool |
8 | 7 |
|
9 | 8 | from alembic import context |
10 | 9 |
|
11 | | -# Add the src directory to Python path |
| 10 | +# Add the src directory to Python path explicitly before importing app modules |
12 | 11 | current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
13 | 12 | src_dir = os.path.join(current_dir, "src") |
14 | | -sys.path.append(src_dir) |
| 13 | +if src_dir not in sys.path: |
| 14 | + sys.path.insert(0, src_dir) |
15 | 15 |
|
16 | | -# Import your models and Base |
17 | | -from paste.database import Base |
| 16 | +# Import your models and Base after path setup |
| 17 | +from paste.config import get_settings # noqa: E402 |
| 18 | +from paste.database import Base # noqa: E402 |
| 19 | + |
| 20 | +# Import all your models here so Base.metadata is populated |
| 21 | +from paste.models import Paste # noqa: F401, E402 |
18 | 22 |
|
19 | | -# Import all your models here |
20 | 23 | # this is the Alembic Config object |
21 | 24 | config = context.config |
22 | 25 |
|
23 | 26 | # Interpret the config file for Python logging. |
24 | 27 | if config.config_file_name is not None: |
25 | 28 | fileConfig(config.config_file_name) |
26 | 29 |
|
27 | | -from paste.config import get_settings |
28 | | - |
29 | 30 | config.set_main_option("sqlalchemy.url", get_settings().SQLALCHEMY_DATABASE_URL) |
30 | 31 |
|
31 | 32 |
|
|
0 commit comments