diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index bb63248d7..b36117eeb 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -8,6 +8,6 @@ //= require jquery.qtip.js //= require ugoira_player.js //= require stupidtable.js -//= require rails.js +//= require rails-ujs //= require common.js //= require_tree . diff --git a/app/assets/javascripts/forum_post_votes_controller.js b/app/assets/javascripts/forum_post_votes_controller.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/forum_post_votes_controller.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/forum_post_votes_controller.scss b/app/assets/stylesheets/forum_post_votes_controller.scss new file mode 100644 index 000000000..5aac47c6d --- /dev/null +++ b/app/assets/stylesheets/forum_post_votes_controller.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the ForumPostVotesController controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/specific/forum.scss b/app/assets/stylesheets/specific/forum.scss index afbfdb2fa..0d8990a0b 100644 --- a/app/assets/stylesheets/specific/forum.scss +++ b/app/assets/stylesheets/specific/forum.scss @@ -5,10 +5,30 @@ div.list-of-forum-posts { word-wrap: break-word; box-shadow: 1px 1px 2px #AAA; + a.voted { + font-weight: bold; + } + + span.desc { + color: grey; + } + &:target { background-color: #FFC; } + .vote-score-up { + color: green; + } + + .vote-score-meh { + color: goldenrod; + } + + .vote-score-down { + color: red; + } + div.author { padding: 1em 1em 0 1em; width: 12em; @@ -26,6 +46,10 @@ div.list-of-forum-posts { menu { margin-top: 0.5em; + ul.votes { + margin: 0.5em 0; + } + li { margin-right: 1em; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c19e44742..61dba882e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -116,7 +116,7 @@ class ApplicationController < ActionController::Base fmt.xml { render template: "static/error", status: 501 } end else - render :template => "static/error", :status => 500 + render :template => "static/error", :status => 500, :layout => "blank" end end diff --git a/app/controllers/forum_post_votes_controller.rb b/app/controllers/forum_post_votes_controller.rb new file mode 100644 index 000000000..f84653cd7 --- /dev/null +++ b/app/controllers/forum_post_votes_controller.rb @@ -0,0 +1,32 @@ +class ForumPostVotesController < ApplicationController + respond_to :js + before_action :load_forum_post + before_action :load_vote, only: [:destroy] + before_action :member_only + + def create + @forum_post_vote = @forum_post.votes.create(forum_post_vote_params) + respond_with(@forum_post_vote) + end + + def destroy + @forum_post_vote.destroy + respond_with(@forum_post_vote) + end + +private + + def load_vote + @forum_post_vote = @forum_post.votes.where(creator_id: CurrentUser.id).first + raise ActiveRecord::RecordNotFound.new if @forum_post_vote.nil? + end + + def load_forum_post + @forum_post = ForumPost.find(params[:forum_post_id]) + end + + def forum_post_vote_params + params.fetch(:forum_post_vote, {}).permit(:score) + end + +end diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 015e73f7e..bb7df8f33 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -46,6 +46,7 @@ class ForumTopicsController < ApplicationController @forum_topic.mark_as_read!(CurrentUser.user) end @forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page]) + @original_forum_post_id = @forum_topic.original_post.id respond_with(@forum_topic) do |format| format.atom do @forum_posts = @forum_posts.reverse_order.includes(:creator).load diff --git a/app/helpers/forum_post_votes_controller_helper.rb b/app/helpers/forum_post_votes_controller_helper.rb new file mode 100644 index 000000000..e39878914 --- /dev/null +++ b/app/helpers/forum_post_votes_controller_helper.rb @@ -0,0 +1,2 @@ +module ForumPostVotesControllerHelper +end diff --git a/app/logical/daily_maintenance.rb b/app/logical/daily_maintenance.rb index 7e8b02d32..42ec90303 100644 --- a/app/logical/daily_maintenance.rb +++ b/app/logical/daily_maintenance.rb @@ -5,6 +5,7 @@ class DailyMaintenance TagPruner.new.prune! Upload.where('created_at < ?', 1.day.ago).delete_all Delayed::Job.where('created_at < ?', 45.days.ago).delete_all + #ForumPostVote.where("created_at < ?", 90.days.ago).delete_all PostVote.prune! CommentVote.prune! ApiCacheGenerator.new.generate_tag_cache @@ -15,5 +16,7 @@ class DailyMaintenance Tag.clean_up_negative_post_counts! SuperVoter.init! TokenBucket.prune! + TagChangeRequestPruner.warn_all + TagChangeRequestPruner.reject_all end end diff --git a/app/logical/session_loader.rb b/app/logical/session_loader.rb index ce449d858..33f8460de 100644 --- a/app/logical/session_loader.rb +++ b/app/logical/session_loader.rb @@ -79,7 +79,8 @@ private end def load_session_user - CurrentUser.user = User.find_by_id(session[:user_id]) + user = User.find_by_id(session[:user_id]) + CurrentUser.user = user if user end def load_cookie_user diff --git a/app/logical/tag_change_request_pruner.rb b/app/logical/tag_change_request_pruner.rb new file mode 100644 index 000000000..1d1d628fc --- /dev/null +++ b/app/logical/tag_change_request_pruner.rb @@ -0,0 +1,43 @@ +# Service to prune old unapproved tag change requests +# (including tag aliases, tag implications, and bulk +# update requests). + +class TagChangeRequestPruner + def self.warn_all + [TagAlias, TagImplication, BulkUpdateRequest].each do |model| + new.warn_old(model) + end + end + + def self.reject_all + [TagAlias, TagImplication, BulkUpdateRequest].each do |model| + new.reject_expired(model) + end + end + + def warn_old(model) + model.old.pending.find_each do |tag_change| + if tag_change.forum_topic + name = model.model_name.human.downcase + body = "This #{name} is pending automatic rejection in 5 days." + unless tag_change.forum_topic.posts.where(creator_id: User.system.id, body: body).exists? + tag_change.forum_updater.update(body) + end + end + end + end + + def reject_expired(model) + model.expired.pending.find_each do |tag_change| + if tag_change.forum_topic + name = model.model_name.human.downcase + body = "This #{name} has been rejected because it was not approved within 60 days." + tag_change.forum_updater.update(body) + end + + CurrentUser.as_system do + tag_change.reject! + end + end + end +end diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index c349538c9..f0afbc405 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -18,6 +18,9 @@ class BulkUpdateRequest < ApplicationRecord after_create :create_forum_topic scope :pending_first, lambda { order("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)") } + scope :pending, ->{where(status: "pending")} + scope :expired, ->{where("created_at < ?", TagRelationship::EXPIRY.days.ago)} + scope :old, ->{where("created_at between ? and ?", TagRelationship::EXPIRY.days.ago, TagRelationship::EXPIRY_WARNING.days.ago)} module SearchMethods def default_order @@ -121,7 +124,7 @@ class BulkUpdateRequest < ApplicationRecord end end - def reject!(rejector) + def reject!(rejector = User.system) transaction do update(status: "rejected") forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.", "REJECTED") diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 0866d8767..c533ac821 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -5,6 +5,7 @@ class ForumPost < ApplicationRecord belongs_to_creator belongs_to_updater belongs_to :topic, :class_name => "ForumTopic" + has_many :votes, class_name: "ForumPostVote" before_validation :initialize_is_deleted, :on => :create after_create :update_topic_updated_at_on_create after_update :update_topic_updated_at_on_update_for_original_posts @@ -128,6 +129,10 @@ class ForumPost < ApplicationRecord end end + def voted?(user, score) + votes.where(creator_id: user.id, score: score).exists? + end + def validate_topic_is_unlocked return if CurrentUser.is_moderator? return if topic.nil? @@ -228,8 +233,12 @@ class ForumPost < ApplicationRecord ((ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count) / Danbooru.config.posts_per_page.to_f).ceil end - def is_original_post? - ForumPost.exists?(["id = ? and id = (select _.id from forum_posts _ where _.topic_id = ? order by _.id asc limit 1)", id, topic_id]) + def is_original_post?(original_post_id = nil) + if original_post_id + return id == original_post_id + else + ForumPost.exists?(["id = ? and id = (select _.id from forum_posts _ where _.topic_id = ? order by _.id asc limit 1)", id, topic_id]) + end end def delete_topic_if_original_post diff --git a/app/models/forum_post_vote.rb b/app/models/forum_post_vote.rb new file mode 100644 index 000000000..88ee0f0a0 --- /dev/null +++ b/app/models/forum_post_vote.rb @@ -0,0 +1,44 @@ +class ForumPostVote < ApplicationRecord + belongs_to_creator + belongs_to :forum_post + validates :creator_id, uniqueness: {scope: :forum_post_id} + validates :score, inclusion: {in: [-1, 0, 1]} + scope :up, -> {where(score: 1)} + scope :down, -> {where(score: -1)} + scope :by, ->(user_id) {where(creator_id: user_id)} + scope :excluding, ->(user_id) {where("creator_id <> ?", user_id)} + + def up? + score == 1 + end + + def down? + score == -1 + end + + def meh? + score == 0 + end + + def fa_class + if score == 1 + return "fa-thumbs-up" + elsif score == -1 + return "fa-thumbs-down" + else + return "fa-meh" + end + end + + def vote_type + if score == 1 + return "up" + elsif score == -1 + return "down" + elsif score == 0 + return "meh" + else + raise + end + end +end diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 25097fd9d..222f03aa3 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -10,6 +10,9 @@ class TagImplication < TagRelationship validate :consequent_is_not_aliased validate :antecedent_and_consequent_are_different validate :wiki_pages_present, :on => :create + scope :expired, ->{where("created_at < ?", 2.months.ago)} + scope :old, ->{where("created_at between ? and ?", 2.months.ago, 1.month.ago)} + scope :pending, ->{where(status: "pending")} module DescendantMethods extend ActiveSupport::Concern diff --git a/app/models/tag_relationship.rb b/app/models/tag_relationship.rb index 66ff817be..3a9391d95 100644 --- a/app/models/tag_relationship.rb +++ b/app/models/tag_relationship.rb @@ -1,6 +1,9 @@ class TagRelationship < ApplicationRecord self.abstract_class = true + EXPIRY = 60 + EXPIRY_WARNING = 55 + attr_accessor :skip_secondary_validations belongs_to_creator @@ -10,6 +13,10 @@ class TagRelationship < ApplicationRecord has_one :antecedent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "antecedent_name" has_one :consequent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "consequent_name" + scope :expired, ->{where("created_at < ?", EXPIRY.days.ago)} + scope :old, ->{where("created_at >= ? and created_at < ?", EXPIRY.days.ago, EXPIRY_WARNING.days.ago)} + scope :pending, ->{where(status: "pending")} + before_validation :initialize_creator, :on => :create before_validation :normalize_names validates_format_of :status, :with => /\A(active|deleted|pending|processing|queued|error: .*)\Z/ diff --git a/app/views/forum_post_votes/_add_vote.html.erb b/app/views/forum_post_votes/_add_vote.html.erb new file mode 100644 index 000000000..d8610890e --- /dev/null +++ b/app/views/forum_post_votes/_add_vote.html.erb @@ -0,0 +1,11 @@ +<%- +# forum_post +%> + +
  • + <%= link_to content_tag(:i, nil, class: "far fa-thumbs-up"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=1"}, title: "Vote up" %> + + <%= link_to content_tag(:i, nil, class: "far fa-meh"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=0"}, title: "Vote meh" %> + + <%= link_to content_tag(:i, nil, class: "far fa-thumbs-down"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :post, data: {params: "forum_post_vote[score]=-1"}, title: "Vote down" %> +
  • diff --git a/app/views/forum_post_votes/_list.html.erb b/app/views/forum_post_votes/_list.html.erb new file mode 100644 index 000000000..2026f5b83 --- /dev/null +++ b/app/views/forum_post_votes/_list.html.erb @@ -0,0 +1,16 @@ +<%- +# votes +# forum_post +%> + +<% votes.by(CurrentUser.user.id).each do |vote| %> + <%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %> +<% end %> + +<% votes.excluding(CurrentUser.user.id).each do |vote| %> + <%= render "forum_post_votes/vote", vote: vote, forum_post: forum_post %> +<% end %> + +<% if !votes.by(CurrentUser.user.id).exists? %> + <%= render "forum_post_votes/add_vote", vote: votes.by(CurrentUser.user.id).first, forum_post: forum_post %> +<% end %> \ No newline at end of file diff --git a/app/views/forum_post_votes/_vote.html.erb b/app/views/forum_post_votes/_vote.html.erb new file mode 100644 index 000000000..0246d2125 --- /dev/null +++ b/app/views/forum_post_votes/_vote.html.erb @@ -0,0 +1,14 @@ +<%- +# vote +# forum_post +%> + +
  • + <% if vote.creator_id == CurrentUser.id %> + <%= link_to content_tag(:i, nil, class: "far #{vote.fa_class}"), forum_post_votes_path(forum_post_id: forum_post.id, format: "js"), remote: true, method: :delete %> + <%= link_to_user vote.creator %> + <% else %> + <%= content_tag(:i, nil, class: "far #{vote.fa_class}") %> + <%= link_to_user vote.creator %> + <% end %> +
  • diff --git a/app/views/forum_post_votes/create.js.erb b/app/views/forum_post_votes/create.js.erb new file mode 100644 index 000000000..0ac2021bd --- /dev/null +++ b/app/views/forum_post_votes/create.js.erb @@ -0,0 +1,7 @@ +<% if @forum_post_vote.invalid? %> +Danbooru.error(<%= raw @forum_post_vote.errors.full_messages.join("; ").to_json %>); +<% else %> +Danbooru.notice("Voted"); +var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>; +$("#forum-post-votes-for-<%= @forum_post.id %>").html(code); +<% end %> diff --git a/app/views/forum_post_votes/destroy.js.erb b/app/views/forum_post_votes/destroy.js.erb new file mode 100644 index 000000000..906bd0807 --- /dev/null +++ b/app/views/forum_post_votes/destroy.js.erb @@ -0,0 +1,3 @@ +Danbooru.notice("Unvoted"); +var code = <%= raw render(partial: "forum_post_votes/list", locals: {forum_post: @forum_post, votes: @forum_post.votes}).to_json %>; +$("#forum-post-votes-for-<%= @forum_post.id %>").html(code); diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb index 1b31895bf..82779124f 100644 --- a/app/views/forum_posts/_forum_post.html.erb +++ b/app/views/forum_posts/_forum_post.html.erb @@ -1,3 +1,5 @@ +<%- # original_forum_post_id: used to accelerate #is_original_post? calls %> + <% if forum_post.visible?(CurrentUser.user) %>
    @@ -23,7 +25,7 @@ <% if CurrentUser.is_member? && @forum_topic %>
  • <%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %>
  • <% end %> - <% if CurrentUser.is_moderator? && !forum_post.is_original_post? %> + <% if CurrentUser.is_moderator? && !forum_post.is_original_post?(original_forum_post_id) %> <% if forum_post.is_deleted %>
  • <%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %>
  • <% else %> @@ -31,7 +33,7 @@ <% end %> <% end %> <% if forum_post.editable_by?(CurrentUser.user) %> - <% if forum_post.is_original_post? %> + <% if forum_post.is_original_post?(original_forum_post_id) %>
  • <%= link_to "Edit", edit_forum_topic_path(forum_post.topic), :id => "edit_forum_topic_link_#{forum_post.topic.id}", :class => "edit_forum_topic_link" %>
  • <% else %>
  • <%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %>
  • @@ -42,9 +44,14 @@ <% else %>
  • <%= link_to "Permalink", forum_post_path(forum_post) %>
  • <% end %> + <% if forum_post.is_original_post?(original_forum_post_id) %> + + <% end %> <% if forum_post.editable_by?(CurrentUser.user) %> - <% if forum_post.is_original_post? %> + <% if forum_post.is_original_post?(original_forum_post_id) %> <%= render "forum_topics/form", :forum_topic => forum_post.topic %> <% else %> <%= render "forum_posts/partials/edit/form", :forum_post => forum_post %> diff --git a/app/views/forum_posts/_listing.html.erb b/app/views/forum_posts/_listing.html.erb index 8550b324c..ea80a4f95 100644 --- a/app/views/forum_posts/_listing.html.erb +++ b/app/views/forum_posts/_listing.html.erb @@ -1,6 +1,9 @@ +<%- # forum_post %> +<%- # original_forum_post_id %> +
    <% forum_posts.each do |forum_post| %> - <%= render "forum_posts/forum_post", :forum_post => forum_post %> + <%= render "forum_posts/forum_post", :forum_post => forum_post, :original_forum_post_id => original_forum_post_id %> <% end %>
    diff --git a/app/views/forum_posts/show.html.erb b/app/views/forum_posts/show.html.erb index d98ce233e..839d1020f 100644 --- a/app/views/forum_posts/show.html.erb +++ b/app/views/forum_posts/show.html.erb @@ -1,7 +1,7 @@

    Topic: <%= @forum_post.topic.title %>

    - <%= render "forum_post", :forum_post => @forum_post %> + <%= render "forum_post", :forum_post => @forum_post, :original_forum_post_id => @forum_post.topic.original_post.id %>
    diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index fae19d00b..97598ef62 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -20,7 +20,7 @@
    <% end %> - <%= render "forum_posts/listing", :forum_posts => @forum_posts %> + <%= render "forum_posts/listing", :forum_posts => @forum_posts, :original_forum_post_id => @forum_topic.original_post.id %> <% if CurrentUser.is_member? %> <% if CurrentUser.is_moderator? || !@forum_topic.is_locked? %> diff --git a/app/views/layouts/blank.html.erb b/app/views/layouts/blank.html.erb index c7dcf2595..b9662a9cb 100644 --- a/app/views/layouts/blank.html.erb +++ b/app/views/layouts/blank.html.erb @@ -7,9 +7,9 @@ <%= csrf_meta_tag %> <%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %> <%= stylesheet_link_tag "application", :media => "screen" %> + <%= javascript_include_tag "application" %> <%= Danbooru.config.custom_html_header_content %> - <%= yield :html_header %> diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 5ee1cabeb..9483d219c 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -71,6 +71,7 @@ "url" : "<%= root_url %>" } + >
    diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458de..5a6a32d37 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb new file mode 100644 index 000000000..3b1c1b5ed --- /dev/null +++ b/config/initializers/cors.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Avoid CORS issues when API is called from the frontend app. +# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. + +# Read more: https://github.com/cyu/rack-cors + +# Rails.application.config.middleware.insert_before 0, Rack::Cors do +# allow do +# origins 'example.com' +# +# resource '*', +# headers: :any, +# methods: [:get, :post, :put, :patch, :delete, :options, :head] +# end +# end diff --git a/config/locales/en.yml b/config/locales/en.yml index fe1fe27fe..3674b8234 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,8 @@ en: hello: "Hello world" activerecord: attributes: + forum_post_vote: + creator_id: "Your vote" post: approver: "You" approver_id: "You" diff --git a/config/routes.rb b/config/routes.rb index 9ee17368d..2c67a6c38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,6 +132,7 @@ Rails.application.routes.draw do resource :order, :only => [:edit], :controller => "favorite_group_orders" end resources :forum_posts do + resource :votes, controller: "forum_post_votes" member do post :undelete end diff --git a/db/migrate/20100204211522_create_users.rb b/db/migrate/20100204211522_create_users.rb index 73eb503d3..40957e40c 100644 --- a/db/migrate/20100204211522_create_users.rb +++ b/db/migrate/20100204211522_create_users.rb @@ -1,4 +1,4 @@ -class CreateUsers < ActiveRecord::Migration +class CreateUsers < ActiveRecord::Migration[4.2] def self.up create_table :users do |t| t.timestamps diff --git a/db/migrate/20100204214746_create_posts.rb b/db/migrate/20100204214746_create_posts.rb index fa36a459f..30e154750 100644 --- a/db/migrate/20100204214746_create_posts.rb +++ b/db/migrate/20100204214746_create_posts.rb @@ -1,4 +1,4 @@ -class CreatePosts < ActiveRecord::Migration +class CreatePosts < ActiveRecord::Migration[4.2] def self.up create_table :posts do |t| t.timestamps diff --git a/db/migrate/20100205162521_create_tags.rb b/db/migrate/20100205162521_create_tags.rb index 927cf359e..1d47b4e15 100644 --- a/db/migrate/20100205162521_create_tags.rb +++ b/db/migrate/20100205162521_create_tags.rb @@ -1,4 +1,4 @@ -class CreateTags < ActiveRecord::Migration +class CreateTags < ActiveRecord::Migration[4.2] def self.up create_table :tags do |t| t.column :name, :string, :null => false diff --git a/db/migrate/20100205163027_create_post_versions.rb b/db/migrate/20100205163027_create_post_versions.rb index 75bd7a77c..c6531d4bf 100644 --- a/db/migrate/20100205163027_create_post_versions.rb +++ b/db/migrate/20100205163027_create_post_versions.rb @@ -1,4 +1,4 @@ -class CreatePostVersions < ActiveRecord::Migration +class CreatePostVersions < ActiveRecord::Migration[4.2] def self.up create_table :post_versions do |t| t.timestamps diff --git a/db/migrate/20100205224030_create_uploads.rb b/db/migrate/20100205224030_create_uploads.rb index a55e4d444..3fec422dc 100644 --- a/db/migrate/20100205224030_create_uploads.rb +++ b/db/migrate/20100205224030_create_uploads.rb @@ -1,4 +1,4 @@ -class CreateUploads < ActiveRecord::Migration +class CreateUploads < ActiveRecord::Migration[4.2] def self.up create_table :uploads do |t| t.column :source, :string diff --git a/db/migrate/20100211025616_create_pools.rb b/db/migrate/20100211025616_create_pools.rb index b8fb224ad..c85107fbd 100644 --- a/db/migrate/20100211025616_create_pools.rb +++ b/db/migrate/20100211025616_create_pools.rb @@ -1,4 +1,4 @@ -class CreatePools < ActiveRecord::Migration +class CreatePools < ActiveRecord::Migration[4.2] def self.up create_table :pools do |t| t.column :name, :string diff --git a/db/migrate/20100211181944_create_favorites.rb b/db/migrate/20100211181944_create_favorites.rb index c3f38fb4d..bcaff3d71 100644 --- a/db/migrate/20100211181944_create_favorites.rb +++ b/db/migrate/20100211181944_create_favorites.rb @@ -1,4 +1,4 @@ -class CreateFavorites < ActiveRecord::Migration +class CreateFavorites < ActiveRecord::Migration[4.2] TABLE_COUNT = 100 def self.up diff --git a/db/migrate/20100211191709_create_tag_aliases.rb b/db/migrate/20100211191709_create_tag_aliases.rb index 04ba2e5a4..fdc07b1e3 100644 --- a/db/migrate/20100211191709_create_tag_aliases.rb +++ b/db/migrate/20100211191709_create_tag_aliases.rb @@ -1,4 +1,4 @@ -class CreateTagAliases < ActiveRecord::Migration +class CreateTagAliases < ActiveRecord::Migration[4.2] def self.up create_table :tag_aliases do |t| t.column :antecedent_name, :string, :null => false diff --git a/db/migrate/20100211191716_create_tag_implications.rb b/db/migrate/20100211191716_create_tag_implications.rb index c68deada6..f02087ce7 100644 --- a/db/migrate/20100211191716_create_tag_implications.rb +++ b/db/migrate/20100211191716_create_tag_implications.rb @@ -1,4 +1,4 @@ -class CreateTagImplications < ActiveRecord::Migration +class CreateTagImplications < ActiveRecord::Migration[4.2] def self.up create_table :tag_implications do |t| t.column :antecedent_name, :string, :null => false diff --git a/db/migrate/20100213181847_create_comments.rb b/db/migrate/20100213181847_create_comments.rb index 24654ad34..b59645826 100644 --- a/db/migrate/20100213181847_create_comments.rb +++ b/db/migrate/20100213181847_create_comments.rb @@ -1,4 +1,4 @@ -class CreateComments < ActiveRecord::Migration +class CreateComments < ActiveRecord::Migration[4.2] def self.up create_table :comments do |t| t.column :post_id, :integer, :null => false diff --git a/db/migrate/20100213183712_create_comment_votes.rb b/db/migrate/20100213183712_create_comment_votes.rb index c7e4610a0..9bee88cb7 100644 --- a/db/migrate/20100213183712_create_comment_votes.rb +++ b/db/migrate/20100213183712_create_comment_votes.rb @@ -1,4 +1,4 @@ -class CreateCommentVotes < ActiveRecord::Migration +class CreateCommentVotes < ActiveRecord::Migration[4.2] def self.up create_table :comment_votes do |t| t.column :comment_id, :integer, :null => false diff --git a/db/migrate/20100214080549_create_artists.rb b/db/migrate/20100214080549_create_artists.rb index b4e29dfba..b9ed0a0ac 100644 --- a/db/migrate/20100214080549_create_artists.rb +++ b/db/migrate/20100214080549_create_artists.rb @@ -1,4 +1,4 @@ -class CreateArtists < ActiveRecord::Migration +class CreateArtists < ActiveRecord::Migration[4.2] def self.up create_table :artists do |t| t.column :name, :string, :null => false diff --git a/db/migrate/20100214080557_create_artist_versions.rb b/db/migrate/20100214080557_create_artist_versions.rb index a50b47ed4..566b648e6 100644 --- a/db/migrate/20100214080557_create_artist_versions.rb +++ b/db/migrate/20100214080557_create_artist_versions.rb @@ -1,4 +1,4 @@ -class CreateArtistVersions < ActiveRecord::Migration +class CreateArtistVersions < ActiveRecord::Migration[4.2] def self.up create_table :artist_versions do |t| t.column :artist_id, :integer, :null => false diff --git a/db/migrate/20100214080605_create_artist_urls.rb b/db/migrate/20100214080605_create_artist_urls.rb index b30b1a5ef..0290ee20f 100644 --- a/db/migrate/20100214080605_create_artist_urls.rb +++ b/db/migrate/20100214080605_create_artist_urls.rb @@ -1,4 +1,4 @@ -class CreateArtistUrls < ActiveRecord::Migration +class CreateArtistUrls < ActiveRecord::Migration[4.2] def self.up create_table :artist_urls do |t| t.column :artist_id, :integer, :null => false diff --git a/db/migrate/20100215182234_create_wiki_pages.rb b/db/migrate/20100215182234_create_wiki_pages.rb index 9f85ce257..e380f057f 100644 --- a/db/migrate/20100215182234_create_wiki_pages.rb +++ b/db/migrate/20100215182234_create_wiki_pages.rb @@ -1,4 +1,4 @@ -class CreateWikiPages < ActiveRecord::Migration +class CreateWikiPages < ActiveRecord::Migration[4.2] def self.up create_table :wiki_pages do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20100215213756_create_wiki_page_versions.rb b/db/migrate/20100215213756_create_wiki_page_versions.rb index 7ef0d0515..ee10464ee 100644 --- a/db/migrate/20100215213756_create_wiki_page_versions.rb +++ b/db/migrate/20100215213756_create_wiki_page_versions.rb @@ -1,4 +1,4 @@ -class CreateWikiPageVersions < ActiveRecord::Migration +class CreateWikiPageVersions < ActiveRecord::Migration[4.2] def self.up create_table :wiki_page_versions do |t| t.column :wiki_page_id, :integer, :null => false diff --git a/db/migrate/20100215223541_create_post_votes.rb b/db/migrate/20100215223541_create_post_votes.rb index 56c60dc9a..86af71068 100644 --- a/db/migrate/20100215223541_create_post_votes.rb +++ b/db/migrate/20100215223541_create_post_votes.rb @@ -1,4 +1,4 @@ -class CreatePostVotes < ActiveRecord::Migration +class CreatePostVotes < ActiveRecord::Migration[4.2] def self.up create_table :post_votes do |t| t.column :post_id, :integer, :null => false diff --git a/db/migrate/20100215224629_create_advertisements.rb b/db/migrate/20100215224629_create_advertisements.rb index 67fafc14d..85a58f8e0 100644 --- a/db/migrate/20100215224629_create_advertisements.rb +++ b/db/migrate/20100215224629_create_advertisements.rb @@ -1,4 +1,4 @@ -class CreateAdvertisements < ActiveRecord::Migration +class CreateAdvertisements < ActiveRecord::Migration[4.2] def self.up create_table :advertisements do |t| t.column :referral_url, :text, :null => false diff --git a/db/migrate/20100215224635_create_advertisement_hits.rb b/db/migrate/20100215224635_create_advertisement_hits.rb index f152ffee3..cfac7701f 100644 --- a/db/migrate/20100215224635_create_advertisement_hits.rb +++ b/db/migrate/20100215224635_create_advertisement_hits.rb @@ -1,4 +1,4 @@ -class CreateAdvertisementHits < ActiveRecord::Migration +class CreateAdvertisementHits < ActiveRecord::Migration[4.2] def self.up create_table :advertisement_hits do |t| t.column :advertisement_id, :integer, :null => false diff --git a/db/migrate/20100215225710_create_bans.rb b/db/migrate/20100215225710_create_bans.rb index 3e0c6e49a..f586323b2 100644 --- a/db/migrate/20100215225710_create_bans.rb +++ b/db/migrate/20100215225710_create_bans.rb @@ -1,4 +1,4 @@ -class CreateBans < ActiveRecord::Migration +class CreateBans < ActiveRecord::Migration[4.2] def self.up create_table :bans do |t| t.column :user_id, :integer diff --git a/db/migrate/20100215230642_create_user_feedback.rb b/db/migrate/20100215230642_create_user_feedback.rb index 49d5bd3cf..b7d3c912a 100644 --- a/db/migrate/20100215230642_create_user_feedback.rb +++ b/db/migrate/20100215230642_create_user_feedback.rb @@ -1,4 +1,4 @@ -class CreateUserFeedback < ActiveRecord::Migration +class CreateUserFeedback < ActiveRecord::Migration[4.2] def self.up create_table :user_feedback do |t| t.column :user_id, :integer, :null => false diff --git a/db/migrate/20100219230537_create_dmails.rb b/db/migrate/20100219230537_create_dmails.rb index 61fc4136d..711f7f26c 100644 --- a/db/migrate/20100219230537_create_dmails.rb +++ b/db/migrate/20100219230537_create_dmails.rb @@ -1,4 +1,4 @@ -class CreateDmails < ActiveRecord::Migration +class CreateDmails < ActiveRecord::Migration[4.2] def self.up create_table :dmails do |t| t.column :owner_id, :integer, :null => false diff --git a/db/migrate/20100221003655_create_forum_topics.rb b/db/migrate/20100221003655_create_forum_topics.rb index 5f0845ffc..528129a53 100644 --- a/db/migrate/20100221003655_create_forum_topics.rb +++ b/db/migrate/20100221003655_create_forum_topics.rb @@ -1,4 +1,4 @@ -class CreateForumTopics < ActiveRecord::Migration +class CreateForumTopics < ActiveRecord::Migration[4.2] def self.up create_table :forum_topics do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20100221005812_create_forum_posts.rb b/db/migrate/20100221005812_create_forum_posts.rb index a204d20a6..04b4298f6 100644 --- a/db/migrate/20100221005812_create_forum_posts.rb +++ b/db/migrate/20100221005812_create_forum_posts.rb @@ -1,4 +1,4 @@ -class CreateForumPosts < ActiveRecord::Migration +class CreateForumPosts < ActiveRecord::Migration[4.2] def self.up create_table :forum_posts do |t| t.column :topic_id, :integer, :null => false diff --git a/db/migrate/20100223001012_create_post_disapprovals.rb b/db/migrate/20100223001012_create_post_disapprovals.rb index 3ca5ccbd5..36643a925 100644 --- a/db/migrate/20100223001012_create_post_disapprovals.rb +++ b/db/migrate/20100223001012_create_post_disapprovals.rb @@ -1,4 +1,4 @@ -class CreatePostDisapprovals < ActiveRecord::Migration +class CreatePostDisapprovals < ActiveRecord::Migration[4.2] def self.up create_table :post_disapprovals do |t| t.column :user_id, :integer, :null => false diff --git a/db/migrate/20100224171915_create_notes.rb b/db/migrate/20100224171915_create_notes.rb index 69fbbe362..2b645276a 100644 --- a/db/migrate/20100224171915_create_notes.rb +++ b/db/migrate/20100224171915_create_notes.rb @@ -1,4 +1,4 @@ -class CreateNotes < ActiveRecord::Migration +class CreateNotes < ActiveRecord::Migration[4.2] def self.up create_table :notes do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20100224172146_create_note_versions.rb b/db/migrate/20100224172146_create_note_versions.rb index fde7aaa47..2534f9fc1 100644 --- a/db/migrate/20100224172146_create_note_versions.rb +++ b/db/migrate/20100224172146_create_note_versions.rb @@ -1,4 +1,4 @@ -class CreateNoteVersions < ActiveRecord::Migration +class CreateNoteVersions < ActiveRecord::Migration[4.2] def self.up create_table :note_versions do |t| t.column :note_id, :integer, :null => false diff --git a/db/migrate/20100307073438_create_tag_subscriptions.rb b/db/migrate/20100307073438_create_tag_subscriptions.rb index 932c71476..3e40b0e28 100644 --- a/db/migrate/20100307073438_create_tag_subscriptions.rb +++ b/db/migrate/20100307073438_create_tag_subscriptions.rb @@ -1,4 +1,4 @@ -class CreateTagSubscriptions < ActiveRecord::Migration +class CreateTagSubscriptions < ActiveRecord::Migration[4.2] def self.up create_table :tag_subscriptions do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20100309211553_create_janitor_trials.rb b/db/migrate/20100309211553_create_janitor_trials.rb index dbb995599..82710b901 100644 --- a/db/migrate/20100309211553_create_janitor_trials.rb +++ b/db/migrate/20100309211553_create_janitor_trials.rb @@ -1,4 +1,4 @@ -class CreateJanitorTrials < ActiveRecord::Migration +class CreateJanitorTrials < ActiveRecord::Migration[4.2] def self.up create_table :janitor_trials do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20100318213503_create_ip_bans.rb b/db/migrate/20100318213503_create_ip_bans.rb index cd8035047..6826a9916 100644 --- a/db/migrate/20100318213503_create_ip_bans.rb +++ b/db/migrate/20100318213503_create_ip_bans.rb @@ -1,4 +1,4 @@ -class CreateIpBans < ActiveRecord::Migration +class CreateIpBans < ActiveRecord::Migration[4.2] def self.up create_table :ip_bans do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20100826232512_create_delayed_jobs.rb b/db/migrate/20100826232512_create_delayed_jobs.rb index 0c6a50396..1f00dd9cf 100644 --- a/db/migrate/20100826232512_create_delayed_jobs.rb +++ b/db/migrate/20100826232512_create_delayed_jobs.rb @@ -1,4 +1,4 @@ -class CreateDelayedJobs < ActiveRecord::Migration +class CreateDelayedJobs < ActiveRecord::Migration[4.2] def self.up create_table :delayed_jobs, :force => true do |table| table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue diff --git a/db/migrate/20110328215652_create_post_flags.rb b/db/migrate/20110328215652_create_post_flags.rb index f52f09c00..2ac024f82 100644 --- a/db/migrate/20110328215652_create_post_flags.rb +++ b/db/migrate/20110328215652_create_post_flags.rb @@ -1,4 +1,4 @@ -class CreatePostFlags < ActiveRecord::Migration +class CreatePostFlags < ActiveRecord::Migration[4.2] def self.up create_table :post_flags do |t| t.column :post_id, :integer, :null => false diff --git a/db/migrate/20110328215701_create_post_appeals.rb b/db/migrate/20110328215701_create_post_appeals.rb index b238ae8bf..31e3827c4 100644 --- a/db/migrate/20110328215701_create_post_appeals.rb +++ b/db/migrate/20110328215701_create_post_appeals.rb @@ -1,4 +1,4 @@ -class CreatePostAppeals < ActiveRecord::Migration +class CreatePostAppeals < ActiveRecord::Migration[4.2] def self.up create_table :post_appeals do |t| t.column :post_id, :integer, :null => false diff --git a/db/migrate/20110607194023_create_pool_versions.rb b/db/migrate/20110607194023_create_pool_versions.rb index 5d5fb97e3..e0b781853 100644 --- a/db/migrate/20110607194023_create_pool_versions.rb +++ b/db/migrate/20110607194023_create_pool_versions.rb @@ -1,4 +1,4 @@ -class CreatePoolVersions < ActiveRecord::Migration +class CreatePoolVersions < ActiveRecord::Migration[4.2] def up create_table :pool_versions do |t| t.column :pool_id, :integer diff --git a/db/migrate/20110717010705_create_user_password_reset_nonces.rb b/db/migrate/20110717010705_create_user_password_reset_nonces.rb index 55e83b0cc..6098621fd 100644 --- a/db/migrate/20110717010705_create_user_password_reset_nonces.rb +++ b/db/migrate/20110717010705_create_user_password_reset_nonces.rb @@ -1,4 +1,4 @@ -class CreateUserPasswordResetNonces < ActiveRecord::Migration +class CreateUserPasswordResetNonces < ActiveRecord::Migration[4.2] def change create_table :user_password_reset_nonces do |t| t.column :key, :string, :null => false diff --git a/db/migrate/20110722211855_create_mod_actions.rb b/db/migrate/20110722211855_create_mod_actions.rb index 40564cb79..617d62565 100644 --- a/db/migrate/20110722211855_create_mod_actions.rb +++ b/db/migrate/20110722211855_create_mod_actions.rb @@ -1,4 +1,4 @@ -class CreateModActions < ActiveRecord::Migration +class CreateModActions < ActiveRecord::Migration[4.2] def change create_table :mod_actions do |t| t.column :creator_id, :integer, :null => false diff --git a/db/migrate/20110815233456_create_amazon_backups.rb b/db/migrate/20110815233456_create_amazon_backups.rb index 25c41e8d6..dddd3a4c1 100644 --- a/db/migrate/20110815233456_create_amazon_backups.rb +++ b/db/migrate/20110815233456_create_amazon_backups.rb @@ -1,4 +1,4 @@ -class CreateAmazonBackups < ActiveRecord::Migration +class CreateAmazonBackups < ActiveRecord::Migration[4.2] def change create_table :amazon_backups do |t| t.integer :last_id diff --git a/db/migrate/20111101212358_create_news_updates.rb b/db/migrate/20111101212358_create_news_updates.rb index 7825828ca..0ea0e52ae 100644 --- a/db/migrate/20111101212358_create_news_updates.rb +++ b/db/migrate/20111101212358_create_news_updates.rb @@ -1,4 +1,4 @@ -class CreateNewsUpdates < ActiveRecord::Migration +class CreateNewsUpdates < ActiveRecord::Migration[4.2] def change create_table :news_updates do |t| t.column :message, :text, :null => false diff --git a/db/migrate/20130106210658_add_server_to_uploads.rb b/db/migrate/20130106210658_add_server_to_uploads.rb index 940b88ae9..b6a8df165 100644 --- a/db/migrate/20130106210658_add_server_to_uploads.rb +++ b/db/migrate/20130106210658_add_server_to_uploads.rb @@ -1,4 +1,4 @@ -class AddServerToUploads < ActiveRecord::Migration +class AddServerToUploads < ActiveRecord::Migration[4.2] def change add_column :uploads, :server, :text end diff --git a/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb b/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb index 072c8d40c..7c1316f67 100644 --- a/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb +++ b/db/migrate/20130114154400_add_queue_to_delayed_jobs.rb @@ -1,4 +1,4 @@ -class AddQueueToDelayedJobs < ActiveRecord::Migration +class AddQueueToDelayedJobs < ActiveRecord::Migration[4.2] def self.up add_column :delayed_jobs, :queue, :string end diff --git a/db/migrate/20130219171111_change_uploads_source_to_text.rb b/db/migrate/20130219171111_change_uploads_source_to_text.rb index 156db92fa..e80b0f738 100644 --- a/db/migrate/20130219171111_change_uploads_source_to_text.rb +++ b/db/migrate/20130219171111_change_uploads_source_to_text.rb @@ -1,4 +1,4 @@ -class ChangeUploadsSourceToText < ActiveRecord::Migration +class ChangeUploadsSourceToText < ActiveRecord::Migration[4.2] def up execute "alter table uploads alter column source type text" end diff --git a/db/migrate/20130219184743_add_parent_id_to_uploads.rb b/db/migrate/20130219184743_add_parent_id_to_uploads.rb index 2ef6e1729..cb8928aeb 100644 --- a/db/migrate/20130219184743_add_parent_id_to_uploads.rb +++ b/db/migrate/20130219184743_add_parent_id_to_uploads.rb @@ -1,4 +1,4 @@ -class AddParentIdToUploads < ActiveRecord::Migration +class AddParentIdToUploads < ActiveRecord::Migration[4.2] def change add_column :uploads, :parent_id, :integer end diff --git a/db/migrate/20130221032344_add_index_updated_at_on_post_versions.rb b/db/migrate/20130221032344_add_index_updated_at_on_post_versions.rb index 12330543e..395ed2c96 100644 --- a/db/migrate/20130221032344_add_index_updated_at_on_post_versions.rb +++ b/db/migrate/20130221032344_add_index_updated_at_on_post_versions.rb @@ -1,4 +1,4 @@ -class AddIndexUpdatedAtOnPostVersions < ActiveRecord::Migration +class AddIndexUpdatedAtOnPostVersions < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" add_index :post_versions, :updated_at diff --git a/db/migrate/20130221035518_add_index_created_at_on_user_feedback.rb b/db/migrate/20130221035518_add_index_created_at_on_user_feedback.rb index ca490ff03..78ff09b6f 100644 --- a/db/migrate/20130221035518_add_index_created_at_on_user_feedback.rb +++ b/db/migrate/20130221035518_add_index_created_at_on_user_feedback.rb @@ -1,4 +1,4 @@ -class AddIndexCreatedAtOnUserFeedback < ActiveRecord::Migration +class AddIndexCreatedAtOnUserFeedback < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" add_index :user_feedback, :created_at diff --git a/db/migrate/20130221214811_add_index_updated_at_on_pool_versions.rb b/db/migrate/20130221214811_add_index_updated_at_on_pool_versions.rb index 01bca170e..22a15cab5 100644 --- a/db/migrate/20130221214811_add_index_updated_at_on_pool_versions.rb +++ b/db/migrate/20130221214811_add_index_updated_at_on_pool_versions.rb @@ -1,4 +1,4 @@ -class AddIndexUpdatedAtOnPoolVersions < ActiveRecord::Migration +class AddIndexUpdatedAtOnPoolVersions < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" add_index :pool_versions, :updated_at diff --git a/db/migrate/20130302214500_add_index_pixiv_on_posts.rb b/db/migrate/20130302214500_add_index_pixiv_on_posts.rb index cf833e5e8..7cbd137c9 100644 --- a/db/migrate/20130302214500_add_index_pixiv_on_posts.rb +++ b/db/migrate/20130302214500_add_index_pixiv_on_posts.rb @@ -1,4 +1,4 @@ -class AddIndexPixivOnPosts < ActiveRecord::Migration +class AddIndexPixivOnPosts < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" execute "CREATE INDEX index_posts_on_pixiv_suffix ON posts USING btree diff --git a/db/migrate/20130305005138_add_bcrypt_fields_to_users.rb b/db/migrate/20130305005138_add_bcrypt_fields_to_users.rb index f1292e897..01dfc3746 100644 --- a/db/migrate/20130305005138_add_bcrypt_fields_to_users.rb +++ b/db/migrate/20130305005138_add_bcrypt_fields_to_users.rb @@ -1,4 +1,4 @@ -class AddBcryptFieldsToUsers < ActiveRecord::Migration +class AddBcryptFieldsToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" diff --git a/db/migrate/20130307225324_add_settings_to_users.rb b/db/migrate/20130307225324_add_settings_to_users.rb index b18e914f2..a000d152f 100644 --- a/db/migrate/20130307225324_add_settings_to_users.rb +++ b/db/migrate/20130307225324_add_settings_to_users.rb @@ -1,4 +1,4 @@ -class AddSettingsToUsers < ActiveRecord::Migration +class AddSettingsToUsers < ActiveRecord::Migration[4.2] def change add_column :users, :enable_post_navigation, :boolean, :null => false, :default => true add_column :users, :new_post_navigation_layout, :boolean, :null => false, :default => true diff --git a/db/migrate/20130308204213_add_lower_name_index_to_pools.rb b/db/migrate/20130308204213_add_lower_name_index_to_pools.rb index 6deddeee1..af1a1ea2e 100644 --- a/db/migrate/20130308204213_add_lower_name_index_to_pools.rb +++ b/db/migrate/20130308204213_add_lower_name_index_to_pools.rb @@ -1,4 +1,4 @@ -class AddLowerNameIndexToPools < ActiveRecord::Migration +class AddLowerNameIndexToPools < ActiveRecord::Migration[4.2] def self.up execute "create index index_pools_on_lower_name on pools (lower(name))" end diff --git a/db/migrate/20130318002652_add_updater_info_to_comments.rb b/db/migrate/20130318002652_add_updater_info_to_comments.rb index d8815fead..0e90bed06 100644 --- a/db/migrate/20130318002652_add_updater_info_to_comments.rb +++ b/db/migrate/20130318002652_add_updater_info_to_comments.rb @@ -1,4 +1,4 @@ -class AddUpdaterInfoToComments < ActiveRecord::Migration +class AddUpdaterInfoToComments < ActiveRecord::Migration[4.2] def change add_column :comments, :updater_id, :integer add_column :comments, :updater_ip_addr, "inet" diff --git a/db/migrate/20130318012517_add_updated_at_index_to_wiki_pages.rb b/db/migrate/20130318012517_add_updated_at_index_to_wiki_pages.rb index 29b9ff8f8..6ce5b94da 100644 --- a/db/migrate/20130318012517_add_updated_at_index_to_wiki_pages.rb +++ b/db/migrate/20130318012517_add_updated_at_index_to_wiki_pages.rb @@ -1,4 +1,4 @@ -class AddUpdatedAtIndexToWikiPages < ActiveRecord::Migration +class AddUpdatedAtIndexToWikiPages < ActiveRecord::Migration[4.2] def change # add_index :wiki_pages, :updated_at end diff --git a/db/migrate/20130318030619_add_enable_post_seq_navigation_to_users.rb b/db/migrate/20130318030619_add_enable_post_seq_navigation_to_users.rb index d89a09c08..10a87f78d 100644 --- a/db/migrate/20130318030619_add_enable_post_seq_navigation_to_users.rb +++ b/db/migrate/20130318030619_add_enable_post_seq_navigation_to_users.rb @@ -1,4 +1,4 @@ -class AddEnablePostSeqNavigationToUsers < ActiveRecord::Migration +class AddEnablePostSeqNavigationToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :users, :enable_sequential_post_navigation, :boolean, :null => false, :default => true diff --git a/db/migrate/20130318231740_change_tag_subscription_tag_query_type.rb b/db/migrate/20130318231740_change_tag_subscription_tag_query_type.rb index 59f3ebc24..36965e464 100644 --- a/db/migrate/20130318231740_change_tag_subscription_tag_query_type.rb +++ b/db/migrate/20130318231740_change_tag_subscription_tag_query_type.rb @@ -1,4 +1,4 @@ -class ChangeTagSubscriptionTagQueryType < ActiveRecord::Migration +class ChangeTagSubscriptionTagQueryType < ActiveRecord::Migration[4.2] def up execute "alter table tag_subscriptions alter column tag_query type text" end diff --git a/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb b/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb index 9443a5094..5ab42461d 100644 --- a/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb +++ b/db/migrate/20130320070700_add_updater_id_to_wiki_pages.rb @@ -1,4 +1,4 @@ -class AddUpdaterIdToWikiPages < ActiveRecord::Migration +class AddUpdaterIdToWikiPages < ActiveRecord::Migration[4.2] def change add_column :wiki_pages, :updater_id, :integer end diff --git a/db/migrate/20130322162059_add_is_banned_to_posts.rb b/db/migrate/20130322162059_add_is_banned_to_posts.rb index cfc551148..af4f2f708 100644 --- a/db/migrate/20130322162059_add_is_banned_to_posts.rb +++ b/db/migrate/20130322162059_add_is_banned_to_posts.rb @@ -1,4 +1,4 @@ -class AddIsBannedToPosts < ActiveRecord::Migration +class AddIsBannedToPosts < ActiveRecord::Migration[4.2] def up execute("set statement_timeout = 0") add_column :posts, :is_banned, :boolean, :null => false, :default => false diff --git a/db/migrate/20130322173202_add_per_page_to_users.rb b/db/migrate/20130322173202_add_per_page_to_users.rb index 8e1c42a06..7462b2ff3 100644 --- a/db/migrate/20130322173202_add_per_page_to_users.rb +++ b/db/migrate/20130322173202_add_per_page_to_users.rb @@ -1,4 +1,4 @@ -class AddPerPageToUsers < ActiveRecord::Migration +class AddPerPageToUsers < ActiveRecord::Migration[4.2] def change execute("set statement_timeout = 0") add_column :users, :per_page, :integer, :null => false, :default => 20 diff --git a/db/migrate/20130322173859_add_version_to_notes.rb b/db/migrate/20130322173859_add_version_to_notes.rb index 2e96bbb39..5847dc470 100644 --- a/db/migrate/20130322173859_add_version_to_notes.rb +++ b/db/migrate/20130322173859_add_version_to_notes.rb @@ -1,4 +1,4 @@ -class AddVersionToNotes < ActiveRecord::Migration +class AddVersionToNotes < ActiveRecord::Migration[4.2] def change execute("set statement_timeout = 0") add_column :notes, :version, :integer, :null => false, :default => 0 diff --git a/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb b/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb index 95d59f4d3..42b54f4ad 100644 --- a/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb +++ b/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb @@ -1,4 +1,4 @@ -class AddHideDeletedPostsToUsers < ActiveRecord::Migration +class AddHideDeletedPostsToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :users, :hide_deleted_posts, :boolean, :null => false, :default => false diff --git a/db/migrate/20130326035904_create_user_name_change_requests.rb b/db/migrate/20130326035904_create_user_name_change_requests.rb index 4c8c02b96..38f76e392 100644 --- a/db/migrate/20130326035904_create_user_name_change_requests.rb +++ b/db/migrate/20130326035904_create_user_name_change_requests.rb @@ -1,4 +1,4 @@ -class CreateUserNameChangeRequests < ActiveRecord::Migration +class CreateUserNameChangeRequests < ActiveRecord::Migration[4.2] def up create_table :user_name_change_requests do |t| t.string :status, :null => false, :default => "pending" diff --git a/db/migrate/20130328092739_change_source_pattern_index_on_posts.rb b/db/migrate/20130328092739_change_source_pattern_index_on_posts.rb index 741db8bff..fe0516c83 100644 --- a/db/migrate/20130328092739_change_source_pattern_index_on_posts.rb +++ b/db/migrate/20130328092739_change_source_pattern_index_on_posts.rb @@ -1,4 +1,4 @@ -class ChangeSourcePatternIndexOnPosts < ActiveRecord::Migration +class ChangeSourcePatternIndexOnPosts < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" execute "DROP INDEX index_posts_on_pixiv_suffix" diff --git a/db/migrate/20130331180246_create_key_values.rb b/db/migrate/20130331180246_create_key_values.rb index 0cca57e3a..09faa312c 100644 --- a/db/migrate/20130331180246_create_key_values.rb +++ b/db/migrate/20130331180246_create_key_values.rb @@ -1,4 +1,4 @@ -class CreateKeyValues < ActiveRecord::Migration +class CreateKeyValues < ActiveRecord::Migration[4.2] def change create_table :key_values do |t| t.string :key, :null => false diff --git a/db/migrate/20130331182719_add_pixiv_id_to_posts.rb b/db/migrate/20130331182719_add_pixiv_id_to_posts.rb index 8e777b0ec..6c0fe1433 100644 --- a/db/migrate/20130331182719_add_pixiv_id_to_posts.rb +++ b/db/migrate/20130331182719_add_pixiv_id_to_posts.rb @@ -1,4 +1,4 @@ -class AddPixivIdToPosts < ActiveRecord::Migration +class AddPixivIdToPosts < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" add_column :posts, :pixiv_id, :integer diff --git a/db/migrate/20130401013601_drop_index_posts_on_created_at_date.rb b/db/migrate/20130401013601_drop_index_posts_on_created_at_date.rb index 1c2d59212..2eb7dbc1b 100644 --- a/db/migrate/20130401013601_drop_index_posts_on_created_at_date.rb +++ b/db/migrate/20130401013601_drop_index_posts_on_created_at_date.rb @@ -1,4 +1,4 @@ -class DropIndexPostsOnCreatedAtDate < ActiveRecord::Migration +class DropIndexPostsOnCreatedAtDate < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" execute "drop index index_posts_on_created_at_date" diff --git a/db/migrate/20130409191950_add_creator_id_index_to_comments.rb b/db/migrate/20130409191950_add_creator_id_index_to_comments.rb index b8cd8246f..244e6a858 100644 --- a/db/migrate/20130409191950_add_creator_id_index_to_comments.rb +++ b/db/migrate/20130409191950_add_creator_id_index_to_comments.rb @@ -1,4 +1,4 @@ -class AddCreatorIdIndexToComments < ActiveRecord::Migration +class AddCreatorIdIndexToComments < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_index :comments, :creator_id diff --git a/db/migrate/20130417221643_add_style_usernames_to_users.rb b/db/migrate/20130417221643_add_style_usernames_to_users.rb index b0d54699c..acccf6239 100644 --- a/db/migrate/20130417221643_add_style_usernames_to_users.rb +++ b/db/migrate/20130417221643_add_style_usernames_to_users.rb @@ -1,4 +1,4 @@ -class AddStyleUsernamesToUsers < ActiveRecord::Migration +class AddStyleUsernamesToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :users, :style_usernames, :boolean, :null => false, :default => false diff --git a/db/migrate/20130424121410_add_name_to_pool_versions.rb b/db/migrate/20130424121410_add_name_to_pool_versions.rb index a63fb4b4c..b0b679344 100644 --- a/db/migrate/20130424121410_add_name_to_pool_versions.rb +++ b/db/migrate/20130424121410_add_name_to_pool_versions.rb @@ -1,4 +1,4 @@ -class AddNameToPoolVersions < ActiveRecord::Migration +class AddNameToPoolVersions < ActiveRecord::Migration[4.2] def change execute("set statement_timeout = 0") add_column :pool_versions, :name, :string diff --git a/db/migrate/20130506154136_add_category_to_pools.rb b/db/migrate/20130506154136_add_category_to_pools.rb index 61be564d8..f9e758548 100644 --- a/db/migrate/20130506154136_add_category_to_pools.rb +++ b/db/migrate/20130506154136_add_category_to_pools.rb @@ -1,4 +1,4 @@ -class AddCategoryToPools < ActiveRecord::Migration +class AddCategoryToPools < ActiveRecord::Migration[4.2] def change execute("set statement_timeout = 0") add_column :pools, :category, :string, :null => false, :default => "series" diff --git a/db/migrate/20130606224559_add_category_to_forum_topics.rb b/db/migrate/20130606224559_add_category_to_forum_topics.rb index 852c8f7cc..b5e441fb0 100644 --- a/db/migrate/20130606224559_add_category_to_forum_topics.rb +++ b/db/migrate/20130606224559_add_category_to_forum_topics.rb @@ -1,4 +1,4 @@ -class AddCategoryToForumTopics < ActiveRecord::Migration +class AddCategoryToForumTopics < ActiveRecord::Migration[4.2] def change add_column :forum_topics, :category_id, :integer, :default => 0, :null => false end diff --git a/db/migrate/20130618230158_add_enable_auto_complete_to_users.rb b/db/migrate/20130618230158_add_enable_auto_complete_to_users.rb index bdcffcaa4..a79575054 100644 --- a/db/migrate/20130618230158_add_enable_auto_complete_to_users.rb +++ b/db/migrate/20130618230158_add_enable_auto_complete_to_users.rb @@ -1,4 +1,4 @@ -class AddEnableAutoCompleteToUsers < ActiveRecord::Migration +class AddEnableAutoCompleteToUsers < ActiveRecord::Migration[4.2] def change execute("set statement_timeout = 0") add_column :users, :enable_auto_complete, :boolean, :null => false, :default => :true diff --git a/db/migrate/20130620215658_add_is_locked_to_tags.rb b/db/migrate/20130620215658_add_is_locked_to_tags.rb index 1d9575a15..a1127b00b 100644 --- a/db/migrate/20130620215658_add_is_locked_to_tags.rb +++ b/db/migrate/20130620215658_add_is_locked_to_tags.rb @@ -1,4 +1,4 @@ -class AddIsLockedToTags < ActiveRecord::Migration +class AddIsLockedToTags < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :tags, :is_locked, :boolean, :null => false, :default => false diff --git a/db/migrate/20130712162600_add_custom_style_to_users.rb b/db/migrate/20130712162600_add_custom_style_to_users.rb index 1b1531480..9394d075e 100644 --- a/db/migrate/20130712162600_add_custom_style_to_users.rb +++ b/db/migrate/20130712162600_add_custom_style_to_users.rb @@ -1,4 +1,4 @@ -class AddCustomStyleToUsers < ActiveRecord::Migration +class AddCustomStyleToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :users, :custom_style, :text diff --git a/db/migrate/20130914175431_change_tag_subscription_tag_query_delimiter.rb b/db/migrate/20130914175431_change_tag_subscription_tag_query_delimiter.rb index cff832954..e29e2e7c6 100644 --- a/db/migrate/20130914175431_change_tag_subscription_tag_query_delimiter.rb +++ b/db/migrate/20130914175431_change_tag_subscription_tag_query_delimiter.rb @@ -1,4 +1,4 @@ -class ChangeTagSubscriptionTagQueryDelimiter < ActiveRecord::Migration +class ChangeTagSubscriptionTagQueryDelimiter < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" TagSubscription.find_each do |tag_subscription| diff --git a/db/migrate/20131006193238_update_aliased_implication_consequents.rb b/db/migrate/20131006193238_update_aliased_implication_consequents.rb index 93fea565e..4e703c587 100644 --- a/db/migrate/20131006193238_update_aliased_implication_consequents.rb +++ b/db/migrate/20131006193238_update_aliased_implication_consequents.rb @@ -1,4 +1,4 @@ -class UpdateAliasedImplicationConsequents < ActiveRecord::Migration +class UpdateAliasedImplicationConsequents < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" TagImplication.find_each do |ti| diff --git a/db/migrate/20131117150705_create_artist_commentaries.rb b/db/migrate/20131117150705_create_artist_commentaries.rb index be865730c..502c9c5be 100644 --- a/db/migrate/20131117150705_create_artist_commentaries.rb +++ b/db/migrate/20131117150705_create_artist_commentaries.rb @@ -1,4 +1,4 @@ -class CreateArtistCommentaries < ActiveRecord::Migration +class CreateArtistCommentaries < ActiveRecord::Migration[4.2] def self.up create_table :artist_commentaries do |t| t.integer :post_id, :null => false diff --git a/db/migrate/20131118153503_create_artist_commentary_versions.rb b/db/migrate/20131118153503_create_artist_commentary_versions.rb index f0f89e4b4..37933a695 100644 --- a/db/migrate/20131118153503_create_artist_commentary_versions.rb +++ b/db/migrate/20131118153503_create_artist_commentary_versions.rb @@ -1,4 +1,4 @@ -class CreateArtistCommentaryVersions < ActiveRecord::Migration +class CreateArtistCommentaryVersions < ActiveRecord::Migration[4.2] def self.up create_table :artist_commentary_versions do |t| t.integer :post_id, :null => false diff --git a/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb b/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb index 990cd9b4b..15ebb5a5c 100644 --- a/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb +++ b/db/migrate/20131130190411_add_creator_id_and_post_id_indexes_to_comments_and_notes.rb @@ -1,4 +1,4 @@ -class AddCreatorIdAndPostIdIndexesToCommentsAndNotes < ActiveRecord::Migration +class AddCreatorIdAndPostIdIndexesToCommentsAndNotes < ActiveRecord::Migration[4.2] def self.up execute "set statement_timeout = 0" remove_index :comments, :creator_id diff --git a/db/migrate/20131209181023_add_updater_id_and_post_id_indexes_to_note_versions_and_artist_commentary_versions.rb b/db/migrate/20131209181023_add_updater_id_and_post_id_indexes_to_note_versions_and_artist_commentary_versions.rb index 3e0b9bc86..982cea18c 100644 --- a/db/migrate/20131209181023_add_updater_id_and_post_id_indexes_to_note_versions_and_artist_commentary_versions.rb +++ b/db/migrate/20131209181023_add_updater_id_and_post_id_indexes_to_note_versions_and_artist_commentary_versions.rb @@ -1,4 +1,4 @@ -class AddUpdaterIdAndPostIdIndexesToNoteVersionsAndArtistCommentaryVersions < ActiveRecord::Migration +class AddUpdaterIdAndPostIdIndexesToNoteVersionsAndArtistCommentaryVersions < ActiveRecord::Migration[4.2] def self.up execute "set statement_timeout = 0" remove_index :note_versions, :updater_id diff --git a/db/migrate/20131217025233_add_updated_at_and_id_index_to_post_versions.rb b/db/migrate/20131217025233_add_updated_at_and_id_index_to_post_versions.rb index 46cf5585e..cd623017f 100644 --- a/db/migrate/20131217025233_add_updated_at_and_id_index_to_post_versions.rb +++ b/db/migrate/20131217025233_add_updated_at_and_id_index_to_post_versions.rb @@ -1,4 +1,4 @@ -class AddUpdatedAtAndIdIndexToPostVersions < ActiveRecord::Migration +class AddUpdatedAtAndIdIndexToPostVersions < ActiveRecord::Migration[4.2] def self.up execute "set statement_timeout = 0" remove_index :post_versions, :updated_at diff --git a/db/migrate/20131225002748_add_last_comment_bumped_at_to_posts.rb b/db/migrate/20131225002748_add_last_comment_bumped_at_to_posts.rb index 6b3da0768..c7e3adca1 100644 --- a/db/migrate/20131225002748_add_last_comment_bumped_at_to_posts.rb +++ b/db/migrate/20131225002748_add_last_comment_bumped_at_to_posts.rb @@ -1,4 +1,4 @@ -class AddLastCommentBumpedAtToPosts < ActiveRecord::Migration +class AddLastCommentBumpedAtToPosts < ActiveRecord::Migration[4.2] def self.up execute "SET statement_timeout = 0" diff --git a/db/migrate/20140111191413_change_source_index_on_posts.rb b/db/migrate/20140111191413_change_source_index_on_posts.rb index f27645d27..9145bda78 100644 --- a/db/migrate/20140111191413_change_source_index_on_posts.rb +++ b/db/migrate/20140111191413_change_source_index_on_posts.rb @@ -1,4 +1,4 @@ -class ChangeSourceIndexOnPosts < ActiveRecord::Migration +class ChangeSourceIndexOnPosts < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" execute "DROP INDEX index_posts_on_source" diff --git a/db/migrate/20140204233337_create_transaction_log_items.rb b/db/migrate/20140204233337_create_transaction_log_items.rb index bc23fe69d..3b5f188eb 100644 --- a/db/migrate/20140204233337_create_transaction_log_items.rb +++ b/db/migrate/20140204233337_create_transaction_log_items.rb @@ -1,4 +1,4 @@ -class CreateTransactionLogItems < ActiveRecord::Migration +class CreateTransactionLogItems < ActiveRecord::Migration[4.2] def change create_table :transaction_log_items do |t| t.string :category diff --git a/db/migrate/20140221213349_add_ip_addr_to_dmails.rb b/db/migrate/20140221213349_add_ip_addr_to_dmails.rb index df96961a2..0ab8ecef8 100644 --- a/db/migrate/20140221213349_add_ip_addr_to_dmails.rb +++ b/db/migrate/20140221213349_add_ip_addr_to_dmails.rb @@ -1,4 +1,4 @@ -class AddIpAddrToDmails < ActiveRecord::Migration +class AddIpAddrToDmails < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :dmails, :creator_ip_addr, :inet, :null => false, :default => "127.0.0.1" diff --git a/db/migrate/20140428015134_add_show_deleted_children_to_users.rb b/db/migrate/20140428015134_add_show_deleted_children_to_users.rb index 506faa7f1..6ddf822b4 100644 --- a/db/migrate/20140428015134_add_show_deleted_children_to_users.rb +++ b/db/migrate/20140428015134_add_show_deleted_children_to_users.rb @@ -1,4 +1,4 @@ -class AddShowDeletedChildrenToUsers < ActiveRecord::Migration +class AddShowDeletedChildrenToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :users, :show_deleted_children, :boolean, :null => false, :default => false diff --git a/db/migrate/20140505000956_add_other_names_to_wiki_pages.rb b/db/migrate/20140505000956_add_other_names_to_wiki_pages.rb index b6ee5d69d..468598269 100644 --- a/db/migrate/20140505000956_add_other_names_to_wiki_pages.rb +++ b/db/migrate/20140505000956_add_other_names_to_wiki_pages.rb @@ -1,4 +1,4 @@ -class AddOtherNamesToWikiPages < ActiveRecord::Migration +class AddOtherNamesToWikiPages < ActiveRecord::Migration[4.2] def change add_column :wiki_pages, :other_names, :text add_column :wiki_pages, :other_names_index, :tsvector diff --git a/db/migrate/20140603225334_create_saved_searches.rb b/db/migrate/20140603225334_create_saved_searches.rb index ca6162a22..7660331ff 100644 --- a/db/migrate/20140603225334_create_saved_searches.rb +++ b/db/migrate/20140603225334_create_saved_searches.rb @@ -1,4 +1,4 @@ -class CreateSavedSearches < ActiveRecord::Migration +class CreateSavedSearches < ActiveRecord::Migration[4.2] def change create_table :saved_searches do |t| t.integer :user_id diff --git a/db/migrate/20140604002414_add_bit_prefs_to_users.rb b/db/migrate/20140604002414_add_bit_prefs_to_users.rb index fa421803a..af9f85e96 100644 --- a/db/migrate/20140604002414_add_bit_prefs_to_users.rb +++ b/db/migrate/20140604002414_add_bit_prefs_to_users.rb @@ -1,4 +1,4 @@ -class AddBitPrefsToUsers < ActiveRecord::Migration +class AddBitPrefsToUsers < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" add_column :users, :bit_prefs, "bigint", :null => false, :default => 0 diff --git a/db/migrate/20140613004559_create_bulk_update_requests.rb b/db/migrate/20140613004559_create_bulk_update_requests.rb index 25fd5ec96..b53a8a468 100644 --- a/db/migrate/20140613004559_create_bulk_update_requests.rb +++ b/db/migrate/20140613004559_create_bulk_update_requests.rb @@ -1,4 +1,4 @@ -class CreateBulkUpdateRequests < ActiveRecord::Migration +class CreateBulkUpdateRequests < ActiveRecord::Migration[4.2] def change create_table :bulk_update_requests do |t| t.integer :user_id, :null => false diff --git a/db/migrate/20140701224800_create_forum_topic_visits.rb b/db/migrate/20140701224800_create_forum_topic_visits.rb index f01ff4db9..b629a06ff 100644 --- a/db/migrate/20140701224800_create_forum_topic_visits.rb +++ b/db/migrate/20140701224800_create_forum_topic_visits.rb @@ -1,4 +1,4 @@ -class CreateForumTopicVisits < ActiveRecord::Migration +class CreateForumTopicVisits < ActiveRecord::Migration[4.2] def change create_table :forum_topic_visits do |t| t.integer :user_id diff --git a/db/migrate/20140722225753_create_api_keys.rb b/db/migrate/20140722225753_create_api_keys.rb index a9f161658..546bee77e 100644 --- a/db/migrate/20140722225753_create_api_keys.rb +++ b/db/migrate/20140722225753_create_api_keys.rb @@ -1,4 +1,4 @@ -class CreateApiKeys < ActiveRecord::Migration +class CreateApiKeys < ActiveRecord::Migration[4.2] def change create_table :api_keys do |t| t.integer :user_id, :null => false diff --git a/db/migrate/20140725003232_create_forum_subscriptions.rb b/db/migrate/20140725003232_create_forum_subscriptions.rb index 9264e1694..1b1fe7c0d 100644 --- a/db/migrate/20140725003232_create_forum_subscriptions.rb +++ b/db/migrate/20140725003232_create_forum_subscriptions.rb @@ -1,4 +1,4 @@ -class CreateForumSubscriptions < ActiveRecord::Migration +class CreateForumSubscriptions < ActiveRecord::Migration[4.2] def change create_table :forum_subscriptions do |t| t.integer :user_id diff --git a/db/migrate/20141009231234_create_pixiv_ugoira_frame_data.rb b/db/migrate/20141009231234_create_pixiv_ugoira_frame_data.rb index ec175ee0e..64d4a1dfb 100644 --- a/db/migrate/20141009231234_create_pixiv_ugoira_frame_data.rb +++ b/db/migrate/20141009231234_create_pixiv_ugoira_frame_data.rb @@ -1,4 +1,4 @@ -class CreatePixivUgoiraFrameData < ActiveRecord::Migration +class CreatePixivUgoiraFrameData < ActiveRecord::Migration[4.2] def change create_table :pixiv_ugoira_frame_data do |t| t.integer :post_id diff --git a/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb b/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb index 9e6d48eba..2d3ec0448 100644 --- a/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb +++ b/db/migrate/20141017231608_fix_pixiv_ugoira_frame_data.rb @@ -1,4 +1,4 @@ -class FixPixivUgoiraFrameData < ActiveRecord::Migration +class FixPixivUgoiraFrameData < ActiveRecord::Migration[4.2] def change change_table :pixiv_ugoira_frame_data do |t| t.change :data, :text, :null => false diff --git a/db/migrate/20141120045943_create_dmail_filters.rb b/db/migrate/20141120045943_create_dmail_filters.rb index 025e4d874..1f8da3172 100644 --- a/db/migrate/20141120045943_create_dmail_filters.rb +++ b/db/migrate/20141120045943_create_dmail_filters.rb @@ -1,4 +1,4 @@ -class CreateDmailFilters < ActiveRecord::Migration +class CreateDmailFilters < ActiveRecord::Migration[4.2] def change create_table :dmail_filters do |t| t.integer :user_id, :null => false diff --git a/db/migrate/20150119191042_add_updated_at_index_to_forum_topics.rb b/db/migrate/20150119191042_add_updated_at_index_to_forum_topics.rb index 1cd7a6116..d36b7cde7 100644 --- a/db/migrate/20150119191042_add_updated_at_index_to_forum_topics.rb +++ b/db/migrate/20150119191042_add_updated_at_index_to_forum_topics.rb @@ -1,4 +1,4 @@ -class AddUpdatedAtIndexToForumTopics < ActiveRecord::Migration +class AddUpdatedAtIndexToForumTopics < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" add_index :forum_topics, :updated_at diff --git a/db/migrate/20150120005624_remove_unused_indexes.rb b/db/migrate/20150120005624_remove_unused_indexes.rb index 32890b329..9c05aeecf 100644 --- a/db/migrate/20150120005624_remove_unused_indexes.rb +++ b/db/migrate/20150120005624_remove_unused_indexes.rb @@ -1,7 +1,10 @@ -class RemoveUnusedIndexes < ActiveRecord::Migration +class RemoveUnusedIndexes < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" - remove_index :posts, :source - remove_index :posts, :uploader_ip_addr + begin + remove_index :posts, :source + remove_index :posts, :uploader_ip_addr + rescue ArgumentError + end end end diff --git a/db/migrate/20150128005954_add_bit_flags_to_posts.rb b/db/migrate/20150128005954_add_bit_flags_to_posts.rb index 71212d5be..e1c4ca90f 100644 --- a/db/migrate/20150128005954_add_bit_flags_to_posts.rb +++ b/db/migrate/20150128005954_add_bit_flags_to_posts.rb @@ -1,4 +1,4 @@ -class AddBitFlagsToPosts < ActiveRecord::Migration +class AddBitFlagsToPosts < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :posts, :bit_flags, "bigint", :null => false, :default => 0 diff --git a/db/migrate/20150403224949_add_antecedent_name_pattern_index_and_post_count_to_tag_aliases.rb b/db/migrate/20150403224949_add_antecedent_name_pattern_index_and_post_count_to_tag_aliases.rb index abb854ddd..90928bf32 100644 --- a/db/migrate/20150403224949_add_antecedent_name_pattern_index_and_post_count_to_tag_aliases.rb +++ b/db/migrate/20150403224949_add_antecedent_name_pattern_index_and_post_count_to_tag_aliases.rb @@ -1,4 +1,4 @@ -class AddAntecedentNamePatternIndexAndPostCountToTagAliases < ActiveRecord::Migration +class AddAntecedentNamePatternIndexAndPostCountToTagAliases < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" execute "create index index_tag_aliases_on_antecedent_name_pattern on tag_aliases (antecedent_name text_pattern_ops)" diff --git a/db/migrate/20150613010904_add_status_to_janitor_trials.rb b/db/migrate/20150613010904_add_status_to_janitor_trials.rb index 7fee0f75f..4c4c35966 100644 --- a/db/migrate/20150613010904_add_status_to_janitor_trials.rb +++ b/db/migrate/20150613010904_add_status_to_janitor_trials.rb @@ -1,4 +1,4 @@ -class AddStatusToJanitorTrials < ActiveRecord::Migration +class AddStatusToJanitorTrials < ActiveRecord::Migration[4.2] def change add_column :janitor_trials, :status, :string, :null => false, :default => "active" end diff --git a/db/migrate/20150623191904_create_favorite_groups.rb b/db/migrate/20150623191904_create_favorite_groups.rb index 5662fa4d1..4f34e75ee 100644 --- a/db/migrate/20150623191904_create_favorite_groups.rb +++ b/db/migrate/20150623191904_create_favorite_groups.rb @@ -1,4 +1,4 @@ -class CreateFavoriteGroups < ActiveRecord::Migration +class CreateFavoriteGroups < ActiveRecord::Migration[4.2] def self.up create_table :favorite_groups do |t| t.text :name, :null => false diff --git a/db/migrate/20150629235905_remove_not_null_on_janitor_trials.rb b/db/migrate/20150629235905_remove_not_null_on_janitor_trials.rb index 88209fd48..71e67182f 100644 --- a/db/migrate/20150629235905_remove_not_null_on_janitor_trials.rb +++ b/db/migrate/20150629235905_remove_not_null_on_janitor_trials.rb @@ -1,4 +1,4 @@ -class RemoveNotNullOnJanitorTrials < ActiveRecord::Migration +class RemoveNotNullOnJanitorTrials < ActiveRecord::Migration[4.2] def change change_column :janitor_trials, :original_level, :integer, :null => true end diff --git a/db/migrate/20150705014135_add_is_deleted_to_comments.rb b/db/migrate/20150705014135_add_is_deleted_to_comments.rb index dd0b2f86b..72521b5b1 100644 --- a/db/migrate/20150705014135_add_is_deleted_to_comments.rb +++ b/db/migrate/20150705014135_add_is_deleted_to_comments.rb @@ -1,4 +1,4 @@ -class AddIsDeletedToComments < ActiveRecord::Migration +class AddIsDeletedToComments < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :comments, :is_deleted, :boolean, :null => false, :default => false diff --git a/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb b/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb index f85b5e0ad..0a715b631 100644 --- a/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb +++ b/db/migrate/20150721214646_add_reason_to_post_disapprovals.rb @@ -1,4 +1,4 @@ -class AddReasonToPostDisapprovals < ActiveRecord::Migration +class AddReasonToPostDisapprovals < ActiveRecord::Migration[4.2] def change add_column :post_disapprovals, :reason, :string, :default => "legacy" end diff --git a/db/migrate/20150728170433_add_default_blacklist_to_users.rb b/db/migrate/20150728170433_add_default_blacklist_to_users.rb index b6cf768da..28a380deb 100644 --- a/db/migrate/20150728170433_add_default_blacklist_to_users.rb +++ b/db/migrate/20150728170433_add_default_blacklist_to_users.rb @@ -1,4 +1,4 @@ -class AddDefaultBlacklistToUsers < ActiveRecord::Migration +class AddDefaultBlacklistToUsers < ActiveRecord::Migration[4.2] def self.up execute "set statement_timeout = 0" blacklist = ["spoilers", "guro", "scat", "furry -rating:s"].join("\n") diff --git a/db/migrate/20150805010245_add_message_to_disapprovals.rb b/db/migrate/20150805010245_add_message_to_disapprovals.rb index 023031c45..77c5b1fd1 100644 --- a/db/migrate/20150805010245_add_message_to_disapprovals.rb +++ b/db/migrate/20150805010245_add_message_to_disapprovals.rb @@ -1,4 +1,4 @@ -class AddMessageToDisapprovals < ActiveRecord::Migration +class AddMessageToDisapprovals < ActiveRecord::Migration[4.2] def change add_column :post_disapprovals, :message, :text end diff --git a/db/migrate/20151217213321_add_last_ip_addr_to_users.rb b/db/migrate/20151217213321_add_last_ip_addr_to_users.rb index 204d731f6..c3d554afe 100644 --- a/db/migrate/20151217213321_add_last_ip_addr_to_users.rb +++ b/db/migrate/20151217213321_add_last_ip_addr_to_users.rb @@ -1,4 +1,4 @@ -class AddLastIpAddrToUsers < ActiveRecord::Migration +class AddLastIpAddrToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :users, :last_ip_addr, :inet diff --git a/db/migrate/20160219004022_add_trigram_index_to_pools.rb b/db/migrate/20160219004022_add_trigram_index_to_pools.rb index d8e847fd5..8a2ca0247 100644 --- a/db/migrate/20160219004022_add_trigram_index_to_pools.rb +++ b/db/migrate/20160219004022_add_trigram_index_to_pools.rb @@ -1,4 +1,4 @@ -class AddTrigramIndexToPools < ActiveRecord::Migration +class AddTrigramIndexToPools < ActiveRecord::Migration[4.2] def up execute "create extension pg_trgm" execute "create index index_pools_on_name_trgm on pools using gin (name gin_trgm_ops)" diff --git a/db/migrate/20160219010854_add_trigram_indexes_to_artists.rb b/db/migrate/20160219010854_add_trigram_indexes_to_artists.rb index 6f99cd9ab..6536ab961 100644 --- a/db/migrate/20160219010854_add_trigram_indexes_to_artists.rb +++ b/db/migrate/20160219010854_add_trigram_indexes_to_artists.rb @@ -1,4 +1,4 @@ -class AddTrigramIndexesToArtists < ActiveRecord::Migration +class AddTrigramIndexesToArtists < ActiveRecord::Migration[4.2] def up execute "create index index_artists_on_name_trgm on artists using gin (name gin_trgm_ops)" execute "create index index_artists_on_group_name_trgm on artists using gin (group_name gin_trgm_ops)" diff --git a/db/migrate/20160219172840_add_index_to_artist_group_name.rb b/db/migrate/20160219172840_add_index_to_artist_group_name.rb index 8d6e05052..03eef99fe 100644 --- a/db/migrate/20160219172840_add_index_to_artist_group_name.rb +++ b/db/migrate/20160219172840_add_index_to_artist_group_name.rb @@ -1,4 +1,4 @@ -class AddIndexToArtistGroupName < ActiveRecord::Migration +class AddIndexToArtistGroupName < ActiveRecord::Migration[4.2] def change # add_index :artists, :group_name end diff --git a/db/migrate/20160222211328_create_super_voters.rb b/db/migrate/20160222211328_create_super_voters.rb index 19acf1c65..d0ab544e9 100644 --- a/db/migrate/20160222211328_create_super_voters.rb +++ b/db/migrate/20160222211328_create_super_voters.rb @@ -1,4 +1,4 @@ -class CreateSuperVoters < ActiveRecord::Migration +class CreateSuperVoters < ActiveRecord::Migration[4.2] def change create_table :super_voters do |t| t.integer :user_id diff --git a/db/migrate/20160526174848_add_approver_id.rb b/db/migrate/20160526174848_add_approver_id.rb index c3311746b..aa8717515 100644 --- a/db/migrate/20160526174848_add_approver_id.rb +++ b/db/migrate/20160526174848_add_approver_id.rb @@ -1,4 +1,4 @@ -class AddApproverId < ActiveRecord::Migration +class AddApproverId < ActiveRecord::Migration[4.2] def change add_column :bulk_update_requests, :approver_id, :integer add_column :tag_aliases, :approver_id, :integer diff --git a/db/migrate/20160820003534_create_post_updates.rb b/db/migrate/20160820003534_create_post_updates.rb index df1bef5c3..f0dd0c028 100644 --- a/db/migrate/20160820003534_create_post_updates.rb +++ b/db/migrate/20160820003534_create_post_updates.rb @@ -1,4 +1,4 @@ -class CreatePostUpdates < ActiveRecord::Migration +class CreatePostUpdates < ActiveRecord::Migration[4.2] def up execute "create unlogged table post_updates ( post_id integer, constraint unique_post_id unique(post_id) )" end diff --git a/db/migrate/20160822230752_remove_uniqueness_constraint_on_post_updates.rb b/db/migrate/20160822230752_remove_uniqueness_constraint_on_post_updates.rb index 7e52d8d46..03c79eafa 100644 --- a/db/migrate/20160822230752_remove_uniqueness_constraint_on_post_updates.rb +++ b/db/migrate/20160822230752_remove_uniqueness_constraint_on_post_updates.rb @@ -1,4 +1,4 @@ -class RemoveUniquenessConstraintOnPostUpdates < ActiveRecord::Migration +class RemoveUniquenessConstraintOnPostUpdates < ActiveRecord::Migration[4.2] def up execute "alter table post_updates drop constraint unique_post_id" end diff --git a/db/migrate/20160919234407_create_anti_voters.rb b/db/migrate/20160919234407_create_anti_voters.rb index 030cb5793..0f40ae94e 100644 --- a/db/migrate/20160919234407_create_anti_voters.rb +++ b/db/migrate/20160919234407_create_anti_voters.rb @@ -1,4 +1,4 @@ -class CreateAntiVoters < ActiveRecord::Migration +class CreateAntiVoters < ActiveRecord::Migration[4.2] def change create_table :anti_voters do |t| t.integer :user_id diff --git a/db/migrate/20161018221128_add_is_deleted_to_wiki_pages.rb b/db/migrate/20161018221128_add_is_deleted_to_wiki_pages.rb index 20e7130b1..d83f319d3 100644 --- a/db/migrate/20161018221128_add_is_deleted_to_wiki_pages.rb +++ b/db/migrate/20161018221128_add_is_deleted_to_wiki_pages.rb @@ -1,4 +1,4 @@ -class AddIsDeletedToWikiPages < ActiveRecord::Migration +class AddIsDeletedToWikiPages < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :wiki_pages, :is_deleted, :boolean, :null => false, :default => false diff --git a/db/migrate/20161024220345_add_min_level_to_forum_topics.rb b/db/migrate/20161024220345_add_min_level_to_forum_topics.rb index 6dfacc31c..9ea6b40b0 100644 --- a/db/migrate/20161024220345_add_min_level_to_forum_topics.rb +++ b/db/migrate/20161024220345_add_min_level_to_forum_topics.rb @@ -1,4 +1,4 @@ -class AddMinLevelToForumTopics < ActiveRecord::Migration +class AddMinLevelToForumTopics < ActiveRecord::Migration[4.2] def change add_column :forum_topics, :min_level, :integer, :default => 0, :null => false end diff --git a/db/migrate/20161101003139_create_post_approvals.rb b/db/migrate/20161101003139_create_post_approvals.rb index 512f62f9f..e60e924f5 100644 --- a/db/migrate/20161101003139_create_post_approvals.rb +++ b/db/migrate/20161101003139_create_post_approvals.rb @@ -1,4 +1,4 @@ -class CreatePostApprovals < ActiveRecord::Migration +class CreatePostApprovals < ActiveRecord::Migration[4.2] def change create_table :post_approvals do |t| t.integer :user_id, null: false diff --git a/db/migrate/20161221225849_drop_transaction_log_items.rb b/db/migrate/20161221225849_drop_transaction_log_items.rb index c985bbf65..4e8dbabde 100644 --- a/db/migrate/20161221225849_drop_transaction_log_items.rb +++ b/db/migrate/20161221225849_drop_transaction_log_items.rb @@ -1,4 +1,4 @@ -class DropTransactionLogItems < ActiveRecord::Migration +class DropTransactionLogItems < ActiveRecord::Migration[4.2] def up drop_table :transaction_log_items end diff --git a/db/migrate/20161227003428_add_sticky_to_comments.rb b/db/migrate/20161227003428_add_sticky_to_comments.rb index e85476383..6c2cf65ae 100644 --- a/db/migrate/20161227003428_add_sticky_to_comments.rb +++ b/db/migrate/20161227003428_add_sticky_to_comments.rb @@ -1,4 +1,4 @@ -class AddStickyToComments < ActiveRecord::Migration +class AddStickyToComments < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :comments, :is_sticky, :boolean, null: false, default: false diff --git a/db/migrate/20161229001201_drop_pool_versions.rb b/db/migrate/20161229001201_drop_pool_versions.rb index 2089cd522..082a1e770 100644 --- a/db/migrate/20161229001201_drop_pool_versions.rb +++ b/db/migrate/20161229001201_drop_pool_versions.rb @@ -1,4 +1,4 @@ -class DropPoolVersions < ActiveRecord::Migration +class DropPoolVersions < ActiveRecord::Migration[4.2] def up drop_table :pool_versions end diff --git a/db/migrate/20170106012138_create_token_buckets.rb b/db/migrate/20170106012138_create_token_buckets.rb index 92c1dc0c6..09823f1e1 100644 --- a/db/migrate/20170106012138_create_token_buckets.rb +++ b/db/migrate/20170106012138_create_token_buckets.rb @@ -1,4 +1,4 @@ -class CreateTokenBuckets < ActiveRecord::Migration +class CreateTokenBuckets < ActiveRecord::Migration[4.2] def up execute "create unlogged table token_buckets (user_id integer, last_touched_at timestamp not null, token_count real not null)" add_index :token_buckets, :user_id, :unique => true diff --git a/db/migrate/20170112021922_add_ip_addr_indexes_to_tables.rb b/db/migrate/20170112021922_add_ip_addr_indexes_to_tables.rb index 6e87fe340..2f53c807a 100644 --- a/db/migrate/20170112021922_add_ip_addr_indexes_to_tables.rb +++ b/db/migrate/20170112021922_add_ip_addr_indexes_to_tables.rb @@ -1,4 +1,4 @@ -class AddIpAddrIndexesToTables < ActiveRecord::Migration +class AddIpAddrIndexesToTables < ActiveRecord::Migration[4.2] def change reversible { execute "set statement_timeout = 0" } add_index :wiki_page_versions, :updater_ip_addr diff --git a/db/migrate/20170112060921_change_ip_addr_to_inet_on_post_appeals.rb b/db/migrate/20170112060921_change_ip_addr_to_inet_on_post_appeals.rb index 21d81ec7f..1384cdb15 100644 --- a/db/migrate/20170112060921_change_ip_addr_to_inet_on_post_appeals.rb +++ b/db/migrate/20170112060921_change_ip_addr_to_inet_on_post_appeals.rb @@ -1,4 +1,4 @@ -class ChangeIpAddrToInetOnPostAppeals < ActiveRecord::Migration +class ChangeIpAddrToInetOnPostAppeals < ActiveRecord::Migration[4.2] def up execute "set statement_timeout = 0" change_column_null :post_appeals, :creator_ip_addr, true diff --git a/db/migrate/20170117233040_add_trigram_index_to_users.rb b/db/migrate/20170117233040_add_trigram_index_to_users.rb index 4972e16ab..e780305b8 100644 --- a/db/migrate/20170117233040_add_trigram_index_to_users.rb +++ b/db/migrate/20170117233040_add_trigram_index_to_users.rb @@ -1,4 +1,4 @@ -class AddTrigramIndexToUsers < ActiveRecord::Migration +class AddTrigramIndexToUsers < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" execute "create index index_users_on_name_trgm on users using gin (lower(name) gin_trgm_ops)" diff --git a/db/migrate/20170218104710_add_indexes_to_dmails.rb b/db/migrate/20170218104710_add_indexes_to_dmails.rb index 13028df8c..866945643 100644 --- a/db/migrate/20170218104710_add_indexes_to_dmails.rb +++ b/db/migrate/20170218104710_add_indexes_to_dmails.rb @@ -1,4 +1,4 @@ -class AddIndexesToDmails < ActiveRecord::Migration +class AddIndexesToDmails < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_index :dmails, :is_read diff --git a/db/migrate/20170302014435_remove_default_ip_addr_from_dmails.rb b/db/migrate/20170302014435_remove_default_ip_addr_from_dmails.rb index 1bccb2e38..195634352 100644 --- a/db/migrate/20170302014435_remove_default_ip_addr_from_dmails.rb +++ b/db/migrate/20170302014435_remove_default_ip_addr_from_dmails.rb @@ -1,4 +1,4 @@ -class RemoveDefaultIpAddrFromDmails < ActiveRecord::Migration +class RemoveDefaultIpAddrFromDmails < ActiveRecord::Migration[4.2] def up change_column_default(:dmails, :creator_ip_addr, nil) end diff --git a/db/migrate/20170314235626_add_tags_to_saved_searches.rb b/db/migrate/20170314235626_add_tags_to_saved_searches.rb index 588ea2e31..d4f8f024a 100644 --- a/db/migrate/20170314235626_add_tags_to_saved_searches.rb +++ b/db/migrate/20170314235626_add_tags_to_saved_searches.rb @@ -1,4 +1,4 @@ -class AddTagsToSavedSearches < ActiveRecord::Migration +class AddTagsToSavedSearches < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" add_column :saved_searches, :labels, "text", array: true, null: false, default: [] diff --git a/db/migrate/20170316224630_drop_post_versions.rb b/db/migrate/20170316224630_drop_post_versions.rb index 45e5da0b6..7f4d4aa9a 100644 --- a/db/migrate/20170316224630_drop_post_versions.rb +++ b/db/migrate/20170316224630_drop_post_versions.rb @@ -1,4 +1,4 @@ -class DropPostVersions < ActiveRecord::Migration +class DropPostVersions < ActiveRecord::Migration[4.2] def change execute "set statement_timeout = 0" drop_table :post_versions diff --git a/db/migrate/20170319000519_add_created_at_index_to_versions.rb b/db/migrate/20170319000519_add_created_at_index_to_versions.rb index e8ff515ac..865afcee4 100644 --- a/db/migrate/20170319000519_add_created_at_index_to_versions.rb +++ b/db/migrate/20170319000519_add_created_at_index_to_versions.rb @@ -1,4 +1,4 @@ -class AddCreatedAtIndexToVersions < ActiveRecord::Migration +class AddCreatedAtIndexToVersions < ActiveRecord::Migration[4.2] def change ApplicationRecord.without_timeout do add_index :note_versions, :created_at diff --git a/db/migrate/20170329185605_add_updated_at_index_on_wiki_pages.rb b/db/migrate/20170329185605_add_updated_at_index_on_wiki_pages.rb index 0dfebb6bb..0d4573a6f 100644 --- a/db/migrate/20170329185605_add_updated_at_index_on_wiki_pages.rb +++ b/db/migrate/20170329185605_add_updated_at_index_on_wiki_pages.rb @@ -1,4 +1,4 @@ -class AddUpdatedAtIndexOnWikiPages < ActiveRecord::Migration +class AddUpdatedAtIndexOnWikiPages < ActiveRecord::Migration[4.2] def change WikiPage.without_timeout do add_index :wiki_pages, :updated_at diff --git a/db/migrate/20170330230231_add_forum_post_id_to_tag_requests.rb b/db/migrate/20170330230231_add_forum_post_id_to_tag_requests.rb index 055e40c72..8293cd0b3 100644 --- a/db/migrate/20170330230231_add_forum_post_id_to_tag_requests.rb +++ b/db/migrate/20170330230231_add_forum_post_id_to_tag_requests.rb @@ -1,4 +1,4 @@ -class AddForumPostIdToTagRequests < ActiveRecord::Migration +class AddForumPostIdToTagRequests < ActiveRecord::Migration[4.2] def change ApplicationRecord.without_timeout do add_column :tag_aliases, :forum_post_id, :integer diff --git a/db/migrate/20170413000209_add_title_to_bulk_update_requests.rb b/db/migrate/20170413000209_add_title_to_bulk_update_requests.rb index 39f57cd8c..35da93031 100644 --- a/db/migrate/20170413000209_add_title_to_bulk_update_requests.rb +++ b/db/migrate/20170413000209_add_title_to_bulk_update_requests.rb @@ -1,4 +1,4 @@ -class AddTitleToBulkUpdateRequests < ActiveRecord::Migration +class AddTitleToBulkUpdateRequests < ActiveRecord::Migration[4.2] def change add_column :bulk_update_requests, :title, :text end diff --git a/db/migrate/20170414005856_add_unique_name_constraint_to_users.rb b/db/migrate/20170414005856_add_unique_name_constraint_to_users.rb index 5243ee926..96df82d36 100644 --- a/db/migrate/20170414005856_add_unique_name_constraint_to_users.rb +++ b/db/migrate/20170414005856_add_unique_name_constraint_to_users.rb @@ -1,7 +1,7 @@ -class AddUniqueNameConstraintToUsers < ActiveRecord::Migration +class AddUniqueNameConstraintToUsers < ActiveRecord::Migration[4.2] def up User.without_timeout do - remove_index :users, :name + remove_index :users, name: "index_users_on_name" execute "create unique index index_users_on_name on users(lower(name))" end end diff --git a/db/migrate/20170414233426_fix_trigram_index_on_pools.rb b/db/migrate/20170414233426_fix_trigram_index_on_pools.rb index 8aba5dd1c..27b18ba46 100644 --- a/db/migrate/20170414233426_fix_trigram_index_on_pools.rb +++ b/db/migrate/20170414233426_fix_trigram_index_on_pools.rb @@ -1,4 +1,4 @@ -class FixTrigramIndexOnPools < ActiveRecord::Migration +class FixTrigramIndexOnPools < ActiveRecord::Migration[4.2] def up execute "drop index index_pools_on_name_trgm" execute "create index index_pools_on_name_trgm on pools using gin (lower(name) gin_trgm_ops)" diff --git a/db/migrate/20170414233617_add_updated_at_index_to_pools.rb b/db/migrate/20170414233617_add_updated_at_index_to_pools.rb index 8c8542854..8c06a5183 100644 --- a/db/migrate/20170414233617_add_updated_at_index_to_pools.rb +++ b/db/migrate/20170414233617_add_updated_at_index_to_pools.rb @@ -1,4 +1,4 @@ -class AddUpdatedAtIndexToPools < ActiveRecord::Migration +class AddUpdatedAtIndexToPools < ActiveRecord::Migration[4.2] def change add_index :pools, :updated_at end diff --git a/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb b/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb index cc4b50c78..94b7781c7 100644 --- a/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb +++ b/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb @@ -1,4 +1,4 @@ -class AddReasonTsVectorIndexToPostFlagsAndAppeals < ActiveRecord::Migration +class AddReasonTsVectorIndexToPostFlagsAndAppeals < ActiveRecord::Migration[4.2] def up execute "SET statement_timeout = 0" execute "CREATE INDEX index_post_flags_on_reason_tsvector ON post_flags USING gin (to_tsvector('pg_catalog.english', reason))" diff --git a/db/migrate/20170428220448_remove_name_and_category_from_saved_searches.rb b/db/migrate/20170428220448_remove_name_and_category_from_saved_searches.rb index d2e7fd3d5..b33b50935 100644 --- a/db/migrate/20170428220448_remove_name_and_category_from_saved_searches.rb +++ b/db/migrate/20170428220448_remove_name_and_category_from_saved_searches.rb @@ -1,4 +1,4 @@ -class RemoveNameAndCategoryFromSavedSearches < ActiveRecord::Migration +class RemoveNameAndCategoryFromSavedSearches < ActiveRecord::Migration[4.2] def change SavedSearch.without_timeout do remove_column :saved_searches, :name, :text diff --git a/db/migrate/20170512221200_create_post_replacements.rb b/db/migrate/20170512221200_create_post_replacements.rb index c5b844590..166cd7098 100644 --- a/db/migrate/20170512221200_create_post_replacements.rb +++ b/db/migrate/20170512221200_create_post_replacements.rb @@ -1,4 +1,4 @@ -class CreatePostReplacements < ActiveRecord::Migration +class CreatePostReplacements < ActiveRecord::Migration[4.2] def change create_table :post_replacements do |t| t.integer :post_id, null: false diff --git a/db/migrate/20170515235205_add_sort_indexes_to_forum_topics.rb b/db/migrate/20170515235205_add_sort_indexes_to_forum_topics.rb index af7673814..99ddd8e0e 100644 --- a/db/migrate/20170515235205_add_sort_indexes_to_forum_topics.rb +++ b/db/migrate/20170515235205_add_sort_indexes_to_forum_topics.rb @@ -1,4 +1,4 @@ -class AddSortIndexesToForumTopics < ActiveRecord::Migration +class AddSortIndexesToForumTopics < ActiveRecord::Migration[4.2] def change add_index :forum_topics, [:is_sticky, :updated_at] end diff --git a/db/migrate/20170519204506_fix_last_noted_at_index_on_posts.rb b/db/migrate/20170519204506_fix_last_noted_at_index_on_posts.rb index 3b6bbf841..4cb5b6ffa 100644 --- a/db/migrate/20170519204506_fix_last_noted_at_index_on_posts.rb +++ b/db/migrate/20170519204506_fix_last_noted_at_index_on_posts.rb @@ -1,4 +1,4 @@ -class FixLastNotedAtIndexOnPosts < ActiveRecord::Migration +class FixLastNotedAtIndexOnPosts < ActiveRecord::Migration[4.2] def up Post.without_timeout do remove_index :posts, column: :last_comment_bumped_at diff --git a/db/migrate/20170526183928_change_source_to_non_null_on_posts.rb b/db/migrate/20170526183928_change_source_to_non_null_on_posts.rb index 23030b5cc..4e16456c5 100644 --- a/db/migrate/20170526183928_change_source_to_non_null_on_posts.rb +++ b/db/migrate/20170526183928_change_source_to_non_null_on_posts.rb @@ -1,4 +1,4 @@ -class ChangeSourceToNonNullOnPosts < ActiveRecord::Migration +class ChangeSourceToNonNullOnPosts < ActiveRecord::Migration[4.2] def up Post.without_timeout do change_column_null(:posts, :source, false, "") diff --git a/db/migrate/20170608043651_add_pending_flagged_indexes_to_posts.rb b/db/migrate/20170608043651_add_pending_flagged_indexes_to_posts.rb index 594cf6af8..3dc5d0bea 100644 --- a/db/migrate/20170608043651_add_pending_flagged_indexes_to_posts.rb +++ b/db/migrate/20170608043651_add_pending_flagged_indexes_to_posts.rb @@ -1,4 +1,4 @@ -class AddPendingFlaggedIndexesToPosts < ActiveRecord::Migration +class AddPendingFlaggedIndexesToPosts < ActiveRecord::Migration[4.2] def change Post.without_timeout do add_index :posts, :is_pending, where: "is_pending = true" diff --git a/db/migrate/20170613200356_change_fields_to_non_null_on_artist_commentaries.rb b/db/migrate/20170613200356_change_fields_to_non_null_on_artist_commentaries.rb index 9ed18ba54..b565d8f18 100644 --- a/db/migrate/20170613200356_change_fields_to_non_null_on_artist_commentaries.rb +++ b/db/migrate/20170613200356_change_fields_to_non_null_on_artist_commentaries.rb @@ -1,4 +1,4 @@ -class ChangeFieldsToNonNullOnArtistCommentaries < ActiveRecord::Migration +class ChangeFieldsToNonNullOnArtistCommentaries < ActiveRecord::Migration[4.2] def up ArtistCommentary.without_timeout do change_column_null(:artist_commentaries, :original_title, false, "") diff --git a/db/migrate/20170709190409_drop_key_values.rb b/db/migrate/20170709190409_drop_key_values.rb index bdcf0fbb5..76629d91e 100644 --- a/db/migrate/20170709190409_drop_key_values.rb +++ b/db/migrate/20170709190409_drop_key_values.rb @@ -1,4 +1,4 @@ -class DropKeyValues < ActiveRecord::Migration +class DropKeyValues < ActiveRecord::Migration[4.2] def up drop_table :key_values end diff --git a/db/migrate/20170914200122_add_is_spam_to_dmails.rb b/db/migrate/20170914200122_add_is_spam_to_dmails.rb index d7aa83142..2db3592cf 100644 --- a/db/migrate/20170914200122_add_is_spam_to_dmails.rb +++ b/db/migrate/20170914200122_add_is_spam_to_dmails.rb @@ -1,4 +1,4 @@ -class AddIsSpamToDmails < ActiveRecord::Migration +class AddIsSpamToDmails < ActiveRecord::Migration[4.2] def change Dmail.without_timeout do add_column :dmails, :is_spam, :boolean, default: false diff --git a/db/migrate/20180116001101_add_keeper_data_to_posts.rb b/db/migrate/20180116001101_add_keeper_data_to_posts.rb index e7edcd1e6..a52e77520 100644 --- a/db/migrate/20180116001101_add_keeper_data_to_posts.rb +++ b/db/migrate/20180116001101_add_keeper_data_to_posts.rb @@ -1,4 +1,4 @@ -class AddKeeperDataToPosts < ActiveRecord::Migration +class AddKeeperDataToPosts < ActiveRecord::Migration[4.2] def change add_column :posts, :keeper_data, :text end diff --git a/db/migrate/20180413224239_create_forum_post_votes.rb b/db/migrate/20180413224239_create_forum_post_votes.rb new file mode 100644 index 000000000..ead7d9753 --- /dev/null +++ b/db/migrate/20180413224239_create_forum_post_votes.rb @@ -0,0 +1,14 @@ +class CreateForumPostVotes < ActiveRecord::Migration[5.1] + def change + create_table :forum_post_votes do |t| + t.integer :forum_post_id, null: false + t.integer :creator_id, null: false + t.integer :score, null: false + + t.timestamps + end + + add_index :forum_post_votes, :forum_post_id + add_index :forum_post_votes, [:forum_post_id, :creator_id], unique: true + end +end diff --git a/test/controllers/forum_post_votes_controller_test.rb b/test/controllers/forum_post_votes_controller_test.rb new file mode 100644 index 000000000..c5c1ce8d1 --- /dev/null +++ b/test/controllers/forum_post_votes_controller_test.rb @@ -0,0 +1,36 @@ +require 'test_helper' + +class ForumPostVotesControllerTest < ActionDispatch::IntegrationTest + context "The forum post votes controller" do + setup do + @user = create(:user) + + as_user do + @forum_topic = create(:forum_topic) + @forum_post = create(:forum_post, topic: @forum_topic) + end + end + + should "allow voting" do + assert_difference("ForumPostVote.count") do + post_auth forum_post_votes_path(forum_post_id: @forum_post.id), @user, params: {forum_post_vote: {score: 1}, format: "js"} + end + assert_response :success + end + + context "when deleting" do + setup do + as_user do + @forum_post_vote = @forum_post.votes.create(score: 1) + end + end + + should "allow removal" do + assert_difference("ForumPostVote.count", -1) do + delete_auth forum_post_votes_path(forum_post_id: @forum_post.id), @user, params: {format: "js"} + end + assert_response :success + end + end + end +end diff --git a/test/fixtures/forum_post_votes.yml b/test/fixtures/forum_post_votes.yml new file mode 100644 index 000000000..19da71734 --- /dev/null +++ b/test/fixtures/forum_post_votes.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + forum_post_id: 1 + creator_id: 1 + score: 1 + +two: + forum_post_id: 1 + creator_id: 1 + score: 1 diff --git a/test/models/forum_post_vote_test.rb b/test/models/forum_post_vote_test.rb new file mode 100644 index 000000000..3c7d85c47 --- /dev/null +++ b/test/models/forum_post_vote_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ForumPostVoteTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/tag_change_request_pruner_test.rb b/test/unit/tag_change_request_pruner_test.rb new file mode 100644 index 000000000..d7798741d --- /dev/null +++ b/test/unit/tag_change_request_pruner_test.rb @@ -0,0 +1,66 @@ +require 'test_helper' + +class TagChangeRequestPrunerTest < ActiveSupport::TestCase + setup do + CurrentUser.user = FactoryBot.create(:admin_user) + CurrentUser.ip_addr = "127.0.0.1" + + @forum_topic = create(:forum_topic) + @tag_alias = create(:tag_alias, forum_topic: @forum_topic) + @tag_implication = create(:tag_implication, antecedent_name: "ccc", consequent_name: "ddd", forum_topic: @forum_topic) + @bulk_update_request = create(:bulk_update_request, script: "alias eee -> fff", forum_topic: @forum_topic) + end + + teardown do + CurrentUser.user = nil + CurrentUser.ip_addr = nil + end + + subject { TagChangeRequestPruner.new } + + context '#warn_old' do + setup do + [TagAlias, TagImplication, BulkUpdateRequest].each do |model| + model.update_all(status: "pending", created_at: (TagRelationship::EXPIRY_WARNING + 1).days.ago) + end + end + + should "update the forum topic for an alias" do + ForumUpdater.any_instance.expects(:update) + subject.warn_old(TagAlias) + end + + should "update the forum topic for an implication" do + ForumUpdater.any_instance.expects(:update) + subject.warn_old(TagImplication) + end + + should "update the forum topic for a bulk update request" do + ForumUpdater.any_instance.expects(:update) + subject.warn_old(BulkUpdateRequest) + end + end + + context '#reject_expired' do + setup do + [TagAlias, TagImplication, BulkUpdateRequest].each do |model| + model.update_all(status: "pending", created_at: (TagRelationship::EXPIRY + 1).days.ago) + end + end + + should "reject the alias" do + TagAlias.any_instance.expects(:reject!) + subject.reject_expired(TagAlias) + end + + should "reject the implication" do + TagImplication.any_instance.expects(:reject!) + subject.reject_expired(TagImplication) + end + + should "reject the bulk update request" do + BulkUpdateRequest.any_instance.expects(:reject!) + subject.reject_expired(BulkUpdateRequest) + end + end +end diff --git a/vendor/assets/javascripts/rails.js b/vendor/assets/javascripts/rails.js deleted file mode 100644 index 5c000cee8..000000000 --- a/vendor/assets/javascripts/rails.js +++ /dev/null @@ -1,393 +0,0 @@ -(function($, undefined) { - -/** - * Unobtrusive scripting adapter for jQuery - * https://github.com/rails/jquery-ujs - * - * Requires jQuery 1.7.0 or later. - * - * Released under the MIT license - * - */ - - // Cut down on the number of issues from people inadvertently including jquery_ujs twice - // by detecting and raising an error when it happens. - if ( $.rails !== undefined ) { - $.error('jquery-ujs has already been loaded!'); - } - - // Shorthand to make it a little easier to call public rails functions from within rails.js - var rails; - - $.rails = rails = { - // Link elements bound by jquery-ujs - linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]', - - // Button elements boud jquery-ujs - buttonClickSelector: 'button[data-remote]', - - // Select elements bound by jquery-ujs - inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]', - - // Form elements bound by jquery-ujs - formSubmitSelector: 'form', - - // Form input elements bound by jquery-ujs - formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])', - - // Form input elements disabled during form submission - disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]', - - // Form input elements re-enabled after form submission - enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled', - - // Form required input elements - requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])', - - // Form file input elements - fileInputSelector: 'input[type=file]', - - // Link onClick disable selector with possible reenable after remote submission - linkDisableSelector: 'a[data-disable-with]', - - // Make sure that every Ajax request sends the CSRF token - CSRFProtection: function(xhr) { - var token = $('meta[name="csrf-token"]').attr('content'); - if (token) xhr.setRequestHeader('X-CSRF-Token', token); - }, - - // Triggers an event on an element and returns false if the event result is false - fire: function(obj, name, data) { - var event = $.Event(name); - obj.trigger(event, data); - return event.result !== false; - }, - - // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm - confirm: function(message) { - return confirm(message); - }, - - // Default ajax function, may be overridden with custom function in $.rails.ajax - ajax: function(options) { - return $.ajax(options); - }, - - // Default way to get an element's href. May be overridden at $.rails.href. - href: function(element) { - return element.attr('href'); - }, - - // Submits "remote" forms and links with ajax - handleRemote: function(element) { - var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options; - - if (rails.fire(element, 'ajax:before')) { - elCrossDomain = element.data('cross-domain'); - crossDomain = elCrossDomain === undefined ? null : elCrossDomain; - withCredentials = element.data('with-credentials') || null; - dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType); - - if (element.is('form')) { - method = element.attr('method'); - url = element.attr('action'); - data = element.serializeArray(); - // memoized value from clicked submit button - var button = element.data('ujs:submit-button'); - if (button) { - data.push(button); - element.data('ujs:submit-button', null); - } - } else if (element.is(rails.inputChangeSelector)) { - method = element.data('method'); - url = element.data('url'); - data = element.serialize(); - if (element.data('params')) data = data + "&" + element.data('params'); - } else if (element.is(rails.buttonClickSelector)) { - method = element.data('method') || 'get'; - url = element.data('url'); - data = element.serialize(); - if (element.data('params')) data = data + "&" + element.data('params'); - } else { - method = element.data('method'); - url = rails.href(element); - data = element.data('params') || null; - } - - options = { - type: method || 'GET', data: data, dataType: dataType, - // stopping the "ajax:beforeSend" event will cancel the ajax request - beforeSend: function(xhr, settings) { - if (settings.dataType === undefined) { - xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script); - } - return rails.fire(element, 'ajax:beforeSend', [xhr, settings]); - }, - success: function(data, status, xhr) { - element.trigger('ajax:success', [data, status, xhr]); - }, - complete: function(xhr, status) { - element.trigger('ajax:complete', [xhr, status]); - }, - error: function(xhr, status, error) { - element.trigger('ajax:error', [xhr, status, error]); - }, - crossDomain: crossDomain - }; - - // There is no withCredentials for IE6-8 when - // "Enable native XMLHTTP support" is disabled - if (withCredentials) { - options.xhrFields = { - withCredentials: withCredentials - }; - } - - // Only pass url to `ajax` options if not blank - if (url) { options.url = url; } - - var jqxhr = rails.ajax(options); - element.trigger('ajax:send', jqxhr); - return jqxhr; - } else { - return false; - } - }, - - // Handles "data-method" on links such as: - // Delete - handleMethod: function(link) { - var href = rails.href(link), - method = link.data('method'), - target = link.attr('target'), - csrf_token = $('meta[name=csrf-token]').attr('content'), - csrf_param = $('meta[name=csrf-param]').attr('content'), - form = $('
    '), - metadata_input = ''; - - if (csrf_param !== undefined && csrf_token !== undefined) { - metadata_input += ''; - } - - if (target) { form.attr('target', target); } - - form.hide().append(metadata_input).appendTo('body'); - form.submit(); - }, - - /* Disables form elements: - - Caches element value in 'ujs:enable-with' data store - - Replaces element text with value of 'data-disable-with' attribute - - Sets disabled property to true - */ - disableFormElements: function(form) { - form.find(rails.disableSelector).each(function() { - var element = $(this), method = element.is('button') ? 'html' : 'val'; - element.data('ujs:enable-with', element[method]()); - element[method](element.data('disable-with')); - element.prop('disabled', true); - }); - }, - - /* Re-enables disabled form elements: - - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`) - - Sets disabled property to false - */ - enableFormElements: function(form) { - form.find(rails.enableSelector).each(function() { - var element = $(this), method = element.is('button') ? 'html' : 'val'; - if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with')); - element.prop('disabled', false); - }); - }, - - /* For 'data-confirm' attribute: - - Fires `confirm` event - - Shows the confirmation dialog - - Fires the `confirm:complete` event - - Returns `true` if no function stops the chain and user chose yes; `false` otherwise. - Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog. - Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function - return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog. - */ - allowAction: function(element) { - var message = element.data('confirm'), - answer = false, callback; - if (!message) { return true; } - - if (rails.fire(element, 'confirm')) { - answer = rails.confirm(message); - callback = rails.fire(element, 'confirm:complete', [answer]); - } - return answer && callback; - }, - - // Helper function which checks for blank inputs in a form that match the specified CSS selector - blankInputs: function(form, specifiedSelector, nonBlank) { - var inputs = $(), input, valueToCheck, - selector = specifiedSelector || 'input,textarea', - allInputs = form.find(selector); - - allInputs.each(function() { - input = $(this); - valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val(); - // If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey - if (!valueToCheck === !nonBlank) { - - // Don't count unchecked required radio if other radio with same name is checked - if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) { - return true; // Skip to next input - } - - inputs = inputs.add(input); - } - }); - return inputs.length ? inputs : false; - }, - - // Helper function which checks for non-blank inputs in a form that match the specified CSS selector - nonBlankInputs: function(form, specifiedSelector) { - return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank - }, - - // Helper function, needed to provide consistent behavior in IE - stopEverything: function(e) { - $(e.target).trigger('ujs:everythingStopped'); - e.stopImmediatePropagation(); - return false; - }, - - // replace element's html with the 'data-disable-with' after storing original html - // and prevent clicking on it - disableElement: function(element) { - element.data('ujs:enable-with', element.html()); // store enabled state - element.html(element.data('disable-with')); // set to disabled state - element.bind('click.railsDisable', function(e) { // prevent further clicking - return rails.stopEverything(e); - }); - }, - - // restore element to its original state which was disabled by 'disableElement' above - enableElement: function(element) { - if (element.data('ujs:enable-with') !== undefined) { - element.html(element.data('ujs:enable-with')); // set to old enabled state - element.removeData('ujs:enable-with'); // clean up cache - } - element.unbind('click.railsDisable'); // enable element - } - - }; - - if (rails.fire($(document), 'rails:attachBindings')) { - - $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }}); - - $(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() { - rails.enableElement($(this)); - }); - - $(document).delegate(rails.linkClickSelector, 'click.rails', function(e) { - var link = $(this), method = link.data('method'), data = link.data('params'); - if (!rails.allowAction(link)) return rails.stopEverything(e); - - if (link.is(rails.linkDisableSelector)) rails.disableElement(link); - - if (link.data('remote') !== undefined) { - if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; } - - var handleRemote = rails.handleRemote(link); - // response from rails.handleRemote() will either be false or a deferred object promise. - if (handleRemote === false) { - rails.enableElement(link); - } else { - handleRemote.error( function() { rails.enableElement(link); } ); - } - return false; - - } else if (link.data('method')) { - rails.handleMethod(link); - return false; - } - }); - - $(document).delegate(rails.buttonClickSelector, 'click.rails', function(e) { - var button = $(this); - if (!rails.allowAction(button)) return rails.stopEverything(e); - - rails.handleRemote(button); - return false; - }); - - $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) { - var link = $(this); - if (!rails.allowAction(link)) return rails.stopEverything(e); - - rails.handleRemote(link); - return false; - }); - - $(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) { - var form = $(this), - remote = form.data('remote') !== undefined, - blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector), - nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector); - - if (!rails.allowAction(form)) return rails.stopEverything(e); - - // skip other logic when required values are missing or file upload is present - if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { - return rails.stopEverything(e); - } - - if (remote) { - if (nonBlankFileInputs) { - // slight timeout so that the submit button gets properly serialized - // (make it easy for event handler to serialize form without disabled values) - setTimeout(function(){ rails.disableFormElements(form); }, 13); - var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]); - - // re-enable form elements if event bindings return false (canceling normal form submission) - if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); } - - return aborted; - } - - rails.handleRemote(form); - return false; - - } else { - // slight timeout so that the submit button gets properly serialized - setTimeout(function(){ rails.disableFormElements(form); }, 13); - } - }); - - $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) { - var button = $(this); - - if (!rails.allowAction(button)) return rails.stopEverything(event); - - // register the pressed submit button - var name = button.attr('name'), - data = name ? {name:name, value:button.val()} : null; - - button.closest('form').data('ujs:submit-button', data); - }); - - $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) { - if (this == event.target) rails.disableFormElements($(this)); - }); - - $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) { - if (this == event.target) rails.enableFormElements($(this)); - }); - - $(function(){ - // making sure that all forms have actual up-to-date token(cached forms contain old one) - var csrf_token = $('meta[name=csrf-token]').attr('content'); - var csrf_param = $('meta[name=csrf-param]').attr('content'); - $('form input[name="' + csrf_param + '"]').val(csrf_token); - }); - } - -})( jQuery ); \ No newline at end of file