Closed cllns closed 2 months ago
Addressed all your comments.
Should we also add default DATABASE_URL's to .env.development
and .env.test
?
Addressed all your comments.
Thanks @cllns, those changes look good!
Should we also add default DATABASE_URL's to .env.development and .env.test?
I reckon we should actually add it directly to a generated .env
file!
Reasons:
.env
is safe to check in._test
suffix for the database name in test mode.Together, this means a single .env
with a single DATABASE_URL
will be enough to cover all local development use cases! This feels a lot neater than having to generate two files and requiring new users to remember that the DATABASE_URL
needs to be kept in sync across both.
Now, as the dotenv docs point out, if you check in a .env
, then it's imperative you use the counterpart files that are not checked in (.env.development.local
, etc.) to store any sensitive values.
To this end, I think we should:
.env
with the DATABASE_URL
in it.env
making it clear that sensitive values should go in the other files.gitignore
so that .env
is no longer ignored, and add .env.local
and .env.*.local
in its placeHow does this sound to you, @cllns?
Once this is done I reckon we should finally be at the point of a ready-to-go database-backed app after hanami new
! 🎉
p.s. I re-ran the failing tests and they turned green (due to my making the latest dry-configurable gem release), so I think this should come good after the next push. It might need a rebase to get the latest GitHub actions workflow from the main branch though (with 3.0 removed).
Addressed all the comments and we're green again.
I also added include Dry::Operation::Extensions::ROM
into the base Operation so users will be able to use transaction
(unless they --skip-db)
Right now the app/db/repo.rb
is generated as AppName::Repo
, not AppName::DB::Repo
. I feel like that's fine but just want to confirm that we're all OK with that, since it might be surprising. We could also alias it so it exists in both places, but that's a little strange too.
Sweet. All good now, with the base repo going into app/db/repo.rb
as MyApp::DB::Repo
Thanks @cllns! I'm going to merge this now, since I want to start updating our getting started guide, and being able to generate a new app will help with that :)
Resolves #147.
A couple things.
DATABASE_URL
to.env
yet. I like the pattern of putting those into.env.development
and.env.test
. I know there was some discussion about an automatic translation from a development DATABASE_URL to a test one but not sure where we landed on that. When deploying to production, it's a feature that it won't deploy without DATABASE_URL set on the production server, so the development one isn't used accidentally.private_constant
so I can re-use them. I don't really like where they are now, any ideas of a better place to put them?Hanami::DB::Repo
and added a FIXME for when rename that toHanami::Repo