Skip to content

Commit a1d8b27

Browse files
committed
Remove channel index since we use channel_hash now
1 parent c75d007 commit a1d8b27

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎lib/generators/solid_cable/install/templates/db/cable_schema.rb‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
t.binary "payload", limit: 536870912, null: false
55
t.datetime "created_at", null: false
66
t.integer "channel_hash", limit: 8, null: false
7-
t.index ["channel"], name: "index_solid_cable_messages_on_channel"
87
t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
98
t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
109
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveChannelIndex < ActiveRecord::Migration[7.2]
4+
def up
5+
remove_index :solid_cable_messages, :channel, if_exists: true
6+
end
7+
8+
def down
9+
add_index :solid_cable_messages, :channel, if_not_exists: true
10+
end
11+
end

‎lib/generators/solid_cable/update/update_generator.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ class SolidCable::UpdateGenerator < Rails::Generators::Base
1111
def copy_files
1212
migration_template "db/migrate/create_compact_channel.rb",
1313
"db/cable_migrate/create_compact_channel.rb"
14+
migration_template "db/migrate/remove_channel_index.rb",
15+
"db/cable_migrate/remove_channel_index.rb"
1416
end
1517
end

‎test/lib/generators/solid_cable/update/update_generator_test.rb‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ class SolidCable::UpdateGeneratorTest < Rails::Generators::TestCase
88
setup :prepare_destination
99
setup :run_generator
1010

11-
test "cable_schema exists" do
11+
test "compact_channel migration exists" do
1212
assert_migration "db/cable_migrate/create_compact_channel.rb"
1313
end
14+
15+
test "channel index removal migration exists" do
16+
assert_migration "db/cable_migrate/remove_channel_index.rb"
17+
end
1418
end

0 commit comments

Comments
 (0)