diff --git a/data/guides.yml b/data/guides.yml index 6ce1358d2..1ba911552 100644 --- a/data/guides.yml +++ b/data/guides.yml @@ -52,6 +52,7 @@ categories: - path: models pages: - path: overview + - path: database-configuration - path: repositories - path: entities - path: data-types diff --git a/source/guides/models/database-configuration.md b/source/guides/models/database-configuration.md new file mode 100644 index 000000000..26053e96c --- /dev/null +++ b/source/guides/models/database-configuration.md @@ -0,0 +1,41 @@ +--- +title: Guides - Database Configuration +--- + +# Database Configuration + +Before starting your server, you need to configure the database link in .env* files. + +Open this file for each environment and update DATABASE_URL for your database. + +## PostgreSQL + +Setup database variable for the development environment: + +``` +# .env.development +DATABASE_URL="postgresql://username:password@localhost/bookshelf_development" +``` + +Setup database variable for the test environment: + +``` +# .env.test +DATABASE_URL="postgresql://username:password@localhost/bookshelf_test" +``` + +# Setup your database + +After your database variables setup is done you need to create the database and run the migrations before being able to launch a development server. + +In your terminal, enter: + +``` +% bundle exec hanami db prepare +``` + +To setup your test environment database, enter: + +``` +% HANAMI_ENV=test bundle exec hanami db prepare +```