Skip to content

Commit

Permalink
mysql for local/test, postgres for remote prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Fine committed Nov 10, 2022
1 parent 4b1111b commit b9a235a
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', git: 'https://github.com/wearefine/rails'
gem 'capistrano-rvm'

gem 'pg'
gem 'mysql2'
gem "puma", "~> 5.0"

gem "fog-aws"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ GEM
minitest (5.15.0)
msgpack (1.5.6)
multi_json (1.15.0)
mysql2 (0.5.4)
nenv (0.3.0)
net-imap (0.2.3)
digest
Expand Down Expand Up @@ -302,7 +303,6 @@ GEM
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0)
pg (1.4.3)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -463,7 +463,7 @@ DEPENDENCIES
fae-rails!
fog-aws
guard-rspec
pg
mysql2
pry
puma (~> 5.0)
rails (~> 7.0.2)
Expand Down
15 changes: 8 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
- FINE_NETLIFY_API_TOKEN=test
- FINE_NETLIFY_API_USER=test
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
# image: postgres
# volumes:
# - ./tmp/db:/var/lib/postgresql/data
# environment:
# POSTGRES_PASSWORD: password
# ports:
# - "5432:5432"
image: mariadb
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_ALLOW_EMPTY_PASSWORD='yes'
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/app/models/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def fae_display_field
# validates :wine_id, presence: true
validates :intro, length: { maximum: 100 }
validates :release_date, presence: true
validates :acclaims, presence: true
# validates :acclaims, presence: true
validates :wine, presence: true
validates :selling_points, presence: true
# validates :selling_points, presence: true

belongs_to :wine
belongs_to :varietal
Expand Down
53 changes: 32 additions & 21 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
default: &default
adapter: postgresql
encoding: unicode
host: <%= ENV.fetch('PGHOST') { 'db' } %>
username: postgres
password: password
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
base: &base
adapter: mysql2
encoding: utf8
collation: utf8_general_ci
database: fae_dummy
username: root
password:
host: localhost

development:
<<: *base
host: <%= ENV['DEV_MYSQL_HOST'] || 'localhost' %>

# test:
# <<: *base
# database: <%= ENV['MYSQL_DATABASE'] || 'fae_dummy_test' %>
# username: <%= ENV['MYSQL_USER'] || 'root' %>
# password: <%= ENV['MYSQL_PASSWORD'] %>
# host: <%= ENV['DEV_MYSQL_HOST'] || 'localhost' %>
test:
<<: *base
database: <%= ENV['MYSQL_DATABASE'] || 'fae_dummy_test' %>
username: <%= ENV['MYSQL_USER'] || 'root' %>
password: <%= ENV['MYSQL_PASSWORD'] %>
host: <%= ENV['DEV_MYSQL_HOST'] || 'localhost' %>

# =======================================

# development:
# <<: *default
# database: fae_engine
remote_development:
<<: *base
database: fae_dev
username: fae
password: sh45&rEDnap

# test:
# <<: *default
# database: fae_deploy_test_test
stage:
<<: *base
database: fae_stage
username: fae
password: sh45&rEDnap

production:
url: <%= ENV['DATABASE_URL'] %>
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
url: <%= ENV['DATABASE_URL'] %>
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/datadog.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Datadog.configure do |c|
c.tracing.enabled = Rails.env.production?
c.service = 'FAE Dummy'
c.env = 'production'
end
26 changes: 9 additions & 17 deletions spec/dummy/config/initializers/fae.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@
config.use_form_manager = true

# Removed for now to simplify render.com deploy
# if Rails.env.development? || Rails.env.test?
# config.netlify = {
# api_user: ENV['FINE_NETLIFY_API_USER'],
# api_token: ENV['FINE_NETLIFY_API_TOKEN'],
# site: 'fine-pss',
# site_id: 'bb32173b-9ff2-4d9d-860a-2683ae4e1e2b',
# api_base: 'https://api.netlify.com/api/v1/'
# }
# else
# config.netlify = {
# api_user: Rails.application.secrets.fine_netlify_api_user,
# api_token: Rails.application.secrets.fine_netlify_api_token,
# site: 'fine-pss',
# site_id: 'bb32173b-9ff2-4d9d-860a-2683ae4e1e2b',
# api_base: 'https://api.netlify.com/api/v1/'
# }
# end
if Rails.env.test?
config.netlify = {
api_user: ENV['FINE_NETLIFY_API_USER'],
api_token: ENV['FINE_NETLIFY_API_TOKEN'],
site: 'fine-pss',
site_id: 'bb32173b-9ff2-4d9d-860a-2683ae4e1e2b',
api_base: 'https://api.netlify.com/api/v1/'
}
end
end

0 comments on commit b9a235a

Please sign in to comment.