fix(migrations): support virtualenv Alembic execution
This commit is contained in:
@@ -1,10 +1,18 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import sys
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
from pathlib import Path
|
||||||
from sqlalchemy import pool
|
from sqlalchemy import pool
|
||||||
from sqlalchemy.engine import Connection
|
from sqlalchemy.engine import Connection
|
||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
from sqlalchemy.ext.asyncio import async_engine_from_config
|
||||||
from alembic import context
|
from alembic import context
|
||||||
|
|
||||||
|
# Ensure Alembic works both in the container and when invoked from a virtualenv
|
||||||
|
# on a server where the console-script directory would otherwise be sys.path[0].
|
||||||
|
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
if str(BACKEND_ROOT) not in sys.path:
|
||||||
|
sys.path.insert(0, str(BACKEND_ROOT))
|
||||||
|
|
||||||
from app.database import Base
|
from app.database import Base
|
||||||
from app.models import * # noqa: import all models
|
from app.models import * # noqa: import all models
|
||||||
from app.config import settings
|
from app.config import settings
|
||||||
|
|||||||
Reference in New Issue
Block a user