diff --git a/app/models/webhook_endpoint.rb b/app/models/webhook_endpoint.rb new file mode 100644 index 0000000000..8626e11b93 --- /dev/null +++ b/app/models/webhook_endpoint.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +# Records a webhook url to send notifications to +class WebhookEndpoint < ApplicationRecord + validates :url, presence: true +end diff --git a/db/migrate/20221028051650_create_webhook_endpoints.rb b/db/migrate/20221028051650_create_webhook_endpoints.rb new file mode 100644 index 0000000000..034d1141d2 --- /dev/null +++ b/db/migrate/20221028051650_create_webhook_endpoints.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class CreateWebhookEndpoints < ActiveRecord::Migration[6.1] + def change + create_table :webhook_endpoints do |t| + t.string :url, null: false + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 77975612f5..d28ee2ba80 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1189,6 +1189,12 @@ ActiveRecord::Schema.define(version: 2023_02_13_160135) do t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id" end + create_table "webhook_endpoints", force: :cascade do |t| + t.string "url", null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "adjustment_metadata", "enterprises", name: "adjustment_metadata_enterprise_id_fk" diff --git a/spec/models/webhook_endpoint_spec.rb b/spec/models/webhook_endpoint_spec.rb new file mode 100644 index 0000000000..5f1d630f09 --- /dev/null +++ b/spec/models/webhook_endpoint_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe WebhookEndpoint, type: :model do + describe "validations" do + it { is_expected.to validate_presence_of(:url) } + end +end