-
Notifications
You must be signed in to change notification settings - Fork 782
Fix Docker setup: Enable database table creation on first run #30735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
## Problem The Docker setup fails to start because the database migration setting prevents table creation. The application crashes with "relation does not exist" errors when trying to access tables that were never created. ## Root Cause The `sails_models__migrate: safe` setting in docker-compose.yml prevents Sails.js from creating database tables, but the README documentation states that the database will be "initialized" on first run. ## Solution Change the migration setting from `safe` to `alter` to allow automatic table creation during development setup. ## Testing - Verified that `docker-compose up --build` now works without errors - Tables are created automatically on first run as documented - Application starts successfully and is accessible at localhost:1337
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
eashaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tux234 Sorry for the delay in reviewing this. IIRC, the database tables are created by the entrypoint.sh script when the container starts for the first time.
If the server is configured to always start with the alter migration strategy, it will try to rebuild the database every time the server starts, which can fail and lead to data loss if there are a large number of records.
|
Got it! So when I attempted to run it locally, it kept failing until I changed that value. Then the container spun up without issue. I fully admit my knowledge of containerization has some gaps, so if this is best practice, no worries! I can try to reproduce the error on another machine to see if we need to tweak something else. Thanks for the insight! |
|
Ok. Tried to reproduce the error on another machine and it didn't happen. Must have been a fluke on my end. Thanks for the help and I'll close this PR. |
Problem
The Docker setup fails to start because the database migration setting prevents table creation. The application crashes with "relation does not exist" errors when trying to access tables that were never created.
Root Cause
The
sails_models__migrate: safesetting in docker-compose.yml prevents Sails.js from creating database tables, but the README documentation states that the database will be "initialized" on first run.Solution
Change the migration setting from
safetoalterto allow automatic table creation during development setup.Testing
docker-compose up --buildnow works without errorsLet me know if you have questions, or if I'm misunderstanding the intention of the current configuration. Thanks!