From 1ec58d3b7bfc94de19a52a170b9bc804cd9a51bb Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 20 Jan 2017 21:48:05 +0000 Subject: [PATCH] Model for subscriptions #migration --- app/models/subscription.rb | 4 ++++ db/migrate/20170120214721_create_subscriptions.rb | 12 ++++++++++++ db/schema.rb | 14 +++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/models/subscription.rb create mode 100644 db/migrate/20170120214721_create_subscriptions.rb diff --git a/app/models/subscription.rb b/app/models/subscription.rb new file mode 100644 index 00000000..ac9e48d0 --- /dev/null +++ b/app/models/subscription.rb @@ -0,0 +1,4 @@ +class Subscription < ActiveRecord::Base + belongs_to :user + belongs_to :billing_plan +end diff --git a/db/migrate/20170120214721_create_subscriptions.rb b/db/migrate/20170120214721_create_subscriptions.rb new file mode 100644 index 00000000..8037bfbf --- /dev/null +++ b/db/migrate/20170120214721_create_subscriptions.rb @@ -0,0 +1,12 @@ +class CreateSubscriptions < ActiveRecord::Migration + def change + create_table :subscriptions do |t| + t.references :user, index: true, foreign_key: true + t.references :billing_plan, index: true, foreign_key: true + t.datetime :start_date + t.datetime :end_date + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a9b54d23..1d9aefbd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170120214443) do +ActiveRecord::Schema.define(version: 20170120214721) do create_table "archenemyships", force: :cascade do |t| t.integer "user_id" @@ -615,6 +615,18 @@ ActiveRecord::Schema.define(version: 20170120214443) do t.integer "subgroup_id" end + create_table "subscriptions", force: :cascade do |t| + t.integer "user_id" + t.integer "billing_plan_id" + t.datetime "start_date" + t.datetime "end_date" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "subscriptions", ["billing_plan_id"], name: "index_subscriptions_on_billing_plan_id" + add_index "subscriptions", ["user_id"], name: "index_subscriptions_on_user_id" + create_table "supergroupships", force: :cascade do |t| t.integer "user_id" t.integer "group_id"