2.4 KiB
2.4 KiB
Fix DATABASE_URL in .env File
❌ Issue
The .env file contains a placeholder DATABASE_URL:
DATABASE_URL=postgresql://user:password@host:port/database
This is not a valid connection string - the port must be a number (e.g., 5432), not the literal word "port".
✅ Solution
Option 1: Use the Fix Script (Interactive)
cd /home/intlc/projects/proxmox/dbis_core
./scripts/fix-database-url.sh
This will prompt you for:
- Database host (default: 192.168.11.100)
- Database port (default: 5432)
- Database name (default: dbis_core)
- Database user (default: dbis)
- Database password
Option 2: Manual Edit
Edit the .env file and replace the placeholder with the actual connection string:
cd /home/intlc/projects/proxmox/dbis_core
nano .env # or use your preferred editor
Replace:
DATABASE_URL=postgresql://user:password@host:port/database
With (based on deployment docs):
DATABASE_URL=postgresql://dbis:8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771@192.168.11.100:5432/dbis_core
Option 3: Quick Fix Command
cd /home/intlc/projects/proxmox/dbis_core
# Replace with actual connection string
sed -i 's|DATABASE_URL=postgresql://user:password@host:port/database|DATABASE_URL=postgresql://dbis:8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771@192.168.11.100:5432/dbis_core|' .env
🔍 Verify Fix
After fixing, verify the connection string:
cd /home/intlc/projects/proxmox/dbis_core
grep "^DATABASE_URL" .env | sed 's/:[^:@]*@/:***@/g'
You should see:
DATABASE_URL=postgresql://dbis:***@192.168.11.100:5432/dbis_core
🚀 Then Run Migration
Once the DATABASE_URL is fixed, run the migration again:
./scripts/run-chart-of-accounts-migration.sh
⚠️ Important Notes
-
Password Encoding: If your password contains special characters (
:,@,#,/,?,&,=), they need to be URL-encoded::→%3A@→%40#→%23/→%2F?→%3F&→%26=→%3D
-
Connection Test: You can test the connection with:
psql "$DATABASE_URL" -c "SELECT version();" -
Security: The
.envfile should be in.gitignoreand not committed to version control.
After fixing the DATABASE_URL, the migration should work!