Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add webhooks db tables.

Sebastian Palma2e1c0abd773f
diff --git a/api/db/migrate/20210902162826_create_spree_webhooks_tables.rb b/api/db/migrate/20210902162826_create_spree_webhooks_tables.rb
new file mode 100644
index 0000000000..7301f6ddd3
--- /dev/null
+++ b/api/db/migrate/20210902162826_create_spree_webhooks_tables.rb
@@ -0,0 +1,30 @@
+class CreateSpreeWebhooksTables < ActiveRecord::Migration[6.1]
+ def change
+ create_table :spree_webhooks_events do |t|
+ t.text :name, null: false
+ t.boolean :enabled, default: true
+
+ t.timestamps
+ end
+
+ create_table :spree_webhooks_endpoints do |t|
+ t.text :url, null: false
+ t.boolean :enabled, default: true
+
+ create_subscriptions_column!(t)
+
+ t.timestamps
+ end
+ end
+
+ private
+
+ def create_subscriptions_column!(table)
+ case ActiveRecord::Base.connection.adapter_name
+ when 'Mysql2'
+ table.json :subscriptions
+ when 'PostgreSQL'
+ table.jsonb :subscriptions, default: ['*']
+ end
+ end
+end