Fix syntax errors in MapView.vue and improve backend production robustness (CORS, DB URL, auto-migrations, and seeding)
This commit is contained in:
@ -42,5 +42,12 @@ class Settings(BaseSettings):
|
||||
)
|
||||
|
||||
|
||||
# Global settings instance
|
||||
# Global settings instance
|
||||
@property
|
||||
def get_database_url(self) -> str:
|
||||
url = self.database_url
|
||||
if url.startswith("postgres://"):
|
||||
url = url.replace("postgres://", "postgresql://", 1)
|
||||
return url
|
||||
|
||||
settings = Settings()
|
||||
|
||||
@ -8,7 +8,12 @@ from app.core.config import settings
|
||||
|
||||
# Create database engine
|
||||
# Convert asyncpg URL to psycopg2 for synchronous operations
|
||||
database_url = settings.database_url.replace("+asyncpg", "+psycopg2")
|
||||
database_url = settings.get_database_url
|
||||
if "+asyncpg" in database_url:
|
||||
database_url = database_url.replace("+asyncpg", "+psycopg2")
|
||||
elif "postgresql://" in database_url and "+psycopg2" not in database_url:
|
||||
database_url = database_url.replace("postgresql://", "postgresql+psycopg2://")
|
||||
|
||||
engine = create_engine(
|
||||
database_url,
|
||||
echo=settings.debug,
|
||||
|
||||
Reference in New Issue
Block a user