diff --git a/Gemfile b/Gemfile index d730ac6e1..4fc40030f 100644 --- a/Gemfile +++ b/Gemfile @@ -116,6 +116,8 @@ group :development do gem 'binding_of_caller' gem 'librarian', '>= 0.0.25', require: false gem 'pry-rails' + # https://github.com/ctran/annotate_models/pull/106 + gem 'annotate', :git => 'https://github.com/SamSaffron/annotate_models.git' end # we are using a custom sprockets repo to work around: https://github.com/rails/rails/issues/8099#issuecomment-16137638 diff --git a/Gemfile.lock b/Gemfile.lock index 6dfdf3936..5af455c25 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,6 +71,13 @@ GIT activerecord (>= 3.0.0) activesupport (>= 3.0.0) +PATH + remote: /home/sam/Source/annotate_models + specs: + annotate (2.6.0.beta1) + activerecord (>= 2.3.0) + rake (>= 0.8.7) + PATH remote: vendor/gems/discourse_emoji specs: @@ -458,6 +465,7 @@ DEPENDENCIES active_model_serializers! activerecord-postgres-hstore airbrake (= 3.1.2) + annotate! barber (= 0.3.0) better_errors binding_of_caller diff --git a/app/models/admin_log.rb b/app/models/admin_log.rb index f8a3248cd..b69ee14f9 100644 --- a/app/models/admin_log.rb +++ b/app/models/admin_log.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: admin_logs +# +# id :integer not null, primary key +# action :integer not null +# admin_id :integer not null +# target_user_id :integer +# details :text +# created_at :datetime not null +# updated_at :datetime not null +# + # AdminLog stores information about actions that admins and moderators have taken, # like deleting users, changing site settings, etc. # Use the AdminLogger class to log records to this table. diff --git a/app/models/category.rb b/app/models/category.rb index 275a953cf..e53e22f03 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,3 +1,31 @@ +# == Schema Information +# +# Table name: categories +# +# id :integer not null, primary key +# name :string(50) not null +# color :string(6) default("AB9364"), not null +# topic_id :integer +# topic_count :integer default(0), not null +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer not null +# topics_year :integer +# topics_month :integer +# topics_week :integer +# slug :string(255) not null +# description :text +# text_color :string(6) default("FFFFFF"), not null +# hotness :float default(5.0), not null +# secure :boolean default(FALSE), not null +# auto_close_days :float +# +# Indexes +# +# index_categories_on_forum_thread_count (topic_count) +# index_categories_on_name (name) UNIQUE +# + class Category < ActiveRecord::Base belongs_to :topic, dependent: :destroy belongs_to :topic_only_relative_url, diff --git a/app/models/category_featured_topic.rb b/app/models/category_featured_topic.rb index aed4f2f6e..19f139a15 100644 --- a/app/models/category_featured_topic.rb +++ b/app/models/category_featured_topic.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: category_featured_topics +# +# category_id :integer not null +# topic_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# cat_featured_threads (category_id,topic_id) UNIQUE +# + class CategoryFeaturedTopic < ActiveRecord::Base belongs_to :category belongs_to :topic diff --git a/app/models/category_featured_user.rb b/app/models/category_featured_user.rb index 22519b7cf..a6c0ed875 100644 --- a/app/models/category_featured_user.rb +++ b/app/models/category_featured_user.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: category_featured_users +# +# id :integer not null, primary key +# category_id :integer +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_category_featured_users_on_category_id_and_user_id (category_id,user_id) UNIQUE +# + class CategoryFeaturedUser < ActiveRecord::Base belongs_to :category belongs_to :user diff --git a/app/models/category_group.rb b/app/models/category_group.rb index 25781fca5..820651dc7 100644 --- a/app/models/category_group.rb +++ b/app/models/category_group.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: category_groups +# +# id :integer not null, primary key +# category_id :integer not null +# group_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + class CategoryGroup < ActiveRecord::Base belongs_to :category belongs_to :group diff --git a/app/models/category_search_data.rb b/app/models/category_search_data.rb index a07a89caf..12b7510f6 100644 --- a/app/models/category_search_data.rb +++ b/app/models/category_search_data.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: category_search_data +# +# category_id :integer not null, primary key +# search_data :tsvector +# +# Indexes +# +# idx_search_category (search_data) +# + class CategorySearchData < ActiveRecord::Base belongs_to :category diff --git a/app/models/draft.rb b/app/models/draft.rb index dc31a83e8..dd739db96 100644 --- a/app/models/draft.rb +++ b/app/models/draft.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: drafts +# +# id :integer not null, primary key +# user_id :integer not null +# draft_key :string(255) not null +# data :text not null +# created_at :datetime not null +# updated_at :datetime not null +# sequence :integer default(0), not null +# +# Indexes +# +# index_drafts_on_user_id_and_draft_key (user_id,draft_key) +# + class Draft < ActiveRecord::Base NEW_TOPIC = 'new_topic' NEW_PRIVATE_MESSAGE = 'new_private_message' diff --git a/app/models/draft_sequence.rb b/app/models/draft_sequence.rb index 9283305a2..77f8fc7cf 100644 --- a/app/models/draft_sequence.rb +++ b/app/models/draft_sequence.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: draft_sequences +# +# id :integer not null, primary key +# user_id :integer not null +# draft_key :string(255) not null +# sequence :integer not null +# +# Indexes +# +# index_draft_sequences_on_user_id_and_draft_key (user_id,draft_key) UNIQUE +# + class DraftSequence < ActiveRecord::Base def self.next!(user,key) user_id = user diff --git a/app/models/email_log.rb b/app/models/email_log.rb index da1e04fcb..277479793 100644 --- a/app/models/email_log.rb +++ b/app/models/email_log.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: email_logs +# +# id :integer not null, primary key +# to_address :string(255) not null +# email_type :string(255) not null +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_email_logs_on_created_at (created_at) +# index_email_logs_on_user_id_and_created_at (user_id,created_at) +# + class EmailLog < ActiveRecord::Base belongs_to :user validates_presence_of :email_type diff --git a/app/models/email_token.rb b/app/models/email_token.rb index c02794a65..be07e2e46 100644 --- a/app/models/email_token.rb +++ b/app/models/email_token.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: email_tokens +# +# id :integer not null, primary key +# user_id :integer not null +# email :string(255) not null +# token :string(255) not null +# confirmed :boolean default(FALSE), not null +# expired :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_email_tokens_on_token (token) UNIQUE +# + class EmailToken < ActiveRecord::Base belongs_to :user diff --git a/app/models/facebook_user_info.rb b/app/models/facebook_user_info.rb index 3e0a3a154..83b7969b7 100644 --- a/app/models/facebook_user_info.rb +++ b/app/models/facebook_user_info.rb @@ -1,3 +1,26 @@ +# == Schema Information +# +# Table name: facebook_user_infos +# +# id :integer not null, primary key +# user_id :integer not null +# facebook_user_id :integer not null +# username :string(255) not null +# first_name :string(255) +# last_name :string(255) +# email :string(255) +# gender :string(255) +# name :string(255) +# link :string(255) +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_facebook_user_infos_on_facebook_user_id (facebook_user_id) UNIQUE +# index_facebook_user_infos_on_user_id (user_id) UNIQUE +# + class FacebookUserInfo < ActiveRecord::Base attr_accessible :email, :facebook_user_id, :first_name, :gender, :last_name, :name, :user_id, :username, :link belongs_to :user diff --git a/app/models/github_user_info.rb b/app/models/github_user_info.rb index 7f2b4c56d..2c4f603e1 100644 --- a/app/models/github_user_info.rb +++ b/app/models/github_user_info.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: github_user_infos +# +# id :integer not null, primary key +# user_id :integer not null +# screen_name :string(255) not null +# github_user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_github_user_infos_on_github_user_id (github_user_id) UNIQUE +# index_github_user_infos_on_user_id (user_id) UNIQUE +# + class GithubUserInfo < ActiveRecord::Base belongs_to :user -end \ No newline at end of file +end diff --git a/app/models/group.rb b/app/models/group.rb index f6c423a58..1726066c0 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: groups +# +# id :integer not null, primary key +# name :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# automatic :boolean default(FALSE), not null +# user_count :integer default(0), not null +# +# Indexes +# +# index_groups_on_name (name) UNIQUE +# + class Group < ActiveRecord::Base has_many :category_groups has_many :group_users, dependent: :destroy diff --git a/app/models/group_user.rb b/app/models/group_user.rb index 4b87ec1f2..c9e6fe66e 100644 --- a/app/models/group_user.rb +++ b/app/models/group_user.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: group_users +# +# id :integer not null, primary key +# group_id :integer not null +# user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_group_users_on_group_id_and_user_id (group_id,user_id) UNIQUE +# + class GroupUser < ActiveRecord::Base belongs_to :group, counter_cache: "user_count" belongs_to :user diff --git a/app/models/hot_topic.rb b/app/models/hot_topic.rb index c4ef81774..c61189652 100644 --- a/app/models/hot_topic.rb +++ b/app/models/hot_topic.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: hot_topics +# +# id :integer not null, primary key +# topic_id :integer not null +# category_id :integer +# score :float not null +# random_bias :float +# random_multiplier :float +# days_ago_bias :float +# days_ago_multiplier :float +# hot_topic_type :integer +# +# Indexes +# +# index_hot_topics_on_score (score) +# index_hot_topics_on_topic_id (topic_id) UNIQUE +# + class HotTopic < ActiveRecord::Base belongs_to :topic diff --git a/app/models/incoming_link.rb b/app/models/incoming_link.rb index d077edcab..990d7ea68 100644 --- a/app/models/incoming_link.rb +++ b/app/models/incoming_link.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: incoming_links +# +# id :integer not null, primary key +# url :string(1000) not null +# referer :string(1000) +# domain :string(100) +# topic_id :integer +# post_number :integer +# created_at :datetime not null +# updated_at :datetime not null +# user_id :integer +# ip_address :string +# current_user_id :integer +# +# Indexes +# +# incoming_index (topic_id,post_number) +# + class IncomingLink < ActiveRecord::Base belongs_to :topic belongs_to :user diff --git a/app/models/invite.rb b/app/models/invite.rb index 6a8c737a8..ea49fc45c 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: invites +# +# id :integer not null, primary key +# invite_key :string(32) not null +# email :string(255) not null +# invited_by_id :integer not null +# user_id :integer +# redeemed_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# deleted_at :datetime +# +# Indexes +# +# index_invites_on_email_and_invited_by_id (email,invited_by_id) UNIQUE +# index_invites_on_invite_key (invite_key) UNIQUE +# + require_dependency 'trashable' class Invite < ActiveRecord::Base diff --git a/app/models/notification.rb b/app/models/notification.rb index fd94cfbec..f35e82ba1 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: notifications +# +# id :integer not null, primary key +# notification_type :integer not null +# user_id :integer not null +# data :string(1000) not null +# read :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# topic_id :integer +# post_number :integer +# post_action_id :integer +# +# Indexes +# +# index_notifications_on_post_action_id (post_action_id) +# index_notifications_on_user_id_and_created_at (user_id,created_at) +# + require_dependency 'enum' class Notification < ActiveRecord::Base diff --git a/app/models/post.rb b/app/models/post.rb index 1e6906381..087bf7906 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,3 +1,50 @@ +# == Schema Information +# +# Table name: posts +# +# id :integer not null, primary key +# user_id :integer not null +# topic_id :integer not null +# post_number :integer not null +# raw :text not null +# cooked :text not null +# created_at :datetime not null +# updated_at :datetime not null +# reply_to_post_number :integer +# cached_version :integer default(1), not null +# reply_count :integer default(0), not null +# quote_count :integer default(0), not null +# deleted_at :datetime +# off_topic_count :integer default(0), not null +# like_count :integer default(0), not null +# incoming_link_count :integer default(0), not null +# bookmark_count :integer default(0), not null +# avg_time :integer +# score :float +# reads :integer default(0), not null +# post_type :integer default(1), not null +# vote_count :integer default(0), not null +# sort_order :integer +# last_editor_id :integer +# hidden :boolean default(FALSE), not null +# hidden_reason_id :integer +# notify_moderators_count :integer default(0), not null +# spam_count :integer default(0), not null +# illegal_count :integer default(0), not null +# inappropriate_count :integer default(0), not null +# last_version_at :datetime not null +# user_deleted :boolean default(FALSE), not null +# reply_to_user_id :integer +# percent_rank :float default(1.0) +# notify_user_count :integer default(0), not null +# +# Indexes +# +# idx_posts_user_id_deleted_at (user_id) +# index_posts_on_reply_to_post_number (reply_to_post_number) +# index_posts_on_topic_id_and_post_number (topic_id,post_number) UNIQUE +# + require_dependency 'jobs' require_dependency 'pretty_text' require_dependency 'rate_limiter' diff --git a/app/models/post_action.rb b/app/models/post_action.rb index 284513ec6..d84ca6e62 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: post_actions +# +# id :integer not null, primary key +# post_id :integer not null +# user_id :integer not null +# post_action_type_id :integer not null +# deleted_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# deleted_by :integer +# message :text +# related_post_id :integer +# +# Indexes +# +# idx_unique_actions (user_id,post_action_type_id,post_id,deleted_at) UNIQUE +# index_post_actions_on_post_id (post_id) +# + require_dependency 'rate_limiter' require_dependency 'system_message' require_dependency 'trashable' diff --git a/app/models/post_action_type.rb b/app/models/post_action_type.rb index 8eba6a8e4..5c52b52f5 100644 --- a/app/models/post_action_type.rb +++ b/app/models/post_action_type.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: post_action_types +# +# name_key :string(50) not null +# is_flag :boolean default(FALSE), not null +# icon :string(20) +# created_at :datetime not null +# updated_at :datetime not null +# id :integer not null, primary key +# position :integer default(0), not null +# + require_dependency 'enum' class PostActionType < ActiveRecord::Base diff --git a/app/models/post_reply.rb b/app/models/post_reply.rb index 251db65b4..099d70b5c 100644 --- a/app/models/post_reply.rb +++ b/app/models/post_reply.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: post_replies +# +# post_id :integer +# reply_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_post_replies_on_post_id_and_reply_id (post_id,reply_id) UNIQUE +# + class PostReply < ActiveRecord::Base belongs_to :post belongs_to :reply, class_name: 'Post' diff --git a/app/models/post_search_data.rb b/app/models/post_search_data.rb index 178f66304..c58f0c873 100644 --- a/app/models/post_search_data.rb +++ b/app/models/post_search_data.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: post_search_data +# +# post_id :integer not null, primary key +# search_data :tsvector +# +# Indexes +# +# idx_search_post (search_data) +# + class PostSearchData < ActiveRecord::Base belongs_to :post diff --git a/app/models/post_timing.rb b/app/models/post_timing.rb index acf6147af..3ae564dfd 100644 --- a/app/models/post_timing.rb +++ b/app/models/post_timing.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: post_timings +# +# topic_id :integer not null +# post_number :integer not null +# user_id :integer not null +# msecs :integer not null +# +# Indexes +# +# post_timings_summary (topic_id,post_number) +# post_timings_unique (topic_id,post_number,user_id) UNIQUE +# + class PostTiming < ActiveRecord::Base belongs_to :topic belongs_to :user diff --git a/app/models/site_content.rb b/app/models/site_content.rb index f9d737000..3079ce4e8 100644 --- a/app/models/site_content.rb +++ b/app/models/site_content.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: site_contents +# +# content_type :string(255) not null, primary key +# content :text not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_site_contents_on_content_type (content_type) UNIQUE +# + require_dependency 'site_content_type' require_dependency 'site_content_class_methods' diff --git a/app/models/site_customization.rb b/app/models/site_customization.rb index 507d6f0ac..43d6790f8 100644 --- a/app/models/site_customization.rb +++ b/app/models/site_customization.rb @@ -1,3 +1,25 @@ +# == Schema Information +# +# Table name: site_customizations +# +# id :integer not null, primary key +# name :string(255) not null +# stylesheet :text +# header :text +# position :integer not null +# user_id :integer not null +# enabled :boolean not null +# key :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# override_default_style :boolean default(FALSE), not null +# stylesheet_baked :text default(""), not null +# +# Indexes +# +# index_site_customizations_on_key (key) +# + class SiteCustomization < ActiveRecord::Base ENABLED_KEY = '7e202ef2-56d7-47d5-98d8-a9c8d15e57dd' # placing this in uploads to ease deployment rules diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index e4196ab32..da7b85562 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: site_settings +# +# id :integer not null, primary key +# name :string(255) not null +# data_type :integer not null +# value :text +# created_at :datetime not null +# updated_at :datetime not null +# + require 'site_setting_extension' class SiteSetting < ActiveRecord::Base diff --git a/app/models/topic.rb b/app/models/topic.rb index fdf606336..55327ee4a 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1,3 +1,59 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# title :string(255) not null +# last_posted_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# views :integer default(0), not null +# posts_count :integer default(0), not null +# user_id :integer not null +# last_post_user_id :integer not null +# reply_count :integer default(0), not null +# featured_user1_id :integer +# featured_user2_id :integer +# featured_user3_id :integer +# avg_time :integer +# deleted_at :datetime +# highest_post_number :integer default(0), not null +# image_url :string(255) +# off_topic_count :integer default(0), not null +# like_count :integer default(0), not null +# incoming_link_count :integer default(0), not null +# bookmark_count :integer default(0), not null +# star_count :integer default(0), not null +# category_id :integer +# visible :boolean default(TRUE), not null +# moderator_posts_count :integer default(0), not null +# closed :boolean default(FALSE), not null +# archived :boolean default(FALSE), not null +# bumped_at :datetime not null +# has_best_of :boolean default(FALSE), not null +# meta_data :hstore +# vote_count :integer default(0), not null +# archetype :string(255) default("regular"), not null +# featured_user4_id :integer +# notify_moderators_count :integer default(0), not null +# spam_count :integer default(0), not null +# illegal_count :integer default(0), not null +# inappropriate_count :integer default(0), not null +# pinned_at :datetime +# score :float +# percent_rank :float default(1.0), not null +# notify_user_count :integer default(0), not null +# subtype :string(255) +# slug :string(255) +# auto_close_at :datetime +# auto_close_user_id :integer +# +# Indexes +# +# idx_topics_user_id_deleted_at (user_id) +# index_forum_threads_on_bumped_at (bumped_at) +# + require_dependency 'slug' require_dependency 'avatar_lookup' require_dependency 'topic_view' diff --git a/app/models/topic_allowed_group.rb b/app/models/topic_allowed_group.rb index e5606596f..393ca9b54 100644 --- a/app/models/topic_allowed_group.rb +++ b/app/models/topic_allowed_group.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: topic_allowed_groups +# +# id :integer not null, primary key +# group_id :integer not null +# topic_id :integer not null +# +# Indexes +# +# index_topic_allowed_groups_on_group_id_and_topic_id (group_id,topic_id) UNIQUE +# index_topic_allowed_groups_on_topic_id_and_group_id (topic_id,group_id) UNIQUE +# + class TopicAllowedGroup < ActiveRecord::Base belongs_to :topic belongs_to :group diff --git a/app/models/topic_allowed_user.rb b/app/models/topic_allowed_user.rb index 031c88700..7691e80c7 100644 --- a/app/models/topic_allowed_user.rb +++ b/app/models/topic_allowed_user.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: topic_allowed_users +# +# id :integer not null, primary key +# user_id :integer not null +# topic_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_topic_allowed_users_on_topic_id_and_user_id (topic_id,user_id) UNIQUE +# index_topic_allowed_users_on_user_id_and_topic_id (user_id,topic_id) UNIQUE +# + class TopicAllowedUser < ActiveRecord::Base belongs_to :topic belongs_to :user diff --git a/app/models/topic_invite.rb b/app/models/topic_invite.rb index 3a5491a02..eca7b2c46 100644 --- a/app/models/topic_invite.rb +++ b/app/models/topic_invite.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: topic_invites +# +# id :integer not null, primary key +# topic_id :integer not null +# invite_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_topic_invites_on_invite_id (invite_id) +# index_topic_invites_on_topic_id_and_invite_id (topic_id,invite_id) UNIQUE +# + class TopicInvite < ActiveRecord::Base belongs_to :topic belongs_to :invite diff --git a/app/models/topic_link.rb b/app/models/topic_link.rb index 433ee111e..6992b865b 100644 --- a/app/models/topic_link.rb +++ b/app/models/topic_link.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: topic_links +# +# id :integer not null, primary key +# topic_id :integer not null +# post_id :integer +# user_id :integer not null +# url :string(500) not null +# domain :string(100) not null +# internal :boolean default(FALSE), not null +# link_topic_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# reflection :boolean default(FALSE) +# clicks :integer default(0), not null +# link_post_id :integer +# +# Indexes +# +# index_forum_thread_links_on_forum_thread_id (topic_id) +# index_forum_thread_links_on_forum_thread_id_and_post_id_and_url (topic_id,post_id,url) UNIQUE +# + require 'uri' require_dependency 'slug' diff --git a/app/models/topic_link_click.rb b/app/models/topic_link_click.rb index b6abd19a8..8a4901eb1 100644 --- a/app/models/topic_link_click.rb +++ b/app/models/topic_link_click.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: topic_link_clicks +# +# id :integer not null, primary key +# topic_link_id :integer not null +# user_id :integer +# ip :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_forum_thread_link_clicks_on_forum_thread_link_id (topic_link_id) +# + require_dependency 'discourse' require 'ipaddr' diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index e8306e8b0..5032a9278 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -1,3 +1,28 @@ +# == Schema Information +# +# Table name: topic_users +# +# user_id :integer not null +# topic_id :integer not null +# starred :boolean default(FALSE), not null +# posted :boolean default(FALSE), not null +# last_read_post_number :integer +# seen_post_count :integer +# starred_at :datetime +# last_visited_at :datetime +# first_visited_at :datetime +# notification_level :integer default(1), not null +# notifications_changed_at :datetime +# notifications_reason_id :integer +# total_msecs_viewed :integer default(0), not null +# cleared_pinned_at :datetime +# unstarred_at :datetime +# +# Indexes +# +# index_forum_thread_users_on_forum_thread_id_and_user_id (topic_id,user_id) UNIQUE +# + class TopicUser < ActiveRecord::Base belongs_to :user belongs_to :topic diff --git a/app/models/twitter_user_info.rb b/app/models/twitter_user_info.rb index e1675b069..c5277e171 100644 --- a/app/models/twitter_user_info.rb +++ b/app/models/twitter_user_info.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: twitter_user_infos +# +# id :integer not null, primary key +# user_id :integer not null +# screen_name :string(255) not null +# twitter_user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_twitter_user_infos_on_twitter_user_id (twitter_user_id) UNIQUE +# index_twitter_user_infos_on_user_id (user_id) UNIQUE +# + class TwitterUserInfo < ActiveRecord::Base belongs_to :user end diff --git a/app/models/upload.rb b/app/models/upload.rb index 81932cb25..c4731117b 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: uploads +# +# id :integer not null, primary key +# user_id :integer not null +# topic_id :integer not null +# original_filename :string(255) not null +# filesize :integer not null +# width :integer +# height :integer +# url :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_uploads_on_forum_thread_id (topic_id) +# index_uploads_on_user_id (user_id) +# + require 'digest/sha1' class Upload < ActiveRecord::Base diff --git a/app/models/user.rb b/app/models/user.rb index 7beced2a2..22939e3e0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,63 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# username :string(20) not null +# created_at :datetime not null +# updated_at :datetime not null +# name :string(255) +# bio_raw :text +# seen_notification_id :integer default(0), not null +# last_posted_at :datetime +# email :string(256) not null +# password_hash :string(64) +# salt :string(32) +# active :boolean +# username_lower :string(20) not null +# auth_token :string(32) +# last_seen_at :datetime +# website :string(255) +# admin :boolean default(FALSE), not null +# last_emailed_at :datetime +# email_digests :boolean default(TRUE), not null +# trust_level :integer not null +# bio_cooked :text +# email_private_messages :boolean default(TRUE) +# email_direct :boolean default(TRUE), not null +# approved :boolean default(FALSE), not null +# approved_by_id :integer +# approved_at :datetime +# topics_entered :integer default(0), not null +# posts_read_count :integer default(0), not null +# digest_after_days :integer default(7), not null +# previous_visit_at :datetime +# banned_at :datetime +# banned_till :datetime +# date_of_birth :date +# auto_track_topics_after_msecs :integer +# views :integer default(0), not null +# flag_level :integer default(0), not null +# time_read :integer default(0), not null +# days_visited :integer default(0), not null +# ip_address :string +# new_topic_duration_minutes :integer +# external_links_in_new_tab :boolean default(FALSE), not null +# enable_quoting :boolean default(TRUE), not null +# moderator :boolean default(FALSE) +# likes_given :integer default(0), not null +# likes_received :integer default(0), not null +# topic_reply_count :integer default(0), not null +# +# Indexes +# +# index_users_on_auth_token (auth_token) +# index_users_on_email (email) UNIQUE +# index_users_on_last_posted_at (last_posted_at) +# index_users_on_username (username) UNIQUE +# index_users_on_username_lower (username_lower) UNIQUE +# + require_dependency 'email' require_dependency 'email_token' require_dependency 'trust_level' diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 1232bc0f8..236c0d89e 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -1,3 +1,24 @@ +# == Schema Information +# +# Table name: user_actions +# +# id :integer not null, primary key +# action_type :integer not null +# user_id :integer not null +# target_topic_id :integer +# target_post_id :integer +# target_user_id :integer +# acting_user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# idx_unique_rows (action_type,user_id,target_topic_id,target_post_id,acting_user_id) UNIQUE +# index_actions_on_acting_user_id (acting_user_id) +# index_actions_on_user_id_and_action_type (user_id,action_type) +# + class UserAction < ActiveRecord::Base belongs_to :user belongs_to :target_post, class_name: "Post" diff --git a/app/models/user_open_id.rb b/app/models/user_open_id.rb index 1b889bdee..acf9668f9 100644 --- a/app/models/user_open_id.rb +++ b/app/models/user_open_id.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: user_open_ids +# +# id :integer not null, primary key +# user_id :integer not null +# email :string(255) not null +# url :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# active :boolean not null +# +# Indexes +# +# index_user_open_ids_on_url (url) +# + class UserOpenId < ActiveRecord::Base belongs_to :user attr_accessible :email, :url, :user_id, :active diff --git a/app/models/user_search_data.rb b/app/models/user_search_data.rb index 1f1395849..d60054b9a 100644 --- a/app/models/user_search_data.rb +++ b/app/models/user_search_data.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: user_search_data +# +# user_id :integer not null, primary key +# search_data :tsvector +# +# Indexes +# +# idx_search_user (search_data) +# + class UserSearchData < ActiveRecord::Base belongs_to :user validates_presence_of :search_data diff --git a/app/models/user_visit.rb b/app/models/user_visit.rb index d310ddaa4..5409c405e 100644 --- a/app/models/user_visit.rb +++ b/app/models/user_visit.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: user_visits +# +# id :integer not null, primary key +# user_id :integer not null +# visited_at :date not null +# +# Indexes +# +# index_user_visits_on_user_id_and_visited_at (user_id,visited_at) UNIQUE +# + class UserVisit < ActiveRecord::Base attr_accessible :visited_at, :user_id diff --git a/app/models/view.rb b/app/models/view.rb index 4d4670ce9..e1733df35 100644 --- a/app/models/view.rb +++ b/app/models/view.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: views +# +# parent_id :integer not null +# parent_type :string(50) not null +# ip :integer not null +# viewed_at :date not null +# user_id :integer +# +# Indexes +# +# index_views_on_parent_id_and_parent_type (parent_id,parent_type) +# + require 'ipaddr' class View < ActiveRecord::Base diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 000000000..2aeb47c64 --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -0,0 +1,34 @@ +# NOTE: only doing this in development as some production environments (Heroku) +# NOTE: are sensitive to local FS writes, and besides -- it's just not proper +# NOTE: to have a dev-mode tool do its thing in production. +if(Rails.env.development?) + task :set_annotation_options do + # You can override any of these by setting an environment variable of the + # same name. + Annotate.set_defaults({ + 'position_in_routes' => "before", + 'position_in_class' => "before", + 'position_in_test' => "before", + 'position_in_fixture' => "before", + 'position_in_factory' => "before", + 'show_indexes' => "true", + 'simple_indexes' => "false", + 'model_dir' => "app/models", + 'include_version' => "false", + 'require' => "", + 'exclude_tests' => "true", + 'exclude_fixtures' => "true", + 'exclude_factories' => "true", + 'ignore_model_sub_dir' => "false", + 'skip_on_db_migrate' => "false", + 'format_bare' => "true", + 'format_rdoc' => "false", + 'format_markdown' => "false", + 'sort' => "false", + 'force' => "false", + 'trace' => "false", + }) + end + + Annotate.load_tasks +end