Change list of events to jsonb

This commit is contained in:
Eric Schultz 2021-02-18 14:25:07 -06:00 committed by Eric Schultz
parent 501cb23266
commit ff8420541e
3 changed files with 28 additions and 5 deletions

View file

@ -6,7 +6,7 @@ class ObjectEventHookConfig < ApplicationRecord
# :webhook_service, #str, webhook service to be called
# :configuration, #jsonb, configuration needed to connect to the webhook
# :object_event_types, #text (array), a set of object event types
# :object_event_types, #jsonb, must be an array
belongs_to :nonprofit
@ -14,8 +14,6 @@ class ObjectEventHookConfig < ApplicationRecord
validates :configuration, presence: true
validates :object_event_types, presence: true
serialize :object_event_types, Array
def webhook
Houdini::WebhookAdapter.build(webhook_service, configuration.symbolize_keys)
end

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
class ConvertListOfObjectEventTypesToJsonb < ActiveRecord::Migration[6.1]
def change
remove_column :object_event_hook_configs, :object_event_types, :text
add_column :object_event_hook_configs, :object_event_types, :jsonb, null: false, default: []
end
end

View file

@ -10,10 +10,11 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_02_09_181808) do
ActiveRecord::Schema.define(version: 2021_02_18_191002) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pgcrypto"
enable_extension "plpgsql"
enable_extension "uuid-ossp"
@ -463,6 +464,20 @@ ActiveRecord::Schema.define(version: 2021_02_09_181808) do
t.datetime "updated_at", null: false
end
create_table "good_jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "queue_name"
t.integer "priority"
t.jsonb "serialized_params"
t.datetime "scheduled_at"
t.datetime "performed_at"
t.datetime "finished_at"
t.text "error"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)"
t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)"
end
create_table "image_attachments", id: :serial, force: :cascade do |t|
t.string "file", limit: 255
t.integer "parent_id"
@ -578,10 +593,10 @@ ActiveRecord::Schema.define(version: 2021_02_09_181808) do
create_table "object_event_hook_configs", force: :cascade do |t|
t.string "webhook_service", null: false
t.jsonb "configuration", null: false
t.text "object_event_types", null: false
t.bigint "nonprofit_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.jsonb "object_event_types", default: [], null: false
t.index ["nonprofit_id"], name: "index_object_event_hook_configs_on_nonprofit_id"
end