Skip to content
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

Move from SQLite to PostgreSQL on Elephant SQL #2

Merged
merged 1 commit into from Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
@@ -0,0 +1,2 @@
.git
vendor
6 changes: 5 additions & 1 deletion Gemfile
Expand Up @@ -6,7 +6,11 @@ ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
#gem 'sqlite3', '~> 1.4'

# Use PostgreSQL as the database for Active Record
gem 'pg', '~> 1.2.3'

# Use Puma as the app server
gem 'puma', '~> 5.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
Expand Down
5 changes: 2 additions & 3 deletions Gemfile.lock
Expand Up @@ -100,6 +100,7 @@ GEM
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
pg (1.2.3)
puma (5.2.0)
nio4r (~> 2.0)
racc (1.5.2)
Expand Down Expand Up @@ -144,7 +145,6 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.1.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
Expand All @@ -161,11 +161,10 @@ DEPENDENCIES
bootsnap (>= 1.4.4)
byebug
listen (~> 3.3)
pg (~> 1.2.3)
puma (~> 5.0)
rails (~> 6.1.1)
spring
sqlite3 (~> 1.4)
tzinfo-data

RUBY VERSION
ruby 2.7.2p137
Expand Down
13 changes: 8 additions & 5 deletions config/database.yml
Expand Up @@ -5,21 +5,24 @@
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 2 } %>
timeout: 5000
database: <%= ENV['DATABASE_NAME'] %>
user: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
host: <%= ENV['DATABASE_HOST'] %>
port: <%= ENV['DATABASE_PORT'] %>

development:
<<: *default
database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3

production:
<<: *default
database: db/production.sqlite3
2 changes: 2 additions & 0 deletions config/secrets.yml
@@ -0,0 +1,2 @@
production:
secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
26 changes: 25 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions docker-compose.yml
Expand Up @@ -10,3 +10,8 @@ services:
environment:
- SECRET_KEY_BASE=Qy6VTnREtzwBbzgvxY2LJA5QQwFNex4wUtj2qNTTnSXtHykdZM
- RAILS_ENV=development
- DATABASE_NAME=zrgyfclw
- DATABASE_USER=zrgyfclw
- DATABASE_PASSWORD=5br8zs-McuU5ISx_cp5il97O183_FgYh
- DATABASE_HOST=topsy.db.elephantsql.com
- DATABASE_PORT=5432