diff --git a/Gemfile b/Gemfile index 0026f33..03f3feb 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,8 @@ ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.3', '>= 6.0.3.1' -# Use sqlite3 as the database for Active Record -gem 'sqlite3', '~> 1.4' +# Use pg as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 4.1' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index d94e19f..6973759 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,6 +101,7 @@ GEM nio4r (2.5.2) nokogiri (1.10.9) mini_portile2 (~> 2.4.0) + pg (1.2.3) public_suffix (4.0.5) puma (4.3.5) nio4r (~> 2.0) @@ -165,7 +166,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) @@ -203,13 +203,13 @@ DEPENDENCIES capybara (>= 2.15) jbuilder (~> 2.7) listen (~> 3.2) + pg (>= 0.18, < 2.0) puma (~> 4.1) rails (~> 6.0.3, >= 6.0.3.1) sass-rails (>= 6) selenium-webdriver spring spring-watcher-listen (~> 2.0.0) - sqlite3 (~> 1.4) turbolinks (~> 5) tzinfo-data web-console (>= 3.3.0) diff --git a/config/application.rb b/config/application.rb index d2b6eaa..6cf3203 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,5 +28,9 @@ class Application < Rails::Application # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading # the framework and any gems in your application. + + config.generators do |g| + g.orm :active_record, primary_key_type: :uuid + end end end diff --git a/config/database.yml b/config/database.yml index 4a8a1b2..7193169 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,85 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 +# PostgreSQL. Versions 9.3 and up are supported. # -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' +# Install the pg driver: +# gem install pg +# On macOS with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On macOS 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' # default: &default - adapter: sqlite3 + adapter: postgresql + encoding: unicode + # 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 + database: roam_on_rails_development + + # 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: roam_on_rails + + # 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. test: <<: *default - database: db/test.sqlite3 + database: roam_on_rails_test +# As with config/credentials.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 https://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: <<: *default - database: db/production.sqlite3 + database: roam_on_rails_production + username: roam_on_rails + password: <%= ENV['ROAM_ON_RAILS_DATABASE_PASSWORD'] %> diff --git a/db/migrate/20200613070621_enable_uuid.rb b/db/migrate/20200613070621_enable_uuid.rb new file mode 100644 index 0000000..a875a27 --- /dev/null +++ b/db/migrate/20200613070621_enable_uuid.rb @@ -0,0 +1,5 @@ +class EnableUuid < ActiveRecord::Migration[6.0] + def change + enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto') + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..eca4333 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,19 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `rails +# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_13_070621) do + + # These are extensions that must be enabled in order to support this database + enable_extension "pgcrypto" + enable_extension "plpgsql" + +end