Refactor database configuration and schema for Crypto Trading Bot Platform

- Updated `docker-compose.yml` to remove hardcoded passwords, relying on environment variables for PostgreSQL and Redis configurations.
- Modified `env.template` to reflect new password settings and ensure secure handling of sensitive information.
- Introduced a new `database/connection.py` file for improved database connection management, including connection pooling and session handling.
- Updated `database/models.py` to align with the new schema in `schema_clean.sql`, utilizing JSONB for optimized data storage.
- Enhanced `setup.md` documentation to clarify the initialization process and emphasize the importance of the `.env` file for configuration.
- Added a new `scripts/init_database.py` script for automated database initialization and verification, ensuring all tables are created as expected.
This commit is contained in:
Vasily.onl
2025-05-30 18:20:38 +08:00
parent 8121ce0430
commit 73b7e8bb9d
12 changed files with 781 additions and 142 deletions

View File

@@ -21,10 +21,10 @@ class DatabaseSettings(BaseSettings):
"""Database configuration settings."""
host: str = Field(default="localhost", env="POSTGRES_HOST")
port: int = Field(default=5432, env="POSTGRES_PORT")
port: int = Field(default=5434, env="POSTGRES_PORT")
database: str = Field(default="dashboard", env="POSTGRES_DB")
user: str = Field(default="dashboard", env="POSTGRES_USER")
password: str = Field(default="dashboard123", env="POSTGRES_PASSWORD")
password: str = Field(default="", env="POSTGRES_PASSWORD")
url: Optional[str] = Field(default=None, env="DATABASE_URL")
@property