From bdba7686d3a4c2efab9dd67d3c81e60571a33c77 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Tue, 3 Dec 2019 13:03:10 +1100 Subject: [PATCH] add new table --- app/models/customer.rb | 2 +- .../20191203014808_create_subscriptions_customers.rb | 10 ++++++++++ spec/models/customer_spec.rb | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20191203014808_create_subscriptions_customers.rb diff --git a/app/models/customer.rb b/app/models/customer.rb index 118cce5..506ec64 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -5,7 +5,7 @@ module DiscoursePatrons scope :find_user, ->(user) { find_by_user_id(user.id) } class << self - table_name = "discourse_patrons_customers" + table_name = "discourse_subscriptions_customers" def create_customer(user, customer) create(customer_id: customer[:id], user_id: user.id) diff --git a/db/migrate/20191203014808_create_subscriptions_customers.rb b/db/migrate/20191203014808_create_subscriptions_customers.rb new file mode 100644 index 0000000..6254951 --- /dev/null +++ b/db/migrate/20191203014808_create_subscriptions_customers.rb @@ -0,0 +1,10 @@ +class CreateSubscriptionsCustomers < ActiveRecord::Migration[6.0] + def change + create_table :discourse_subscriptions_customers do |t| + t.string :customer_id, null: false + t.string :product_id + t.references :user, foreign_key: true + t.timestamps + end + end +end diff --git a/spec/models/customer_spec.rb b/spec/models/customer_spec.rb index 4070793..c27c6f5 100644 --- a/spec/models/customer_spec.rb +++ b/spec/models/customer_spec.rb @@ -8,7 +8,7 @@ module DiscoursePatrons let(:stripe_customer) { { id: 'cus_id4567' } } it "has a table name" do - expect(described_class.table_name).to eq "discourse_patrons_customers" + expect(described_class.table_name).to eq "discourse_subscriptions_customers" end it "creates" do