Skip to content

Commit

Permalink
Fix irreversible upgrade migration (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoyoussef authored Oct 12, 2024
1 parent 3897956 commit cd8e0c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion bench/db/migrate/20240912235943_create_compact_channel.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class CreateCompactChannel < ActiveRecord::Migration[7.2]
def change
def up
change_column :solid_cable_messages, :channel, :binary, limit: 1024, null: false
add_column :solid_cable_messages, :channel_hash, :integer, limit: 8, if_not_exists: true
add_index :solid_cable_messages, :channel_hash, if_not_exists: true
Expand All @@ -12,4 +12,10 @@ def change
msg.update(channel_hash: SolidCable::Message.channel_hash_for(msg.channel))
end
end

def down
change_column :solid_cable_messages, :channel, :text
remove_column :solid_cable_messages, :channel_hash, if_exists: true
change_column :solid_cable_messages, :payload, :text
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class CreateCompactChannel < ActiveRecord::Migration[7.2]
def change
def up
change_column :solid_cable_messages, :channel, :binary, limit: 1024, null: false
add_column :solid_cable_messages, :channel_hash, :integer, limit: 8, if_not_exists: true
add_index :solid_cable_messages, :channel_hash, if_not_exists: true
Expand All @@ -11,4 +11,10 @@ def change
msg.update(channel_hash: SolidCable::Message.channel_hash_for(msg.channel))
end
end

def down
change_column :solid_cable_messages, :channel, :text
remove_column :solid_cable_messages, :channel_hash, if_exists: true
change_column :solid_cable_messages, :payload, :text
end
end

0 comments on commit cd8e0c9

Please sign in to comment.