Skip to content

Commit

Permalink
Switch back to cookie_store for sessions
Browse files Browse the repository at this point in the history
Storing in database results in a giant table that needs pruning etc.
  • Loading branch information
fbacall committed Aug 1, 2024
1 parent 9dfc8a0 commit 186715c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
7 changes: 2 additions & 5 deletions config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Be sure to restart your server when you modify this file.

#Rails.application.config.session_store :cookie_store, key: '_tess_sessions'
Rails.application.config.session_store :active_record_store, key: '_tess_sessions', secure: Rails.env.production?


opts = Rails.env.production? ? { same_site: :strict, secure: true } : {}
Rails.application.config.session_store :cookie_store, **opts
16 changes: 16 additions & 0 deletions db/migrate/20240702175333_drop_sessions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class DropSessions < ActiveRecord::Migration[7.0]
def up
drop_table :sessions
end

def down
create_table :sessions do |t|
t.string :session_id, null: false
t.text :data
t.timestamps
end

add_index :sessions, :session_id, unique: true
add_index :sessions, :updated_at
end
end
9 changes: 0 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,6 @@
t.string "title"
end

create_table "sessions", force: :cascade do |t|
t.string "session_id", null: false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["session_id"], name: "index_sessions_on_session_id", unique: true
t.index ["updated_at"], name: "index_sessions_on_updated_at"
end

create_table "sources", force: :cascade do |t|
t.bigint "content_provider_id"
t.bigint "user_id"
Expand Down

0 comments on commit 186715c

Please sign in to comment.