Skip to content

Commit

Permalink
added postgres database
Browse files Browse the repository at this point in the history
  • Loading branch information
dereke committed Oct 8, 2019
1 parent 573fde7 commit 003b561
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.2', require: false
gem 'devise'
gem 'komponent', '>= 3.0.0.beta1'
gem 'pg'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ GEM
parallel (1.17.0)
parser (2.6.4.0)
ast (~> 2.4.0)
pg (1.1.4)
public_suffix (3.1.1)
puma (3.12.1)
rack (2.0.7)
Expand Down Expand Up @@ -250,6 +251,7 @@ DEPENDENCIES
jbuilder (~> 2.7)
komponent (>= 3.0.0.beta1)
listen (>= 3.0.5, < 3.2)
pg
puma (~> 3.11)
rails (~> 6.0.0)
rails_best_practices
Expand Down
6 changes: 2 additions & 4 deletions app/models/initiative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class Initiative < ApplicationRecord
after_initialize :set_default_location

def set_default_location
return if persisted?

self.latitude = 51.742
self.longitude = -2.222
self.latitude ||= 51.742
self.longitude ||= -2.222
end

# rubocop:disable Metrics/MethodLength
Expand Down
38 changes: 18 additions & 20 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# SQLite. Versions 3.8.0 and up are supported.
# 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
adapter: postgresql
encoding: unicode
database: carbon_map_development
pool: 5
username:
password:

# 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
adapter: postgresql
encoding: unicode
database: carbon_map_test
pool: 5
username:
password:

production:
<<: *default
database: db/production.sqlite3
adapter: postgresql
encoding: unicode
database: carbon_map_production
pool: 5
username:
password:
15 changes: 9 additions & 6 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_10_05_213108) do
# These are extensions that must be enabled in order to support this database
enable_extension 'plpgsql'

create_table 'group_group_types', force: :cascade do |t|
t.integer 'group_id', null: false
t.integer 'group_type_id', null: false
t.bigint 'group_id', null: false
t.bigint 'group_type_id', null: false
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index %w[group_id], name: 'index_group_group_types_on_group_id'
Expand All @@ -28,7 +31,7 @@

create_table 'group_websites', force: :cascade do |t|
t.string 'website'
t.integer 'group_id', null: false
t.bigint 'group_id', null: false
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index %w[group_id], name: 'index_group_websites_on_group_id'
Expand All @@ -43,7 +46,7 @@
t.string 'contact_phone'
t.boolean 'gdpr'
t.boolean 'gdpr_email_verified'
t.integer 'owner_id'
t.bigint 'owner_id'
t.datetime 'created_at', precision: 6, null: false
t.datetime 'updated_at', precision: 6, null: false
t.index %w[owner_id], name: 'index_groups_on_owner_id'
Expand All @@ -64,12 +67,12 @@
t.string 'locality'
t.string 'location'
t.string 'alternative_solution_name'
t.integer 'lead_group_id', null: false
t.bigint 'lead_group_id', null: false
t.string 'contact_name'
t.string 'contact_email'
t.string 'contact_phone'
t.string 'partner_groups_role'
t.integer 'status_id', null: false
t.bigint 'status_id', null: false
t.boolean 'gdpr'
t.boolean 'gdpr_email_verified'
t.datetime 'created_at', precision: 6, null: false
Expand Down
7 changes: 6 additions & 1 deletion nuke
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
rails db:drop db:migrate db:seed
#!/usr/bin/env bash

set -e

rails db:drop db:create db:migrate
rails db:seed

0 comments on commit 003b561

Please sign in to comment.