Skip to content

chore: finalize PostgreSQL migration and environment configuration#299

Open
yousefshaheen113-blip wants to merge 10 commits into
TheHamkerCat:devfrom
yousefshaheen113-blip:dev
Open

chore: finalize PostgreSQL migration and environment configuration#299
yousefshaheen113-blip wants to merge 10 commits into
TheHamkerCat:devfrom
yousefshaheen113-blip:dev

Conversation

@yousefshaheen113-blip

Copy link
Copy Markdown

Description

This pull request finalizes the transition from MongoDB to PostgreSQL and stabilizes the project environment for Railway deployment.

Key Changes

  • Database Migration: Completed migration of project infrastructure from MongoDB to PostgreSQL.
  • Environment Configuration: Updated environment variables, removing obsolete MongoDB URIs and ensuring PostgreSQL compatibility.
  • Dependency Fixes: Resolved missing dependency errors and fixed Python uv environment configuration.
  • Bot UI/UX: Improved Arabic/English interface support and fixed welcome message rendering.
  • Stability: Added startup environment variable validation with clear error messages.

Testing

  • Verified database schema consistency.
  • Confirmed successful build and deployment on the Railway platform.

yousefshaheen113-blip and others added 10 commits June 22, 2026 03:35
…es Update, and Railway Optimization

This commit includes:
- Complete migration from MongoDB (motor) to PostgreSQL (asyncpg)
- New database connection layer with connection pooling
- PostgreSQL schema definitions for all collections
- Updated environment variable handling (DATABASE_URL, TZ, LOG_LEVEL, MAX_CONCURRENT_TASKS)
- Fixed deprecated packages (youtube_dl→yt-dlp, googletrans→google-trans-new)
- Added missing pyrogram dependency
- Railway deployment optimization (Dockerfile, pyproject.toml updates)
- Fixed import errors and configuration issues
- Session persistence strategy for Railway compatibility

Files Added:
- wbb/core/database.py (PostgreSQL connection and schema management)
- wbb/utils/db_migrate.py (Database initialization and migration utilities)
- .env.example (Complete environment variables template)
- schema.sql (PostgreSQL schema)

Files Modified:
- wbb/__init__.py (Updated config loading, removed MongoDB, added TZ/LOG_LEVEL/MAX_CONCURRENT_TASKS)
- wbb/utils/dbfunctions.py (PostgreSQL-based implementations)
- wbb/utils/dbfeds.py (PostgreSQL-based federation system)
- wbb/modules/mongo_backup.py (Removed - no longer needed)
- sample_config.env (Updated with DATABASE_URL)
- sample_config.py (Updated config loading)
- pyproject.toml (Updated dependencies, added asyncpg, removed motor)
- Dockerfile (Optimized for PostgreSQL)
- docker-compose.yml (Added PostgreSQL service)
…t case, add Railway/Nixpacks config

- Replace ARQ_API_KEY → ANTHROPIC_API_KEY in all files
- Fix Python_ARQ import (case-sensitive on Linux)
- Remove motor/MongoDB references from inlinefuncs.py and mongo_backup.py
- Add railway.toml and nixpacks.toml for Railway deployment
- Add requirements.txt for pip-based installs
- Migrate mongo_backup.py to PostgreSQL pg_dump
- Fix googletrans import: replace from googletrans import Translator
  with from google_trans_new import google_translator (correct module name)
- Add cryptography>=42.0.0 to requirements.txt (was missing)
- Rebuild requirements.txt with >= version pins (more compatible than ~=)
- Fix nixpacks.toml: explicit pip install into system Python
- Fix railway.toml: remove invalid [[services]] stanza
- Rewrite sample_config.py: validate all required env vars before any
  int() conversion or Pyrogram init can throw a cryptic traceback
- Collect every missing/invalid variable in one pass, print a labeled
  error table with Railway instructions, then sys.exit(1) cleanly
- Detect SESSION_STRING vs PHONE_NUMBER requirement explicitly
- Validate integer fields (API_ID, LOG_GROUP_ID, etc.) with human
  readable error if non-numeric value is supplied
- Remove duplicate DATABASE_URL check from wbb/__init__.py
  (now caught earlier in sample_config.py with better message)
Root cause: nixpacks.toml was overriding uv auto-detection with
pip install -r requirements.txt. Packages went into a venv that
system 'python -m wbb' could not see -> ModuleNotFoundError: aiohttp.

Changes:
- nixpacks.toml: add uv to nixPkgs, run 'uv sync --no-dev --frozen'
- railway.toml: start command -> 'uv run python -m wbb'
- pyproject.toml: add cryptography>=42.0.0 as explicit dep
- uv.lock: regenerated (adds cryptography v49.0.0, cffi, pycparser)
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 0d8310bf-fd05-4cb9-8e27-ceef1e8ba8bf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 0863ea63-f4c1-474b-9d8c-6ce597d73176
Replit-Helium-Checkpoint-Created: true
Refactors database interactions in `wbb/core/database.py` and `wbb/utils/dbfunctions.py` to address schema mismatches and improve compatibility. Updates `requirements.txt` and `replit.nix` for new dependencies and environment configurations.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 0d8310bf-fd05-4cb9-8e27-ceef1e8ba8bf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: fb51d7fb-3444-4ba3-9d4b-d281739ada1f
Replit-Helium-Checkpoint-Created: true
Translate UI elements, command help strings, and documentation into Arabic across numerous files, updating repository URLs and support links.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 0d8310bf-fd05-4cb9-8e27-ceef1e8ba8bf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 4bfc641f-9a38-4069-8a17-703f779d33a7
Replit-Helium-Checkpoint-Created: true
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a9bd5a05-0573-4d97-b99c-ba6254d55433
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 1c309820-94d3-42e0-b9bc-81d3a33db951
Replit-Helium-Checkpoint-Created: true
Fixes a ValueError in text splitting for welcome messages and a TypeError by adding a None check before unpacking results from keyb extraction.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a9bd5a05-0573-4d97-b99c-ba6254d55433
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: fdd778ff-2ab8-4139-9eef-ccdeea70d597
Replit-Helium-Checkpoint-Created: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants