From ecffd073443bd2f6468a89c7c294ab8ae337fc58 Mon Sep 17 00:00:00 2001 From: Yuki Date: Tue, 21 Apr 2015 06:42:11 +0530 Subject: [PATCH 1/4] Support for post subscriptions --- Rakefile | 56 ++++++++++++++++++- .../javascripts/answerbox/comment.coffee | 3 + .../javascripts/answerbox/subscribe.coffee | 27 +++++++++ .../ajax/subscription_controller.rb | 19 +++++++ app/helpers/subscribe_helper.rb | 2 + app/models/answer.rb | 5 +- app/models/comment.rb | 7 ++- app/models/subscription.rb | 48 ++++++++++++++++ app/models/user.rb | 2 + .../ajax/subscription/subscribe.json.jbuilder | 1 + .../subscription/unsubscribe.json.jbuilder | 1 + .../notifications/_notification.html.haml | 10 +++- app/views/shared/_answerbox_buttons.html.haml | 13 ++++- config/routes.rb | 2 + .../20150420232305_create_subscriptions.rb | 10 ++++ spec/controllers/subscribe_controller_spec.rb | 5 ++ spec/helpers/subscribe_helper_spec.rb | 15 +++++ spec/models/subscription_spec.rb | 5 ++ 18 files changed, 223 insertions(+), 8 deletions(-) create mode 100644 app/assets/javascripts/answerbox/subscribe.coffee create mode 100644 app/controllers/ajax/subscription_controller.rb create mode 100644 app/helpers/subscribe_helper.rb create mode 100644 app/models/subscription.rb create mode 100644 app/views/ajax/subscription/subscribe.json.jbuilder create mode 100644 app/views/ajax/subscription/unsubscribe.json.jbuilder create mode 100644 db/migrate/20150420232305_create_subscriptions.rb create mode 100644 spec/controllers/subscribe_controller_spec.rb create mode 100644 spec/helpers/subscribe_helper_spec.rb create mode 100644 spec/models/subscription_spec.rb diff --git a/Rakefile b/Rakefile index 9f233c58..5ee06a1a 100644 --- a/Rakefile +++ b/Rakefile @@ -198,6 +198,45 @@ namespace :justask do puts "Purged #{destroyed_count} dead notifications." end + desc "Subscribes everyone to their answers" + task fix_submarines: :enviornment do + format = '%t (%c/%C) [%b>%i] %e' + + total = Answer.count + progress = ProgressBar.create title: 'Processing answers', format: format, starting_at: 0, total: total + subscribed = 0 + + Answer.all.each do |a| + if not s.user.nil? and not s.answer.nil? + Subscription.subscribe a.user, a + subscribed += 1 + end + + progress.increment + end + + puts "Subscribed to #{subscribed} posts." + end + + desc "Destroy lost subscriptions" + task fix_torpedoes: :enviornment do + format = '%t (%c/%C) [%b>%i] %e' + + total = Subscription.count + progress = ProgressBar.create title: 'Processing subscriptions', format: format, starting_at: 0, total: total + destroyed = 0 + Subscription.all.each do |s| + if s.user.nil? or s.answer.nil? + s.destroy + destroyed += 1 + end + + progress.increment + end + + puts "Put #{destroyed} subscriptions up for adoption." + end + desc "Fixes everything else" task fix_db: :environment do format = '%t (%c/%C) [%b>%i] %e' @@ -206,7 +245,8 @@ namespace :justask do question: 0, answer: 0, smile: 0, - comment: 0 + comment: 0, + subscription: 0 } total = Inbox.count @@ -250,10 +290,24 @@ namespace :justask do progress.increment end + total = Subscription.count + progress = ProgressBar.create title: 'Processing subscriptions', format: format, starting_at: 0, total: total + Subscription.all.each do |s| + if s.user.nil? or s.answer.nil? + s.destroy + destroyed_count[:subscription] += 1 + end + + progress.increment + end + + puts "Put #{destroyed} subscriptions up for adoption." + puts "Purged #{destroyed_count[:inbox]} dead inbox entries." puts "Marked #{destroyed_count[:question]} questions as anonymous." puts "Purged #{destroyed_count[:answer]} dead answers." puts "Purged #{destroyed_count[:answer]} dead comments." + puts "Purged #{destroyed_count[:subscription]} dead subscriptions." end desc "Prints lonely people." diff --git a/app/assets/javascripts/answerbox/comment.coffee b/app/assets/javascripts/answerbox/comment.coffee index 996d5ff3..f81de95a 100644 --- a/app/assets/javascripts/answerbox/comment.coffee +++ b/app/assets/javascripts/answerbox/comment.coffee @@ -39,6 +39,9 @@ $(document).on "keyup", "input[name=ab-comment-new]", (evt) -> input.val '' ctr.html 160 $("span#ab-comment-count-#{aid}").html data.count + subs = $("a[data-action=ab-submarine][data-a-id=#{aid}]")[0] + subs.dataset.torpedo = "no" + subs.children[0].nextSibling.textContent = "Unsubscribe" showNotification data.message, data.success error: (jqxhr, status, error) -> console.log jqxhr, status, error diff --git a/app/assets/javascripts/answerbox/subscribe.coffee b/app/assets/javascripts/answerbox/subscribe.coffee new file mode 100644 index 00000000..4c937dd4 --- /dev/null +++ b/app/assets/javascripts/answerbox/subscribe.coffee @@ -0,0 +1,27 @@ +# the laziest coding known to man +$(document).on "click", "a[data-action=ab-submarine]", (ev) -> + ev.preventDefault() + btn = $(this) + aid = btn[0].dataset.aId + torpedo = 0 + if btn[0].dataset.torpedo == "yes" + torpedo = 1 + endpoint = "subscribe" + if torpedo == 0 + endpoint = "un" + endpoint + $.ajax + url: '/ajax/' + endpoint # TODO: find a way to use rake routes instead of hardcoding them here + type: 'POST' + data: + answer: aid + success: (data, status, jqxhr) -> + if data.success + btn[0].dataset.torpedo = ["yes", "no"][torpedo] + btn[0].children[0].nextSibling.textContent = ["Subscribe", "Unsubscribe"][torpedo] + showNotification "Successfully " + endpoint + "d.", true + else + showNotification "Couldn't unsubscribe from the answer.", false + error: (jqxhr, status, error) -> + console.log jqxhr, status, error + showNotification "An error occurred, a developer should check the console for details", false + complete: (jqxhr, status) -> diff --git a/app/controllers/ajax/subscription_controller.rb b/app/controllers/ajax/subscription_controller.rb new file mode 100644 index 00000000..9b07b0c5 --- /dev/null +++ b/app/controllers/ajax/subscription_controller.rb @@ -0,0 +1,19 @@ +class Ajax::SubscriptionController < ApplicationController + before_filter :authenticate_user! + + def subscribe + params.require :answer + @status = 418 + @message = "418 I'm a torpedo" + state = Subscription.subscribe(current_user, Answer.find(params[:answer])).nil? + @success = state == false + end + + def unsubscribe + params.require :answer + @status = 418 + @message = "418 I'm a torpedo" + state = Subscription.unsubscribe(current_user, Answer.find(params[:answer])).nil? + @success = state == false + end +end diff --git a/app/helpers/subscribe_helper.rb b/app/helpers/subscribe_helper.rb new file mode 100644 index 00000000..e30187f5 --- /dev/null +++ b/app/helpers/subscribe_helper.rb @@ -0,0 +1,2 @@ +module SubscribeHelper +end diff --git a/app/models/answer.rb b/app/models/answer.rb index e346853b..b8af083c 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -3,11 +3,13 @@ class Answer < ActiveRecord::Base belongs_to :question has_many :comments, dependent: :destroy has_many :smiles, dependent: :destroy + has_many :subscriptions, dependent: :destroy after_create do Inbox.where(user: self.user, question: self.question).destroy_all Notification.notify self.question.user, self unless self.question.author_is_anonymous + Subscription.subscribe self.user, self self.user.increment! :answered_count self.question.increment! :answer_count end @@ -27,9 +29,10 @@ class Answer < ActiveRecord::Base end self.comments.each do |comment| comment.user.decrement! :commented_count - Notification.denotify self.user, comment + Subscription.denotify comment, self end Notification.denotify self.question.user, self + Subscription.destruct self end def notification_type(*_args) diff --git a/app/models/comment.rb b/app/models/comment.rb index cf5001a7..6cced397 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -7,14 +7,15 @@ class Comment < ActiveRecord::Base validates :content, length: { maximum: 160 } after_create do - Notification.notify answer.user, self unless answer.user == self.user + Subscription.subscribe self.user, answer + Subscription.notify self, answer user.increment! :commented_count answer.increment! :comment_count end before_destroy do - Notification.denotify answer.user, self unless answer.user == self.user - user.decrement! :commented_count + Subscription.denotify self, answer + user.decrement! :commented_count answer.decrement! :comment_count end diff --git a/app/models/subscription.rb b/app/models/subscription.rb new file mode 100644 index 00000000..8a39ccad --- /dev/null +++ b/app/models/subscription.rb @@ -0,0 +1,48 @@ +class Subscription < ActiveRecord::Base + belongs_to :user + belongs_to :answer + + class << self + def subscribe(recipient, target) + if Subscription.find_by(user: recipient, answer: target).nil? + Subscription.new(user: recipient, answer: target).save! + end + end + + def unsubscribe(recipient, target) + if recipient.nil? or target.nil? + return nil + end + + subs = Subscription.find_by(user: recipient, answer: target) + subs.destroy unless subs.nil? + end + + def destruct(target) + if target.nil? + return nil + end + Subscription.where(answer: target).destroy_all + end + + def notify(source, target) + if source.nil? or target.nil? + return nil + end + + Subscription.where(answer: target).each do |subs| + next unless not subs.user == source.user + Notification.notify subs.user, source + end + end + + def denotify(source, target) + if source.nil? or target.nil? + return nil + end + Subscription.where(answer: target).each do |subs| + Notification.denotify subs.user, source + end + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 0bd4e492..01a1e6e2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,6 +28,8 @@ class User < ActiveRecord::Base has_many :groups, dependent: :destroy has_many :group_memberships, class_name: "GroupMember", foreign_key: 'user_id', dependent: :destroy + has_many :subscriptions, dependent: :destroy + SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/ WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i diff --git a/app/views/ajax/subscription/subscribe.json.jbuilder b/app/views/ajax/subscription/subscribe.json.jbuilder new file mode 100644 index 00000000..f98b3c38 --- /dev/null +++ b/app/views/ajax/subscription/subscribe.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'ajax/shared/status' diff --git a/app/views/ajax/subscription/unsubscribe.json.jbuilder b/app/views/ajax/subscription/unsubscribe.json.jbuilder new file mode 100644 index 00000000..f98b3c38 --- /dev/null +++ b/app/views/ajax/subscription/unsubscribe.json.jbuilder @@ -0,0 +1 @@ +json.partial! 'ajax/shared/status' diff --git a/app/views/notifications/_notification.html.haml b/app/views/notifications/_notification.html.haml index efc508f6..eed4e08e 100644 --- a/app/views/notifications/_notification.html.haml +++ b/app/views/notifications/_notification.html.haml @@ -53,9 +53,15 @@ %p.notification--text commented on %a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id), title: "#{notification.target.answer.content[0..40]}...", data: { toggle: :tooltip, placement: :top }} - your answer + - if notification.target.answer.user == current_user + your + - elsif notification.target.user == notification.target.answer.user + their + - else + = user_screen_name(notification.target.answer.user, false, false) + "'s" + answer %span{title: notification.target.created_at, data: { toggle: :tooltip, placement: :bottom }} = time_ago_in_words notification.target.created_at ago .notification--icon - %i.fa.fa-comments \ No newline at end of file + %i.fa.fa-comments diff --git a/app/views/shared/_answerbox_buttons.html.haml b/app/views/shared/_answerbox_buttons.html.haml index bfde2a68..28b15ead 100644 --- a/app/views/shared/_answerbox_buttons.html.haml +++ b/app/views/shared/_answerbox_buttons.html.haml @@ -21,6 +21,17 @@ %button.btn.btn-default.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} %span.caret %ul.dropdown-menu.dropdown-menu-right{role: :menu} + - if a.subscriptions.find_by(user: current_user) + %li + -# fun joke should subscribe? + %a{href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: "no" }} + %i.fa.fa-anchor + Unubscribe + - else + %li + %a{href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: "yes" }} + %i.fa.fa-anchor + Subscribe - if privileged? a.user %li.text-danger %a{href: '#', data: { a_id: a.id, action: 'ab-destroy' }} @@ -30,4 +41,4 @@ %li %a{href: '#', data: { a_id: a.id, action: 'ab-report' }} %i.fa.fa-exclamation-triangle - Report \ No newline at end of file + Report diff --git a/config/routes.rb b/config/routes.rb index d4af3769..475b516a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -82,6 +82,8 @@ Rails.application.routes.draw do match '/destroy_group', to: 'group#destroy', via: :post, as: :destroy_group match '/group_membership', to: 'group#membership', via: :post, as: :group_membership match '/preview', to: "question#preview", via: :post, as: :preview + match '/subscribe', to: 'subscription#subscribe', via: :post, as: :subscribe_answer + match '/unsubscribe', to: 'subscription#unsubscribe', via: :post, as: :unsubscribe_answer end match '/public', to: 'public#index', via: :get, as: :public_timeline diff --git a/db/migrate/20150420232305_create_subscriptions.rb b/db/migrate/20150420232305_create_subscriptions.rb new file mode 100644 index 00000000..0fc970cb --- /dev/null +++ b/db/migrate/20150420232305_create_subscriptions.rb @@ -0,0 +1,10 @@ +class CreateSubscriptions < ActiveRecord::Migration + def change + create_table :subscriptions do |t| + t.integer :user_id, null: false + t.integer :answer_id, null: false + + t.timestamps null: false + end + end +end diff --git a/spec/controllers/subscribe_controller_spec.rb b/spec/controllers/subscribe_controller_spec.rb new file mode 100644 index 00000000..0afc3489 --- /dev/null +++ b/spec/controllers/subscribe_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SubscribeController, :type => :controller do + +end diff --git a/spec/helpers/subscribe_helper_spec.rb b/spec/helpers/subscribe_helper_spec.rb new file mode 100644 index 00000000..cb8dc23c --- /dev/null +++ b/spec/helpers/subscribe_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the SubscribeHelper. For example: +# +# describe SubscribeHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe SubscribeHelper, :type => :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/subscription_spec.rb b/spec/models/subscription_spec.rb new file mode 100644 index 00000000..2c8d59e9 --- /dev/null +++ b/spec/models/subscription_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Subscription, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 1c485b20e9998e04f6657e8843082bacd57013e1 Mon Sep 17 00:00:00 2001 From: Yuki Date: Tue, 21 Apr 2015 06:58:35 +0530 Subject: [PATCH 2/4] Subscribe asker to the answer --- app/models/answer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/answer.rb b/app/models/answer.rb index b8af083c..83b82918 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -10,6 +10,7 @@ class Answer < ActiveRecord::Base Notification.notify self.question.user, self unless self.question.author_is_anonymous Subscription.subscribe self.user, self + Subscription.subscribe self.question.user, self self.user.increment! :answered_count self.question.increment! :answer_count end From 8eeae22c437bf774731ea59716c525841375e8f3 Mon Sep 17 00:00:00 2001 From: Yuki Date: Tue, 21 Apr 2015 17:52:32 +0530 Subject: [PATCH 3/4] Don't resubscribe if a user unsubscribes and comments again --- app/models/comment.rb | 2 +- app/models/subscription.rb | 29 +++++++-- app/views/shared/_answerbox_buttons.html.haml | 2 +- ...21120557_add_is_active_to_subscriptions.rb | 5 ++ db/schema.rb | 64 ++++++++++++++++++- 5 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20150421120557_add_is_active_to_subscriptions.rb diff --git a/app/models/comment.rb b/app/models/comment.rb index 6cced397..ca8f4087 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -7,7 +7,7 @@ class Comment < ActiveRecord::Base validates :content, length: { maximum: 160 } after_create do - Subscription.subscribe self.user, answer + Subscription.subscribe self.user, answer, false Subscription.notify self, answer user.increment! :commented_count answer.increment! :comment_count diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 8a39ccad..bd250772 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -3,9 +3,21 @@ class Subscription < ActiveRecord::Base belongs_to :answer class << self - def subscribe(recipient, target) - if Subscription.find_by(user: recipient, answer: target).nil? + def for(target) + Subscription.where(answer: target) + end + + def is_subscribed(recipient, target) + existing = Subscription.find_by(user: recipient, answer: target) + existing.nil? or existing.is_active + end + + def subscribe(recipient, target, force = true) + existing = Subscription.find_by(user: recipient, answer: target) + if existing.nil? Subscription.new(user: recipient, answer: target).save! + elsif force + existing.update(is_active: true) end end @@ -15,7 +27,7 @@ class Subscription < ActiveRecord::Base end subs = Subscription.find_by(user: recipient, answer: target) - subs.destroy unless subs.nil? + subs.update(is_active: false) unless subs.nil? end def destruct(target) @@ -25,12 +37,21 @@ class Subscription < ActiveRecord::Base Subscription.where(answer: target).destroy_all end + def destruct_by(recipient, target) + if recipient.nil? or target.nil? + return nil + end + + subs = Subscription.find_by(user: recipient, answer: target) + subs.destroy unless subs.nil? + end + def notify(source, target) if source.nil? or target.nil? return nil end - Subscription.where(answer: target).each do |subs| + Subscription.where(answer: target, is_active: true).each do |subs| next unless not subs.user == source.user Notification.notify subs.user, source end diff --git a/app/views/shared/_answerbox_buttons.html.haml b/app/views/shared/_answerbox_buttons.html.haml index 28b15ead..1daa1f2a 100644 --- a/app/views/shared/_answerbox_buttons.html.haml +++ b/app/views/shared/_answerbox_buttons.html.haml @@ -21,7 +21,7 @@ %button.btn.btn-default.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} %span.caret %ul.dropdown-menu.dropdown-menu-right{role: :menu} - - if a.subscriptions.find_by(user: current_user) + - if Subscription.is_subscribed(current_user, a) %li -# fun joke should subscribe? %a{href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: "no" }} diff --git a/db/migrate/20150421120557_add_is_active_to_subscriptions.rb b/db/migrate/20150421120557_add_is_active_to_subscriptions.rb new file mode 100644 index 00000000..afdfc81e --- /dev/null +++ b/db/migrate/20150421120557_add_is_active_to_subscriptions.rb @@ -0,0 +1,5 @@ +class AddIsActiveToSubscriptions < ActiveRecord::Migration + def change + add_column :subscriptions, :is_active, :boolean, default: :true + end +end diff --git a/db/schema.rb b/db/schema.rb index 4e3d67ca..a60c6040 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: 20150419201122) do +ActiveRecord::Schema.define(version: 20150421120557) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -101,6 +101,49 @@ ActiveRecord::Schema.define(version: 20150419201122) do t.datetime "updated_at" end + create_table "oauth_access_grants", force: :cascade do |t| + t.integer "resource_owner_id", null: false + t.integer "application_id", null: false + t.string "token", null: false + t.integer "expires_in", null: false + t.text "redirect_uri", null: false + t.datetime "created_at", null: false + t.datetime "revoked_at" + t.string "scopes" + end + + add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree + + create_table "oauth_access_tokens", force: :cascade do |t| + t.integer "resource_owner_id" + t.integer "application_id" + t.string "token", null: false + t.string "refresh_token" + t.integer "expires_in" + t.datetime "revoked_at" + t.datetime "created_at", null: false + t.string "scopes" + end + + add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree + add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree + add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree + + create_table "oauth_applications", force: :cascade do |t| + t.string "name", null: false + t.string "uid", null: false + t.string "secret", null: false + t.text "redirect_uri", null: false + t.string "scopes", default: "", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "owner_id" + t.string "owner_type" + end + + add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree + add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree + create_table "questions", force: :cascade do |t| t.string "content" t.boolean "author_is_anonymous" @@ -156,6 +199,25 @@ ActiveRecord::Schema.define(version: 20150419201122) do add_index "smiles", ["user_id", "answer_id"], name: "index_smiles_on_user_id_and_answer_id", unique: true, using: :btree add_index "smiles", ["user_id"], name: "index_smiles_on_user_id", using: :btree + create_table "subscriptions", force: :cascade do |t| + t.integer "user_id" + t.integer "answer_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "is_active", default: true + end + + create_table "user_themes", force: :cascade do |t| + t.integer "user_id" + t.string "bg", default: "#fafafa" + t.string "color", default: "#5e35b1" + t.string "color_a", default: "#5e35b1" + t.string "color_alt", default: "#eeeeee" + t.string "bg_primary", default: "#5e35b1" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false From f6b6bb9c546f65bc52a568eb65196cbf0cb6daa4 Mon Sep 17 00:00:00 2001 From: Yuki Date: Tue, 21 Apr 2015 17:54:25 +0530 Subject: [PATCH 4/4] revert schema --- db/schema.rb | 64 +--------------------------------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index a60c6040..4e3d67ca 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: 20150421120557) do +ActiveRecord::Schema.define(version: 20150419201122) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -101,49 +101,6 @@ ActiveRecord::Schema.define(version: 20150421120557) do t.datetime "updated_at" end - create_table "oauth_access_grants", force: :cascade do |t| - t.integer "resource_owner_id", null: false - t.integer "application_id", null: false - t.string "token", null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", null: false - t.datetime "revoked_at" - t.string "scopes" - end - - add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree - - create_table "oauth_access_tokens", force: :cascade do |t| - t.integer "resource_owner_id" - t.integer "application_id" - t.string "token", null: false - t.string "refresh_token" - t.integer "expires_in" - t.datetime "revoked_at" - t.datetime "created_at", null: false - t.string "scopes" - end - - add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree - add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree - add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree - - create_table "oauth_applications", force: :cascade do |t| - t.string "name", null: false - t.string "uid", null: false - t.string "secret", null: false - t.text "redirect_uri", null: false - t.string "scopes", default: "", null: false - t.datetime "created_at" - t.datetime "updated_at" - t.integer "owner_id" - t.string "owner_type" - end - - add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree - add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree - create_table "questions", force: :cascade do |t| t.string "content" t.boolean "author_is_anonymous" @@ -199,25 +156,6 @@ ActiveRecord::Schema.define(version: 20150421120557) do add_index "smiles", ["user_id", "answer_id"], name: "index_smiles_on_user_id_and_answer_id", unique: true, using: :btree add_index "smiles", ["user_id"], name: "index_smiles_on_user_id", using: :btree - create_table "subscriptions", force: :cascade do |t| - t.integer "user_id" - t.integer "answer_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "is_active", default: true - end - - create_table "user_themes", force: :cascade do |t| - t.integer "user_id" - t.string "bg", default: "#fafafa" - t.string "color", default: "#5e35b1" - t.string "color_a", default: "#5e35b1" - t.string "color_alt", default: "#eeeeee" - t.string "bg_primary", default: "#5e35b1" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false