Skip to content

Commit

Permalink
update files to include postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwinaO committed Aug 28, 2019
1 parent 74db1fc commit dee22e4
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_WITH: "postgres"
9 changes: 7 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ gem 'activerecord', '~> 4.2', '>= 4.2.6', :require => 'active_record'
gem 'sinatra-activerecord', :require => 'sinatra/activerecord'
gem 'rake'
gem 'require_all'
gem 'sqlite3'
gem 'pg', '~> 0.20.0'
gem 'thin'
gem 'shotgun'
gem 'pry'
gem 'bcrypt'
gem "tux"
gem "sysrandom"
gem 'sinatra-flash', '~> 0.3.0'
gem 'date'


group :test do
gem 'rspec'
gem 'capybara'
gem 'rack-test'
gem 'pry'
gem 'database_cleaner', git: 'https://github.com/bmabey/database_cleaner.git'
end

# group :production do
# gem "activerecord-postgresql-adapter"
# end
54 changes: 27 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
GIT
remote: https://github.com/bmabey/database_cleaner.git
revision: 4c2408ffdbbd990e78d6590f4ef6ba5e58aca673
revision: bbc59ae17f88a64501a8ba8be3dc7a986174ee4d
specs:
database_cleaner (1.7.0)
database_cleaner (1.8.0)

GEM
remote: http://rubygems.org/
specs:
activemodel (4.2.11)
activesupport (= 4.2.11)
activemodel (4.2.11.1)
activesupport (= 4.2.11.1)
builder (~> 3.1)
activerecord (4.2.11)
activemodel (= 4.2.11)
activesupport (= 4.2.11)
activerecord (4.2.11.1)
activemodel (= 4.2.11.1)
activesupport (= 4.2.11.1)
arel (~> 6.0)
activesupport (4.2.11)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (6.0.4)
bcrypt (3.1.12)
bcrypt (3.1.13)
bond (0.5.1)
builder (3.2.3)
capybara (3.13.2)
capybara (3.28.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
regexp_parser (~> 1.5)
xpath (~> 3.2)
coderay (1.1.2)
concurrent-ruby (1.1.4)
concurrent-ruby (1.1.5)
daemons (1.3.1)
date (2.0.0)
diff-lcs (1.3)
eventmachine (1.2.7)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
method_source (0.9.2)
mini_mime (1.0.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
mustermann (1.0.3)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
pg (0.20.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.3)
rack (2.0.6)
rack-protection (2.0.5)
public_suffix (3.1.1)
rack (2.0.7)
rack-protection (2.0.7)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rake (12.3.2)
regexp_parser (1.3.0)
rake (12.3.3)
regexp_parser (1.6.0)
require_all (2.0.0)
ripl (0.7.1)
bond (~> 0.5.1)
Expand All @@ -72,28 +73,27 @@ GEM
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rspec-support (3.8.2)
shotgun (0.9.2)
rack (>= 1.0)
sinatra (2.0.5)
sinatra (2.0.7)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.5)
rack-protection (= 2.0.7)
tilt (~> 2.0)
sinatra-activerecord (2.0.13)
activerecord (>= 3.2)
sinatra (>= 1.0)
sinatra-flash (0.3.0)
sinatra (>= 1.0.0)
sqlite3 (1.3.13)
sysrandom (1.0.5)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
Expand All @@ -120,6 +120,7 @@ DEPENDENCIES
capybara
database_cleaner!
date
pg (~> 0.20.0)
pry
rack-test
rake
Expand All @@ -129,10 +130,9 @@ DEPENDENCIES
sinatra
sinatra-activerecord
sinatra-flash (~> 0.3.0)
sqlite3
sysrandom
thin
tux

BUNDLED WITH
1.17.3
2.0.2
4 changes: 1 addition & 3 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require './config/environment'

if ActiveRecord::Migrator.needs_migration?
raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
end

use Rack::MethodOverride

use UsersController
Expand Down
81 changes: 81 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# PostgreSQL. Versions 9.1 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#

# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling

development:
adapter: postgresql
encoding: unicode
database: development
host: localhost
pool: 5
timeout: 5000

# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
# username:
# The password associated with the postgres role (username).
# password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
# host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice

# 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.

# As with config/secrets.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 as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
url: <%= ENV['DATABASE_URL'] %>
adapter: postgresql
encoding: unicode
database: production
host: localhost
pool: 5
timeout: 5000
18 changes: 14 additions & 4 deletions config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])

ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "db/#{ENV['SINATRA_ENV']}.sqlite"
)

require './app/controllers/application_controller'
require_all 'app'


configure :production do
db = URI.parse(ENV['DATABASE_URL'] || 'postgres://localhost/mydb')

ActiveRecord::Base.establish_connection(
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
:host => db.host,
:username => db.user,
:password => db.password,
:database => db.path[1..-1],
:encoding => 'uft8'
)
end
Binary file removed db/.DS_Store
Binary file not shown.
Binary file removed db/development.sqlite
Binary file not shown.
3 changes: 3 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

ActiveRecord::Schema.define(version: 20190127204017) do

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

create_table "conferences", force: :cascade do |t|
t.string "name"
t.string "category"
Expand Down
1 change: 1 addition & 0 deletions procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec rackup config.ru -p $PORT

0 comments on commit dee22e4

Please sign in to comment.