From 05fbddbb3852122202b00baf10dba99948be469b Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 9 Oct 2025 23:45:15 +0900 Subject: [PATCH 1/4] bundle pg on all envs --- Gemfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 571f914..b0b0c90 100644 --- a/Gemfile +++ b/Gemfile @@ -8,8 +8,7 @@ gem "rails", "~> 7.1.3", ">= 7.1.3.4" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" -# Use sqlite3 as the database for Active Record -gem "sqlite3", "~> 1.4" +gem 'pg' # Use the Puma web server [https://github.com/puma/puma] gem "puma", ">= 5.0" @@ -68,8 +67,4 @@ group :test do gem 'simplecov' end -group :production do - gem 'pg' -end - gem 'aws-sdk-s3', '~> 1' From 7183f0438e8247d1dc9da19d9d49540f8232fc04 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 10 Oct 2025 03:17:25 +0900 Subject: [PATCH 2/4] Configure postgres DB --- config/database.yml | 73 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/config/database.yml b/config/database.yml index 796466b..21d17a8 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,68 @@ -# 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 + 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: storage/development.sqlite3 + database: blade_ruby_lang_org_development + + #username: blade_ruby_lang_org + #password: + + #host: localhost + #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: storage/test.sqlite3 + database: blade_ruby_lang_org_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 or a full connection URL as an environment +# variable when you boot the app. For example: +# +# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" +# +# If the connection URL is provided in the special DATABASE_URL environment +# variable, Rails will automatically merge its configuration values on top of +# the values provided in this file. Alternatively, you can specify a connection +# URL environment variable explicitly: +# +# production: +# url: <%= ENV["MY_APP_DATABASE_URL"] %> +# +# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full overview on how database connection configuration can be specified. +# production: - <<: *default - database: storage/production.sqlite3 + primary: &primary_production + <<: *default + database: blade_ruby_lang_org_production + username: blade_ruby_lang_org + password: <%= ENV["R81_PG_DATABASE_PASSWORD"] %> + cache: + <<: *primary_production + database: blade_ruby_lang_org_production_cache + migrations_paths: db/cache_migrate + queue: + <<: *primary_production + database: blade_ruby_lang_org_production_queue + migrations_paths: db/queue_migrate + cable: + <<: *primary_production + database: blade_ruby_lang_org_production_cable + migrations_paths: db/cable_migrate From c892878c44674a2c452b22f3c5399a9fbf43cb52 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 11 Oct 2025 02:45:14 +0900 Subject: [PATCH 3/4] bundle u --- Gemfile.lock | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ee3ae4e..2a95dff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -298,11 +298,6 @@ GEM actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - sqlite3 (1.7.3-aarch64-linux) - sqlite3 (1.7.3-arm-linux) - sqlite3 (1.7.3-arm64-darwin) - sqlite3 (1.7.3-x86_64-darwin) - sqlite3 (1.7.3-x86_64-linux) stimulus-rails (1.3.4) railties (>= 6.0.0) stringio (3.1.7) @@ -359,7 +354,6 @@ DEPENDENCIES selenium-webdriver simplecov sprockets-rails - sqlite3 (~> 1.4) stimulus-rails turbo-rails tzinfo-data From cb4da681372116266beb4417354e7ce84b9e8e0b Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 15 Oct 2025 21:49:07 +0900 Subject: [PATCH 4/4] rails db:migrate --- db/schema.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 0d0b529..8af5535 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,6 +11,10 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema[7.1].define(version: 2024_10_10_062050) do + # These are extensions that must be enabled in order to support this database + enable_extension "pg_trgm" + enable_extension "plpgsql" + create_table "messages", force: :cascade do |t| t.string "subject" t.string "from" @@ -19,8 +23,8 @@ t.datetime "updated_at", null: false t.integer "list_id" t.integer "list_seq" - t.datetime "published_at", precision: nil - t.index ["body"], name: "index_messages_on_body" + t.timestamptz "published_at" + t.index ["body"], name: "index_messages_on_body", opclass: :gin_trgm_ops, using: :gin t.index ["list_id", "list_seq"], name: "index_messages_on_list_id_and_list_seq", unique: true end