mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: remove mongo
This commit is contained in:
parent
573b9a43fc
commit
ac70cb534d
4 changed files with 13 additions and 22 deletions
|
|
@ -46,7 +46,7 @@ class HostingConfig(BaseModel):
|
|||
|
||||
|
||||
class DatabaseConfig(BaseModel):
|
||||
mongodb_connection_string: Optional[str]
|
||||
sql_connection_string: Optional[str]
|
||||
|
||||
|
||||
class LearnHouseConfig(BaseModel):
|
||||
|
|
@ -105,8 +105,8 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
|||
env_allowed_origins = env_allowed_origins.split(",")
|
||||
env_allowed_regexp = os.environ.get("LEARNHOUSE_ALLOWED_REGEXP")
|
||||
env_self_hosted = os.environ.get("LEARNHOUSE_SELF_HOSTED")
|
||||
env_mongodb_connection_string = os.environ.get(
|
||||
"LEARNHOUSE_MONGODB_CONNECTION_STRING"
|
||||
env_sql_connection_string = os.environ.get(
|
||||
"LEARNHOUSE_SQL_CONNECTION_STRING"
|
||||
)
|
||||
|
||||
# Sentry Config
|
||||
|
|
@ -166,9 +166,9 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
|||
)
|
||||
|
||||
# Database config
|
||||
mongodb_connection_string = env_mongodb_connection_string or yaml_config.get(
|
||||
sql_connection_string = env_sql_connection_string or yaml_config.get(
|
||||
"database_config", {}
|
||||
).get("mongodb_connection_string")
|
||||
).get("sql_connection_string")
|
||||
|
||||
# Sentry config
|
||||
# check if the sentry config is provided in the YAML file
|
||||
|
|
@ -210,7 +210,7 @@ def get_learnhouse_config() -> LearnHouseConfig:
|
|||
content_delivery=content_delivery,
|
||||
)
|
||||
database_config = DatabaseConfig(
|
||||
mongodb_connection_string=mongodb_connection_string
|
||||
sql_connection_string=sql_connection_string
|
||||
)
|
||||
|
||||
# Create LearnHouseConfig object
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ hosting_config:
|
|||
domain: learnhouse.app
|
||||
ssl: true
|
||||
allowed_origins:
|
||||
- http://localhost:3000
|
||||
- http://localhost:3001
|
||||
- http://localhost:3000
|
||||
- http://localhost:3001
|
||||
cookies_config:
|
||||
domain: ".localhost"
|
||||
allowed_regexp: '\b((?:https?://)[^\s/$.?#].[^\s]*)\b'
|
||||
|
|
@ -25,4 +25,4 @@ hosting_config:
|
|||
endpoint_url: ""
|
||||
|
||||
database_config:
|
||||
mongodb_connection_string: mongodb://learnhouse:learnhouse@mongo:27017/
|
||||
sql_connection_string: postgresql://learnhouse:learnhouse@db:5432/learnhouse
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import logging
|
||||
from config.config import get_learnhouse_config
|
||||
from fastapi import FastAPI
|
||||
import motor.motor_asyncio
|
||||
from sqlmodel import SQLModel, Session, create_engine
|
||||
|
||||
|
||||
learnhouse_config = get_learnhouse_config()
|
||||
engine = create_engine(
|
||||
"postgresql://learnhouse:learnhouse@db:5432/learnhouse", echo=False
|
||||
learnhouse_config.database_config.sql_connection_string, echo=False
|
||||
)
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
|
|
@ -16,12 +16,6 @@ async def connect_to_db(app: FastAPI):
|
|||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
# mongodb
|
||||
app.mongodb_client = motor.motor_asyncio.AsyncIOMotorClient( # type: ignore
|
||||
app.learnhouse_config.database_config.mongodb_connection_string # type: ignore
|
||||
) # type: ignore
|
||||
app.db = app.mongodb_client["learnhouse"] # type: ignore
|
||||
|
||||
|
||||
def get_db_session():
|
||||
with Session(engine) as session:
|
||||
|
|
@ -29,6 +23,5 @@ def get_db_session():
|
|||
|
||||
|
||||
async def close_database(app: FastAPI):
|
||||
app.mongodb_client.close() # type: ignore
|
||||
logging.info("LearnHouse has been shut down.")
|
||||
return app
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from enum import Enum
|
||||
from typing import Optional
|
||||
from sqlalchemy import JSON, Column
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlalchemy import BigInteger, Column, ForeignKey
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlalchemy import BigInteger, ForeignKey, JSON, Column
|
||||
|
||||
|
||||
class TrailStepTypeEnum(str, Enum):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue