Improve db/migrations misconfigurations
Came to fix one thing and found a few more :)
-
Fix the docker-compose configuration: use correct port, provide the password, add a note to the readme about
docker compose up(successor to docker-compose) -
Re-word the warning when the user is missing
config/db/. I found this from upgrading to 2.2.0.beta1 and the message I got wasWARNING: Database ./db/bookshelf_development.sqlite has no config/db/ directorywhich doesn't make a ton of sense. Now it'll sayWARNING: Database ./db/bookshelf_development.sqlite expects the folder config/db/ to exist but it does not. -
Add a specific warning when the user is missing
config/db/migrate/(but hasconfig/db) -
Add a specific warning when the user has
config/db/migrate/but it's empty (they might have this folder but then have their migrations in a different folder, e.g. with the name 'migrations' which is incorrect)
I also added the line "No database migrations can be run for this database." to the last two, just to be really explicit. I'm not 100% sure it's true, though, if they have migrations in a slice instead of the main app. Happy to get rid of it, or re-word it so that it's always accurate.
After these changes, if they're missing config/db/ this is what they see when they run hanami db prepare
WARNING: Database ./db/bookshelf_development.sqlite expects the folder config/db/ to exist but it does not.
WARNING: Database ./db/bookshelf_development.sqlite expects migrations to be located within config/db/migrate/ but that folder does not exist.
No database migrations can be run for this database.
sh: ~/hanami/bookshelf/config/db/structure.sql: No such file or directory
!!! => "./db/bookshelf_development.sqlite structure dumped to config/db/structure.sql" FAILED
Which is pretty redundant but I'd rather give more info than too little. We can make it more concise later, and also skip attempting to dump the structure if we can know it'll fail beforehand.