Database Initialization Fails During Docker Setup
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Description
When running NextLog locally using Docker Compose, the database initialization process fails with multiple PostgreSQL errors during the installation phase.
Steps to Reproduce:
- Clone the repository and set up Docker environment ( cp .env .env.docker)
- Run
docker-compose up -dto start the containers - Access the web interface and begin the installation process
- The database installation API fails with various PostgreSQL errors
Error Logs:
nextlog-app | ERROR: trigger "update_users_updated_at" for relation "users" already exists (42710)
nextlog-app | ERROR: column "role" does not exist in table "users" (42703)
nextlog-app | ERROR: column "qrz_qsl_sent" does not exist in table "contacts" (42703)
nextlog-app | ERROR: syntax error at or near "NOT" (42601)
nextlog-app | ERROR: syntax error at or near "//" (42601)
Environment:
- Local Docker setup (Docker Compose)
- PostgreSQL container with automatic initialization via
postgres-init.sql - NextLog application container attempting to run installation API
Expected Behavior:
The database should initialize successfully and the application should complete installation without errors when running in Docker.
Actual Behavior:
Database initialization fails due to conflicts between the automatic PostgreSQL initialization and the application's installation API, preventing the application from starting properly.
The issue appears to be related to the interaction between the Docker-based PostgreSQL initialization and the application's database setup logic.
Our Solution Summary
Problem Identified:
Database initialization conflicts between Docker's automatic PostgreSQL setup (postgres-init.sql) and the application's installation API.
Key Issues Fixed:
-
Missing Table Fields
- Added missing
role,status,last_loginfields touserstable - Added missing QRZ QSL fields (
qrz_qsl_sent,qrz_qsl_rcvd, etc.) tocontactstable
- Added missing
-
Trigger Creation Conflicts
- Replaced
CREATE TRIGGERwith conditionalDOblocks usingpg_triggerchecks - Added existence checks before creating triggers to prevent "already exists" errors
- Replaced
Files Modified:
/src/app/api/install/database/route.ts- Fixed trigger creation logic and SQL syntaxpostgres-init.sql- Added missing table fields (optional, for future prevention)
Result
Database installation now completes successfully without conflicts between Docker's automatic initialization and the application's installation process.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/app/api/install/database/route.ts and postgres-init.sql, then reproduce the installation with docker-compose up -d and inspect the PostgreSQL errors. Done means the database installation completes successfully in the Docker setup without trigger, missing-column, or SQL syntax errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, nextjs, postgresql, typescript
- Domain
- database, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100