From 8eb607261278eae52c4008067387ac8ad09b9224 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Fri, 27 Jun 2025 21:26:29 -0400 Subject: [PATCH] Take 2 of switching to psql cache! --- config/database.yml | 6 +++--- .../20250628011017_create_solid_cache_entries.rb | 15 +++++++++++++++ db/schema.rb | 13 ++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20250628011017_create_solid_cache_entries.rb diff --git a/config/database.yml b/config/database.yml index 71f55bd..8176b4b 100644 --- a/config/database.yml +++ b/config/database.yml @@ -104,9 +104,9 @@ production: replica: true cache: <<: *default - adapter: sqlite3 - database: storage/production_cache.sqlite3 - migrations_paths: db/cache_migrate + adapter: postgresql + encoding: unicode + url: <%= ENV['DATABASE_URL'] %> cable: <<: *default adapter: sqlite3 diff --git a/db/migrate/20250628011017_create_solid_cache_entries.rb b/db/migrate/20250628011017_create_solid_cache_entries.rb new file mode 100644 index 0000000..80eed65 --- /dev/null +++ b/db/migrate/20250628011017_create_solid_cache_entries.rb @@ -0,0 +1,15 @@ +class CreateSolidCacheEntries < ActiveRecord::Migration[8.0] + def change + create_table :solid_cache_entries do |t| + t.binary :key, limit: 1024, null: false + t.binary :value, limit: 536870912, null: false + t.datetime :created_at, null: false + t.integer :key_hash, limit: 8, null: false + t.integer :byte_size, limit: 4, null: false + + t.index :byte_size + t.index [ :key_hash, :byte_size ] + t.index :key_hash, unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d06484c..e2c9de7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_06_26_001500) do +ActiveRecord::Schema[8.0].define(version: 2025_06_28_011017) do create_schema "pganalyze" # These are extensions that must be enabled in order to support this database @@ -472,6 +472,17 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_26_001500) do t.index ["user_id"], name: "index_sign_in_tokens_on_user_id" end + create_table "solid_cache_entries", force: :cascade do |t| + t.binary "key", null: false + t.binary "value", null: false + t.datetime "created_at", null: false + t.bigint "key_hash", null: false + t.integer "byte_size", null: false + t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size" + t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size" + t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true + end + create_table "users", force: :cascade do |t| t.string "slack_uid" t.datetime "created_at", null: false