Skip to content

Commit

Permalink
fix: Update the default status of the hooks to enabled (#7652)
Browse files Browse the repository at this point in the history
In the recent Slack integration update, we made changes to how hooks are handled. Now, hooks require an additional check to be enabled. By default, new hooks are created in a disabled state, which might lead to issues with the hooks not being executed as expected.

This migration updates the status attribute of hooks to have 'enabled' as the default value, ensuring that new hooks are enabled by default and can function properly.
  • Loading branch information
pranavrajs committed Aug 1, 2023
1 parent 62e9fc1 commit 3a547de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/integrations/hook.rb
Expand Up @@ -6,7 +6,7 @@
# access_token :string
# hook_type :integer default("account")
# settings :jsonb
# status :integer default("disabled")
# status :integer default("enabled")
# created_at :datetime not null
# updated_at :datetime not null
# account_id :integer
Expand Down
17 changes: 17 additions & 0 deletions db/migrate/20230801180936_update_default_status_in_hooks.rb
@@ -0,0 +1,17 @@
class UpdateDefaultStatusInHooks < ActiveRecord::Migration[7.0]
def up
change_column_default :integrations_hooks, :status, 1

update_default_status
end

def down
change_column_default :integrations_hooks, :status, 0
end

private

def update_default_status
Integrations::Hook.all.update(status: 'enabled')
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_07_27_065605) do
ActiveRecord::Schema[7.0].define(version: 2023_08_01_180936) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -604,7 +604,7 @@
end

create_table "integrations_hooks", force: :cascade do |t|
t.integer "status", default: 0
t.integer "status", default: 1
t.integer "inbox_id"
t.integer "account_id"
t.string "app_id"
Expand Down

0 comments on commit 3a547de

Please sign in to comment.