Add database configurations steps

This commit is contained in:
cryptogopher 2023-03-11 22:43:38 +01:00
parent c4bba4d2e8
commit e497d08f75
3 changed files with 26 additions and 20 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
# Ignore master key for decrypting credentials and more.
/config/application.rb
/config/database.yml
/config/initializers/secret_token.rb
/config/master.key

View File

@ -15,12 +15,20 @@ Modify configuration settings below `SETUP` comment appropriately.
## Database
Create database ...
cp -a config/database.yml.dist config/database.yml
Update database configuration in _config/database.yml_ if required.
Update database configuration.
Password is expected to be provided in `FIXINME_DATABASE_PASSWORD` environment
variable.
Create database user and grant privileges:
> mysql -p
mysql> create user fixinme@localhost identified by '<some password>';
mysql> grant all privileges on fixinme.* to fixinme@localhost;
mysql> flush privileges;
Run database creation task:
RAILS_ENV="production" bundle exec rake db:create
Run migrations ...

View File

@ -1,20 +1,10 @@
# MySQL. Versions 5.5.8 and up are supported.
# If you don't want to store sensitive information, like your database password,
# in your source code, provide the password or a full connection URL as an
# environment variable when you boot the app. For example:
#
# Install the MySQL driver
# gem install mysql2
# DATABASE_PASSWORD="some-password"
#
# Ensure the MySQL gem is defined in your Gemfile
# gem "mysql2"
#
# And be sure to use new-style password hashing:
# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
#
# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
# or
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
@ -26,6 +16,11 @@
# production:
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
#
# You can specify password environment variable in a similar way:
#
# production:
# password: <%= ENV["DATABASE_PASSWORD"] %>
#
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full overview on how database connection configuration can be specified.
default: &default
@ -33,13 +28,15 @@ default: &default
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: fixinme
password: <%= ENV["FIXINME_DATABASE_PASSWORD"] %>
password:
socket: /run/mysqld/mysqld.sock
production:
<<: *default
database: fixinme_production
# Unless you're planning on developing the application, you can skip/remove
# configurations for development and test databases altogether.
development:
<<: *default
database: fixinme_dev