add auto migrations
This commit is contained in:
parent
f75b3dd034
commit
f51aa3133c
|
|
@ -21,8 +21,17 @@ if config.config_file_name is not None:
|
|||
fileConfig(config.config_file_name)
|
||||
|
||||
# Get database URL from settings
|
||||
settings = get_settings()
|
||||
config.set_main_option("sqlalchemy.url", settings.database_url)
|
||||
import os
|
||||
|
||||
db_url = os.environ.get("DATABASE_URL")
|
||||
if not db_url:
|
||||
raise RuntimeError("DATABASE_URL is not set")
|
||||
|
||||
# Alembic sync-only URL
|
||||
db_url = db_url.replace("sqlite+aiosqlite://", "sqlite:///")
|
||||
db_url = db_url.replace("postgresql+asyncpg://", "postgresql://")
|
||||
|
||||
config.set_main_option("sqlalchemy.url", db_url)
|
||||
|
||||
# Add your model's MetaData object here for 'autogenerate' support
|
||||
target_metadata = Base.metadata
|
||||
|
|
|
|||
Loading…
Reference in New Issue