Skip to content

Commit

Permalink
Switch from sqlite to postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
mawise committed Aug 25, 2019
1 parent 390464d commit 4c6c75d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ruby '2.4.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
#gem 'sqlite3'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ GEM
nio4r (2.4.0)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
pg (1.1.4)
public_suffix (3.1.1)
puma (3.12.1)
rack (2.0.7)
Expand Down Expand Up @@ -162,7 +163,6 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.1)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.9)
Expand Down Expand Up @@ -192,13 +192,13 @@ DEPENDENCIES
commonmarker (~> 0.20)
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
pg
puma (~> 3.11)
rails (~> 5.2.3)
sass-rails (~> 5.0)
selenium-webdriver
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
Expand Down
15 changes: 5 additions & 10 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
encoding: unicode

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

# 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
database: rails_test_db

production:
<<: *default
database: db/production.sqlite3
database: tails_production_db
25 changes: 25 additions & 0 deletions config/sqlite.database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

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
8 changes: 6 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

ActiveRecord::Schema.define(version: 2019_08_25_224052) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.integer "record_id", null: false
t.integer "blob_id", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
Expand Down Expand Up @@ -54,4 +57,5 @@
t.datetime "updated_at", null: false
end

add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
end

0 comments on commit 4c6c75d

Please sign in to comment.