feat: add PostgreSQL configuration support for production#435
Conversation
- Add dj-database-url and psycopg2-binary to requirements.txt - Replace hardcoded SQLite DATABASES config in settings.py with dj_database_url.config() that reads DATABASE_URL env var - Falls back to SQLite when DATABASE_URL is not set (dev default) - Enables SSL when DEBUG=False for production PostgreSQL connections - Update .env.example with DATABASE_URL entry and comments - Update README Stack sections and add production database setup docs - Remove previously tracked __pycache__/*.pyc and db.sqlite3 from index
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThe PR adds ChangesPostgreSQL Production Database Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/backend/settings.py`:
- Around line 118-122: The runtime settings are still loading config.settings,
so the database configuration change in backend/settings.py is not being used in
deployment. Update the active settings module backend/config/settings.py to
include the same dj_database_url.config(...) database setup (or, alternatively,
change backend/config/wsgi.py and backend/config/asgi.py to import
backend.settings) so the deployed entrypoints and settings source stay aligned.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f4baa4a7-9174-494f-b7f6-3b0108f77afe
⛔ Files ignored due to path filters (51)
backend/backend/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/backend/__pycache__/celery.cpython-314.pycis excluded by!**/*.pycbackend/backend/__pycache__/settings.cpython-314.pycis excluded by!**/*.pycbackend/backend/__pycache__/urls.cpython-314.pycis excluded by!**/*.pycbackend/backend/__pycache__/wsgi.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/ai.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/apps.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/gmail_service.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/google_auth_views.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/models.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/serializers.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/tasks.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/tests.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/__pycache__/views.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/migrations/__pycache__/0001_initial.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/migrations/__pycache__/0002_campaignlead_last_sent_message_id_and_more.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/migrations/__pycache__/0003_alter_sequencestep_channel_type.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/migrations/__pycache__/0004_connectedemailaccount_connected_by.cpython-314.pycis excluded by!**/*.pycbackend/campaigns/migrations/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/config/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/config/__pycache__/settings.cpython-314.pycis excluded by!**/*.pycbackend/config/__pycache__/urls.cpython-314.pycis excluded by!**/*.pycbackend/config/__pycache__/wsgi.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/apps.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/models.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/serializers.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/tasks.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/tests.cpython-314.pycis excluded by!**/*.pycbackend/leads/__pycache__/views.cpython-314.pycis excluded by!**/*.pycbackend/leads/migrations/__pycache__/0001_initial.cpython-314.pycis excluded by!**/*.pycbackend/leads/migrations/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/admin.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/apps.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/middleware.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/models.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/security.cpython-314.pycis excluded by!**/*.pycbackend/tenants/__pycache__/tests.cpython-314.pycis excluded by!**/*.pycbackend/tenants/migrations/__pycache__/0001_initial.cpython-314.pycis excluded by!**/*.pycbackend/tenants/migrations/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/apps.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/jwt.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/models.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/serializers.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/tests.cpython-314.pycis excluded by!**/*.pycbackend/users/__pycache__/views.cpython-314.pycis excluded by!**/*.pycbackend/users/migrations/__pycache__/0001_initial.cpython-314.pycis excluded by!**/*.pycbackend/users/migrations/__pycache__/__init__.cpython-314.pycis excluded by!**/*.pyc
📒 Files selected for processing (5)
README.mdbackend/.env.examplebackend/backend/settings.pybackend/db.sqlite3requirements.txt
config/wsgi.py and config/asgi.py were still loading config.settings which hardcoded SQLite. Switch them to backend.settings which uses dj-database-url for proper DATABASE_URL support.
|
@Kuldeeep18 pls review |
Pull Request
🔗 Related Issue
Closes #337
📝 Summary of Changes
Adds PostgreSQL configuration support for production deployments via
DATABASE_URLenvironment variable, while keeping SQLite as the default for local development.requirements.txt: Addeddj-database-url>=2.2,<3.0andpsycopg2-binary>=2.9,<3.0backend/backend/settings.py: Replaced hardcoded SQLiteDATABASESdict withdj_database_url.config()that readsDATABASE_URLenv var. Falls back to SQLite when not set. Enables SSL whenDEBUG=Falsefor production.backend/.env.example: AddedDATABASE_URL=entry with commentsREADME.md: Updated both Stack sections to mention PostgreSQL, added "Production database setup" subsection with connection string example__pycache__/*.pycanddb.sqlite3from git index🏷️ Type of Change
🧪 Testing
Steps to test:
python backend/manage.py check— should report 0 issuespython backend/manage.py test users leads tenants— all 39 tests passDATABASE_URLset, verify the app uses SQLite (checkDATABASES['default']['ENGINE']isdjango.db.backends.sqlite3)DATABASE_URL=postgresql://user:pass@host:5432/dbset, verify the app uses PostgreSQL (checkDATABASES['default']['ENGINE']isdjango.db.backends.postgresql)✅ Checklist
Summary by CodeRabbit
DATABASE_URL.DATABASE_URLplaceholders and PostgreSQL connection string guidance.DATABASE_URLis not provided.