Skip to content

Instantly share code, notes, and snippets.

@secretpray
Last active March 23, 2025 06:36
Show Gist options
  • Save secretpray/0574a94c71595be05846dca11aa1ff18 to your computer and use it in GitHub Desktop.
Save secretpray/0574a94c71595be05846dca11aa1ff18 to your computer and use it in GitHub Desktop.
Solid Cable in single database (Ruby on Rails 8)

Single Database Configuration steps:

rails g migration singlify_solid_cable (or whatever you want to call it)

Copy the contents of db/cable_schema.rb into the migration. Mine ended up looking like this:

class SinglifySolidCable < ActiveRecord::Migration[8.0]
  def change
    create_table "solid_cable_messages", force: :cascade do |t|
      t.binary "channel", limit: 1024, null: false
      t.binary "payload", limit: 536870912, null: false
      t.datetime "created_at", null: false
      t.integer "channel_hash", limit: 8, null: false
      t.index ["channel"], name: "index_solid_cable_messages_on_channel"
      t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
      t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
    end
  end
end

Delete db/cable_schema.rb.

Modify config/cable.yml to look like this:

development:
  adapter: solid_cable
  polling_interval: 0.1.seconds
  message_retention: 1.day

test:
  adapter: test

production:
  adapter: solid_cable
  polling_interval: 0.1.seconds
  message_retention: 1.day

Run

rails db/migrate

Restart any processes you have open

Original post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment