Skip to content

Commit

Permalink
Use postgres instead of sqlite3 for database backend.
Browse files Browse the repository at this point in the history
Adds the `pg` gem as a dependency and defaults to using postgres
for development, test, and production configurations of the application.

You must have DATABASE_URL in your .env set to some value (for
development and testing this can be `postgres://localhost`).

After pulling this commit you will need to run
`bundle exec rake db:setup` which will create the development and test
databases and apply all of the migrations.
  • Loading branch information
joelbcastillo committed Oct 31, 2019
1 parent f5b10a6 commit 96e216d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 25 deletions.
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Rails Settings
.# Rails Settings
RAILS_HOST=<RAILS HOST>

# E-Mail Settings
Expand All @@ -16,3 +16,8 @@ SAML_ACS_URL=<URL FOR ACS ENDPOINT>
NYC_ID_WEB_SERVICES_URL=<URL FOR WEB SERVICES>
NYC_ID_WEB_SERVICES_USERNAME=<NYC_ID SERVICE ACCOUNT USERNAME>
NYC_ID_WEB_SERVICES_PASSWORD=<NYC_ID SERVICE ACCOUNT PASSWORD>

# DATABASE
DATABASE_USERNAME=developer
DATABASE_PASSWORD=
DATABASE_URL=postgres://localhost
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ end
gem 'rails', '~> 5.1.6', '>= 5.1.6.2'
# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.3.0"
# Use postgresql as the database
gem "pg"
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ GEM
orm_adapter (0.5.0)
os (1.0.0)
parslet (1.8.2)
pg (1.1.4)
posix-spawn (0.3.13)
power_converter (0.1.2)
public_suffix (3.0.3)
Expand Down Expand Up @@ -812,6 +813,7 @@ DEPENDENCIES
jquery-ui-rails
listen (>= 3.0.5, < 3.2)
omniauth-saml
pg
puma (~> 3.7)
rails (~> 5.1.6, >= 5.1.6.2)
riiif (~> 2.0)
Expand Down
10 changes: 7 additions & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV.fetch("DATABASE_USERNAME") { "developer" } %>
password: <%= ENV.fetch("DATABASE_PASSWORD") { "" } %>
host: <%= ENV.fetch("DATABASE_URL") { "postgres://localhost" } %>
timeout: 5000

development:
<<: *default
database: db/development.sqlite3
database: gpp-hyrax-dev

# 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: gpp-hyrax-test

production:
<<: *default
Expand Down
10 changes: 9 additions & 1 deletion config/spring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }
).each { |path| Spring.watch(path) }
Spring.after_fork do
if ENV['DEBUGGER_STORED_RUBYLIB']
ENV['DEBUGGER_STORED_RUBYLIB'].split(File::PATH_SEPARATOR).each do |path|
next unless path =~ /ruby-debug-ide/
load path + '/ruby-debug-ide/multiprocess/starter.rb'
end
end
end
51 changes: 31 additions & 20 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

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

create_table "bookmarks", force: :cascade do |t|
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "bookmarks", id: :serial, force: :cascade do |t|
t.integer "user_id", null: false
t.string "user_type"
t.string "document_id"
Expand Down Expand Up @@ -50,7 +53,7 @@
end

create_table "collection_type_participants", force: :cascade do |t|
t.integer "hyrax_collection_type_id"
t.bigint "hyrax_collection_type_id"
t.string "agent_type"
t.string "agent_id"
t.string "access"
Expand All @@ -74,7 +77,7 @@
t.string "job_id"
t.string "type"
t.text "message"
t.integer "user_id"
t.bigint "user_id"
t.integer "parent_id"
t.integer "lft", null: false
t.integer "rgt", null: false
Expand Down Expand Up @@ -144,8 +147,8 @@
end

create_table "job_io_wrappers", force: :cascade do |t|
t.integer "user_id"
t.integer "uploaded_file_id"
t.bigint "user_id"
t.bigint "uploaded_file_id"
t.string "file_set_id"
t.string "mime_type"
t.string "original_name"
Expand All @@ -157,21 +160,21 @@
t.index ["user_id"], name: "index_job_io_wrappers_on_user_id"
end

