-
Notifications
You must be signed in to change notification settings - Fork 171
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
Add instructions to setup PostgreSQL #251
Add instructions to setup PostgreSQL #251
Conversation
Hi @mzelenyuk and thank you for the time spent on this! As I said in the issue, I think it should be a full guide page, detailing the configuration for the 3 mainly used DBs. The Getting Started guide should stay clear of this, and only have a link to the previously mentioned Guide. Do you think you'd have time to make a new guide page and adapt what you wrote here as a section of that guide? |
Hi @TiteiKo! Yeah, I think a new Guide page for database configuration is the best case. |
I'm not the best to answer this, so I'll let the amazing people of @hanami/documentation answer your questions! |
@TiteiKo Great, thanks! |
@mzelenyuk good idea 👍 What do you think, maybe will better to write something like this?
/cc @cllns |
@davydovanton Sounds good. We may consider to place each DB's specific content under its own header (see screenshot) and tell how to create a table for each environment to make database setup more easier for the beginners. |
@mzelenyuk awesome 👍 |
@davydovanton Thanks! So what's the plan now? Waiting for @cllns response? |
yep :) |
Yes, I think this should be its own guide, not a part of the Getting Started guide. We also have a Environment Variables guide planned, but I don't think people would know to look their for database configuration/info. I think this should go under the 'Models' section. |
@mzelenyuk Hi and thanks for this PR. TL;DR: We can merge this PR to help new people confused by Postgres complexity, but in the long run we should use Sqlite for the getting started guide. The less details we present in the getting started guide, the less we overwhelm newcomers. While having an env vars guide is desirable as reference, we should remove env vars from the getting started guide. To solve the problem that @mzelenyuk ran into, we should abandon Postgres in the getting started guide in favor of Sqlite. There are a few advantages:
|
892c615
to
8e6911a
Compare
|
||
# Overview | ||
|
||
Before starting your server, you need to configure database link in <code>.env*</code> files. |
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.
configure the database link
|
||
## Prepare tables in database | ||
|
||
After your database variables setup is done you need to create a table in your database before you're be able to launch a development server. |
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.
you need to create the database and run the migrations before being able to launch a development server.
% bundle exec hanami db prepare | ||
``` | ||
|
||
To create a table in database for the test environment, enter: |
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.
To setup your test environment database, enter:
DATABASE_URL="postgres://username:password@localhost/bookshelf_test" | ||
``` | ||
|
||
## Prepare tables in database |
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.
This could be at the same level of title as Overview
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.
Setup your database
@TiteiKo Fixed. Thanks for help! :) |
@mzelenyuk Can you rename this DB config only affects Models so I think it fits well in that group :) |
@cllns Yes, sure. |
@cllns Good for me |
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.
Thanks for the PR, once you change these comments I'll be happy to merge ;)
|
||
``` | ||
# .env.development | ||
DATABASE_URL="postgres://username:password@localhost/bookshelf_development" |
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.
@mzelenyuk could you change postgres://
to postgresql://
? We are generating postgresql://
because it supporter in MRI and JRuby ;)
|
||
``` | ||
# .env.test | ||
DATABASE_URL="postgres://username:password@localhost/bookshelf_test" |
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.
the same here.
@AlfonsoUceda Yes, sure! :) |
Thanks @mzelenyuk ;) |
When generated a new Hanami project with PostgreSQL I was a bit confused how to setup a database on my local machine (I was not able to start
hanami server
because of database connection error). It's not well documented yet so I spend some time to find the answer.I'm not sure where is the best place to show the setup instructions but I hope it will be helpful for new Hanami users.
Particularly closes #229.
Cheers!