Skip to content

Commit

Permalink
Added pg database
Browse files Browse the repository at this point in the history
Signed-off-by: Kapil Chouhan <kpl.chouhan99@gmail.com>
  • Loading branch information
kapilchouhan committed Mar 8, 2020
1 parent 735f29b commit 27afa30
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ruby '2.6.2'
# 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 '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 @@ -114,6 +114,7 @@ GEM
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pg (1.2.2)
popper_js (1.16.0)
public_suffix (4.0.3)
puma (3.12.4)
Expand Down Expand Up @@ -191,7 +192,6 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
Expand Down Expand Up @@ -225,6 +225,7 @@ DEPENDENCIES
jbuilder (~> 2.5)
jquery-rails
listen (>= 3.0.5, < 3.2)
pg
puma (~> 3.11)
rails (~> 5.2.3)
redis
Expand All @@ -233,7 +234,6 @@ DEPENDENCIES
simple_form
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
Expand Down
2 changes: 1 addition & 1 deletion app/views/rooms/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="col">
<div class="alert alert-primary">
<h4 class="alert-heading">
Welcome to the RailsChatTutorial!
Welcome to the Rails Chat!
</h4>

<p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_navigation_bar.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark justify-content-between">
<a class="navbar-brand" href="#">Rails chat tutorial</a>
<a class="navbar-brand" href="#">Rails chat</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#nav-bar-collapse" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
Expand Down
26 changes: 11 additions & 15 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# 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
encoding: unicode
username: postgres
password: postgres
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
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.
database: rails_chat_development
test:
<<: *default
database: db/test.sqlite3
database: rails_chat_test

production:
<<: *default
database: db/production.sqlite3
database: rails_chat_production
username: rails_chat
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
9 changes: 7 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

ActiveRecord::Schema.define(version: 2020_03_08_070541) do

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

create_table "room_messages", force: :cascade do |t|
t.integer "room_id"
t.integer "user_id"
t.bigint "room_id"
t.bigint "user_id"
t.text "message"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Expand Down Expand Up @@ -43,4 +46,6 @@
t.index ["username"], name: "index_users_on_username", unique: true
end

add_foreign_key "room_messages", "rooms"
add_foreign_key "room_messages", "users"
end

0 comments on commit 27afa30

Please sign in to comment.