create_table "mailboxer_conversation_opt_outs", force: :cascade do |t|
create_table "mailboxer_conversation_opt_outs", id: :serial, force: :cascade do |t|
t.string "unsubscriber_type"
t.integer "unsubscriber_id"
t.integer "conversation_id"
t.index ["conversation_id"], name: "index_mailboxer_conversation_opt_outs_on_conversation_id"
t.index ["unsubscriber_id", "unsubscriber_type"], name: "index_mailboxer_conversation_opt_outs_on_unsubscriber_id_type"
end

create_table "mailboxer_conversations", force: :cascade do |t|
create_table "mailboxer_conversations", id: :serial, force: :cascade do |t|
t.string "subject", default: ""
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "mailboxer_notifications", force: :cascade do |t|
create_table "mailboxer_notifications", id: :serial, force: :cascade do |t|
t.string "type"
t.text "body"
t.string "subject", default: ""
Expand All @@ -194,7 +197,7 @@
t.index ["type"], name: "index_mailboxer_notifications_on_type"
end

create_table "mailboxer_receipts", force: :cascade do |t|
create_table "mailboxer_receipts", id: :serial, force: :cascade do |t|
t.string "receiver_type"
t.integer "receiver_id"
t.integer "notification_id", null: false
Expand All @@ -211,19 +214,19 @@
t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type"
end

create_table "minter_states", force: :cascade do |t|
create_table "minter_states", id: :serial, force: :cascade do |t|
t.string "namespace", default: "default", null: false
t.string "template", null: false
t.text "counters"
t.integer "seq", limit: 8, default: 0
t.bigint "seq", default: 0
t.binary "rand"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["namespace"], name: "index_minter_states_on_namespace", unique: true
end

create_table "permission_template_accesses", force: :cascade do |t|
t.integer "permission_template_id"
t.bigint "permission_template_id"
t.string "agent_type"
t.string "agent_id"
t.string "access"
Expand All @@ -245,8 +248,8 @@

create_table "proxy_deposit_requests", force: :cascade do |t|
t.string "work_id", null: false
t.integer "sending_user_id", null: false
t.integer "receiving_user_id", null: false
t.bigint "sending_user_id", null: false
t.bigint "receiving_user_id", null: false
t.datetime "fulfillment_date"
t.string "status", default: "pending", null: false
t.text "sender_comment"
Expand All @@ -258,8 +261,8 @@
end

create_table "proxy_deposit_rights", force: :cascade do |t|
t.integer "grantor_id"
t.integer "grantee_id"
t.bigint "grantor_id"
t.bigint "grantee_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["grantee_id"], name: "index_proxy_deposit_rights_on_grantee_id"
Expand All @@ -274,7 +277,7 @@
end

create_table "qa_local_authority_entries", force: :cascade do |t|
t.integer "local_authority_id"
t.bigint "local_authority_id"
t.string "label"
t.string "uri"
t.datetime "created_at", null: false
Expand All @@ -293,7 +296,7 @@
t.datetime "updated_at", null: false
end

create_table "roles", force: :cascade do |t|
create_table "roles", id: :serial, force: :cascade do |t|
t.string "name"
end

Expand All @@ -306,7 +309,7 @@
t.index ["user_id"], name: "index_roles_users_on_user_id"
end

create_table "searches", force: :cascade do |t|
create_table "searches", id: :serial, force: :cascade do |t|
t.binary "query_params"
t.integer "user_id"
t.string "user_type"
Expand Down Expand Up @@ -496,7 +499,7 @@

create_table "uploaded_files", force: :cascade do |t|
t.string "file"
t.integer "user_id"
t.bigint "user_id"
t.string "file_set_uri"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Expand Down Expand Up @@ -581,4 +584,12 @@
t.index ["work_id"], name: "index_work_view_stats_on_work_id"
end

add_foreign_key "collection_type_participants", "hyrax_collection_types"
add_foreign_key "curation_concerns_operations", "users"
add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id"
add_foreign_key "mailboxer_notifications", "mailboxer_conversations", column: "conversation_id", name: "notifications_on_conversation_id"
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id", name: "receipts_on_notification_id"
add_foreign_key "permission_template_accesses", "permission_templates"
add_foreign_key "qa_local_authority_entries", "qa_local_authorities", column: "local_authority_id"
add_foreign_key "uploaded_files", "users"
end

0 comments on commit 96e216d

Please sign in to comment.