From 3a547de909df6894fadec97379d2d103e96d6e5c Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Tue, 1 Aug 2023 12:14:47 -0700 Subject: [PATCH] fix: Update the default status of the hooks to enabled (#7652) 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. --- app/models/integrations/hook.rb | 2 +- ...0801180936_update_default_status_in_hooks.rb | 17 +++++++++++++++++ db/schema.rb | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20230801180936_update_default_status_in_hooks.rb diff --git a/app/models/integrations/hook.rb b/app/models/integrations/hook.rb index 57d052584..9d80b245b 100644 --- a/app/models/integrations/hook.rb +++ b/app/models/integrations/hook.rb @@ -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 diff --git a/db/migrate/20230801180936_update_default_status_in_hooks.rb b/db/migrate/20230801180936_update_default_status_in_hooks.rb new file mode 100644 index 000000000..c6388a34c --- /dev/null +++ b/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 diff --git a/db/schema.rb b/db/schema.rb index 13d5e6925..759c0d325 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" @@ -604,7 +604,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_27_065605) do 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"