diff --git a/.gitignore b/.gitignore index 7efe0bb..9d5ce0b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ /db/*.sqlite3 /db/*.sqlite3-journal +config/database.yml + # Ignore all logfiles and tempfiles. /log/* /tmp/* diff --git a/Gemfile b/Gemfile index 593b854..0c031a5 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ ruby '2.6.3' gem 'rails', '~> 6.0.3' # Use sqlite3 as the database for Active Record # Use Puma as the app server +gem 'pg', '~> 1.2' gem 'puma', '~> 4.1' # Use SCSS for stylesheets gem 'sass-rails', '>= 6' @@ -37,7 +38,6 @@ gem 'rails-controller-testing' gem 'bootsnap', '>= 1.4.2', require: false group :development, :test do - gem 'sqlite3', '~> 1.4' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: %i[mri mingw x64_mingw] end @@ -59,9 +59,5 @@ group :test do gem 'webdrivers' end -group :production do - gem 'pg' -end - # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 63e2f9d..032ecc1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,7 +228,7 @@ DEPENDENCIES jbuilder (~> 2.7) jquery-rails listen (>= 3.0.5, < 3.2) - pg + pg (~> 1.2) puma (~> 4.1) rails (~> 6.0.3) rails-controller-testing diff --git a/config/database.yml b/config/sample.database.yml similarity index 52% rename from config/database.yml rename to config/sample.database.yml index 1c1a37c..a1c6114 100644 --- a/config/database.yml +++ b/config/sample.database.yml @@ -1,25 +1,20 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' -# default: &default - adapter: sqlite3 - pool: 5 - timeout: 5000 + adapter: postgresql + encoding: unicode + host: <%= ENV['DATABASE_HOST'] || 'localhost' %> + port: <%= ENV['DATABASE_PORT'] || 5432 %> development: <<: *default - database: db/development.sqlite3 + database: alpha_blog_development # 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: alpha_blog_test production: <<: *default - database: db/production.sqlite3 + database: alpha_blog_production diff --git a/db/schema.rb b/db/schema.rb index 0a7c8e0..4974e8f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,6 +12,9 @@ ActiveRecord::Schema.define(version: 2020_05_14_200519) do + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + create_table "article_categories", force: :cascade do |t| t.integer "article_id" t.integer "category_id"