Apply rubocop rules to migration files
There are some rules which only affect migration files, and we cannot enable them if we're excluding those files from being inspected. We're also changing migrations related to the Rails/TimeZone rule slightly because these fields were already changed afterwards, so we aren't changing the schema.
This commit is contained in:
@@ -7,7 +7,6 @@ AllCops:
|
||||
DisplayCopNames: true
|
||||
DisplayStyleGuide: true
|
||||
Exclude:
|
||||
- "db/migrate/**/*"
|
||||
- "db/schema.rb"
|
||||
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
||||
# to ignore them, so only the ones explicitly set in this file are enabled.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class ActsAsVotableMigration < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
create_table :votes do |t|
|
||||
|
||||
t.references :votable, polymorphic: true
|
||||
t.references :voter, polymorphic: true
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class CreateLocks < ActiveRecord::Migration[4.2]
|
||||
create_table :locks do |t|
|
||||
t.references :user, index: true, foreign_key: true
|
||||
t.integer :tries, default: 0
|
||||
t.datetime :locked_until, null: false, default: Time.now
|
||||
t.datetime :locked_until, null: false, default: Time.zone.now
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ class CreateProposal < ActiveRecord::Migration[4.2]
|
||||
t.string "external_url"
|
||||
t.integer "author_id"
|
||||
t.datetime "hidden_at"
|
||||
t.integer "flags_count", default: 0
|
||||
t.integer "flags_count", default: 0
|
||||
t.datetime "ignored_flag_at"
|
||||
t.integer "cached_votes_up", default: 0
|
||||
t.integer "comments_count", default: 0
|
||||
|
||||
@@ -4,4 +4,3 @@ class AddMoreIndexesForAhoy < ActiveRecord::Migration[4.2]
|
||||
add_index :visits, [:started_at]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
class AddsResilientLockedUntilDefault < ActiveRecord::Migration[4.2]
|
||||
|
||||
def up
|
||||
change_column_default :locks, :locked_until, Time.new(2000, 1, 1, 1, 1, 1)
|
||||
change_column_default :locks, :locked_until, Time.zone.local(2000, 1, 1, 1, 1, 1)
|
||||
end
|
||||
|
||||
def down
|
||||
change_column_default :locks, :locked_until, Time.now
|
||||
change_column_default :locks, :locked_until, Time.zone.now
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class AddUnaccentExtension < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
return if extension_enabled?('unaccent')
|
||||
return if extension_enabled?("unaccent")
|
||||
|
||||
begin
|
||||
enable_extension 'unaccent'
|
||||
enable_extension "unaccent"
|
||||
rescue StandardError => e
|
||||
raise "Could not create extension unaccent. Please contact with your system administrator: #{e}"
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class AddPgTrgmExtension < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
return if extension_enabled?('pg_trgm')
|
||||
return if extension_enabled?("pg_trgm")
|
||||
|
||||
begin
|
||||
enable_extension 'pg_trgm'
|
||||
enable_extension "pg_trgm"
|
||||
rescue StandardError => e
|
||||
raise "Could not create extension pg_trgm. Please contact with your system administrator: #{e}"
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddsTsvectorUpdateTrigger < ActiveRecord::Migration[4.2]
|
||||
|
||||
def up
|
||||
add_column :proposals, :tsv, :tsvector
|
||||
add_index :proposals, :tsv, using: "gin"
|
||||
@@ -9,5 +8,4 @@ class AddsTsvectorUpdateTrigger < ActiveRecord::Migration[4.2]
|
||||
remove_index :proposals, :tsv
|
||||
remove_column :proposals, :tsv
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,5 +6,4 @@ class MergeActivitiesAndNotifications < ActiveRecord::Migration[4.2]
|
||||
t.references :notifiable, polymorphic: true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddTsvectorToDebates < ActiveRecord::Migration[4.2]
|
||||
|
||||
def up
|
||||
add_column :debates, :tsv, :tsvector
|
||||
add_index :debates, :tsv, using: "gin"
|
||||
@@ -9,5 +8,4 @@ class AddTsvectorToDebates < ActiveRecord::Migration[4.2]
|
||||
remove_index :debates, :tsv
|
||||
remove_column :debates, :tsv
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class AddTsvectorToSpendingProposals < ActiveRecord::Migration[4.2]
|
||||
|
||||
def change
|
||||
add_column :spending_proposals, :tsv, :tsvector
|
||||
add_index :spending_proposals, :tsv, using: "gin"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
class CreateBanners < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :banners do |t|
|
||||
t.string :title, limit: 80
|
||||
t.string :description
|
||||
t.string :target_url
|
||||
t.string :style
|
||||
t.string :image
|
||||
t.date :post_started_at
|
||||
t.date :post_ended_at
|
||||
t.datetime :hidden_at
|
||||
t.string :title, limit: 80
|
||||
t.string :description
|
||||
t.string :target_url
|
||||
t.string :style
|
||||
t.string :image
|
||||
t.date :post_started_at
|
||||
t.date :post_ended_at
|
||||
t.datetime :hidden_at
|
||||
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index :banners, :hidden_at
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class CreateBudgetInvestments < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :budget_investments do |t|
|
||||
|
||||
t.references "geozone"
|
||||
|
||||
t.integer "author_id", index: true
|
||||
@@ -24,7 +23,7 @@ class CreateBudgetInvestments < ActiveRecord::Migration[4.2]
|
||||
t.datetime "hidden_at"
|
||||
t.integer "cached_votes_up", default: 0
|
||||
t.integer "comments_count", default: 0
|
||||
t.integer "confidence_score", default: 0, null: false
|
||||
t.integer "confidence_score", default: 0, null: false
|
||||
t.integer "physical_votes", default: 0
|
||||
|
||||
t.tsvector "tsv"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class DefaultPasswordChangedAt < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
change_column :users, :password_changed_at, :datetime, null: false, default: Time.now
|
||||
change_column :users, :password_changed_at, :datetime, null: false, default: Time.zone.now
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AdjustBudgetFields < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
change_column :budgets, :phase, :string, limit: 40, default: 'accepting'
|
||||
change_column :budgets, :phase, :string, limit: 40, default: "accepting"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class AddPollIdAndStatsFieldsToPollVoter < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :poll_voters, :poll_id, :integer, null: false
|
||||
add_column :poll_voters, :poll_id, :integer, null: false
|
||||
|
||||
remove_column :poll_voters, :booth_assignment_id, :integer, null: false
|
||||
add_column :poll_voters, :booth_assignment_id, :integer
|
||||
|
||||
@@ -4,6 +4,6 @@ class AddAnswerIdToPollVoters < ActiveRecord::Migration[4.2]
|
||||
|
||||
add_index :poll_voters, :document_number
|
||||
add_index :poll_voters, :poll_id
|
||||
add_index :poll_voters, [:poll_id, :document_number, :document_type], name: 'doc_by_poll'
|
||||
add_index :poll_voters, [:poll_id, :document_number, :document_type], name: "doc_by_poll"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class AddPollsRelatedIndexes < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
|
||||
add_index :poll_booth_assignments, :booth_id
|
||||
add_index :poll_booth_assignments, :poll_id
|
||||
|
||||
@@ -17,7 +16,6 @@ class AddPollsRelatedIndexes < ActiveRecord::Migration[4.2]
|
||||
|
||||
add_index :polls, [:starts_at, :ends_at]
|
||||
|
||||
|
||||
add_foreign_key :poll_answers, :poll_questions, column: :question_id
|
||||
add_foreign_key :poll_booth_assignments, :polls
|
||||
add_foreign_key :poll_final_recounts, :poll_booth_assignments, column: :booth_assignment_id
|
||||
|
||||
@@ -7,7 +7,7 @@ class CreateSiteCustomizationPages < ActiveRecord::Migration[4.2]
|
||||
t.text :content
|
||||
t.boolean :more_info_flag
|
||||
t.boolean :print_content_flag
|
||||
t.string :status, default: 'draft'
|
||||
t.string :status, default: "draft"
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class CreateTopics < ActiveRecord::Migration[4.2]
|
||||
t.string :title, null: false
|
||||
t.text :description
|
||||
t.integer :author_id
|
||||
t.integer "comments_count", default: 0
|
||||
t.integer "comments_count", default: 0
|
||||
t.references :community, index: true
|
||||
t.datetime :hidden_at, index: true
|
||||
t.timestamps null: false
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
class FixPasswordChangedAtDefault < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
change_column_default :users, :password_changed_at, Time.new(2015, 1, 1, 1, 1, 1)
|
||||
change_column_default :users, :password_changed_at, Time.zone.local(2015, 1, 1, 1, 1, 1)
|
||||
end
|
||||
|
||||
def down
|
||||
change_column_default :users, :password_changed_at, Time.now
|
||||
change_column_default :users, :password_changed_at, Time.zone.now
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,11 +9,11 @@ class CreatePollRecount < ActiveRecord::Migration[4.2]
|
||||
t.text :officer_assignment_id_log, default: ""
|
||||
t.text :author_id_log, default: ""
|
||||
t.integer :white_amount
|
||||
t.text :white_amount_log, default: ""
|
||||
t.text :white_amount_log, default: ""
|
||||
t.integer :null_amount
|
||||
t.text :null_amount_log, default: ""
|
||||
t.text :null_amount_log, default: ""
|
||||
t.integer :total_amount
|
||||
t.text :total_amount_log, default: ""
|
||||
t.text :total_amount_log, default: ""
|
||||
end
|
||||
|
||||
add_index :poll_recounts, :booth_assignment_id
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class RenamePollQuestionIdToQuestionId < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
rename_column :poll_question_answers, :poll_question_id, :question_id
|
||||
rename_column :poll_question_answers, :poll_question_id, :question_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class AddTimeZoneToDefaultDatetimes < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
change_column_default :users, :password_changed_at, DateTime.new(2015, 1, 1, 1, 1, 1, '+00:00')
|
||||
change_column_default :locks, :locked_until, DateTime.new(2000, 1, 1, 1, 1, 1, '+00:00')
|
||||
change_column_default :users, :password_changed_at, DateTime.new(2015, 1, 1, 1, 1, 1, "+00:00")
|
||||
change_column_default :locks, :locked_until, DateTime.new(2000, 1, 1, 1, 1, 1, "+00:00")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class CreateRelatedContent < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :related_contents do |t|
|
||||
t.references :parent_relationable, polymorphic: true, index: { name: 'index_related_contents_on_parent_relationable' }
|
||||
t.references :child_relationable, polymorphic: true, index: { name: 'index_related_contents_on_child_relationable' }
|
||||
t.references :related_content, index: { name: 'opposite_related_content' }
|
||||
t.references :parent_relationable, polymorphic: true, index: { name: "index_related_contents_on_parent_relationable" }
|
||||
t.references :child_relationable, polymorphic: true, index: { name: "index_related_contents_on_child_relationable" }
|
||||
t.references :related_content, index: { name: "opposite_related_content" }
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ class AddTranslateMilestones < ActiveRecord::Migration[4.2]
|
||||
t.timestamps null: false
|
||||
t.string :title
|
||||
t.text :description
|
||||
|
||||
end
|
||||
|
||||
add_index :budget_investment_milestone_translations,
|
||||
|
||||
@@ -2,7 +2,7 @@ class CreateProposalExecutedDashboardActions < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :proposal_executed_dashboard_actions do |t|
|
||||
t.references :proposal, index: true, foreign_key: true
|
||||
t.references :proposal_dashboard_action, index: { name: 'index_proposal_action' }, foreign_key: true
|
||||
t.references :proposal_dashboard_action, index: { name: "index_proposal_action" }, foreign_key: true
|
||||
t.datetime :executed_at
|
||||
t.text :comments
|
||||
|
||||
|
||||
@@ -9,4 +9,3 @@ class ChangeBudgetInvestmentStatusesToMilestoneStatuses < ActiveRecord::Migratio
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class RenameAdministratorTaskToDashboardAdministratorTask < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
rename_index :administrator_tasks, 'index_administrator_tasks_on_source_type_and_source_id', 'index_dashboard_administrator_tasks_on_source'
|
||||
rename_index :administrator_tasks, "index_administrator_tasks_on_source_type_and_source_id", "index_dashboard_administrator_tasks_on_source"
|
||||
rename_table :administrator_tasks, :dashboard_administrator_tasks
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class RenameDashboardActionIdToActionId < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
rename_column :dashboard_executed_actions, :dashboard_action_id, :action_id
|
||||
rename_column :dashboard_executed_actions, :dashboard_action_id, :action_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddBannerTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Banner.create_translation_table!(
|
||||
{
|
||||
@@ -14,4 +13,3 @@ class AddBannerTranslations < ActiveRecord::Migration[4.2]
|
||||
Banner.drop_translation_table!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddHomepageContentTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Widget::Card.create_translation_table!(
|
||||
{
|
||||
@@ -16,4 +15,3 @@ class AddHomepageContentTranslations < ActiveRecord::Migration[4.2]
|
||||
Widget::Card.drop_translation_table!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddPollTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Poll.create_translation_table!(
|
||||
{
|
||||
@@ -14,5 +13,4 @@ class AddPollTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Poll.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddAdminNotificationTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
AdminNotification.create_translation_table!(
|
||||
{
|
||||
@@ -14,4 +13,3 @@ class AddAdminNotificationTranslations < ActiveRecord::Migration[4.2]
|
||||
AdminNotification.drop_translation_table!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddPollQuestionTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Poll::Question.create_translation_table!(
|
||||
{ title: :string },
|
||||
@@ -10,5 +9,4 @@ class AddPollQuestionTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Poll::Question.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddPollQuestionAnswerTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Poll::Question::Answer.create_translation_table!(
|
||||
{
|
||||
@@ -13,5 +12,4 @@ class AddPollQuestionAnswerTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Poll::Question::Answer.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddCollaborativeLegislationTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Legislation::Process.create_translation_table!(
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddActivePollsTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
ActivePoll.create_translation_table!(
|
||||
{
|
||||
@@ -12,5 +11,4 @@ class AddActivePollsTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
ActivePollPoll.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddBudgetTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Budget.create_translation_table!(
|
||||
{
|
||||
@@ -12,5 +11,4 @@ class AddBudgetTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Budget.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddBudgetPhaseTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Budget::Phase.create_translation_table!(
|
||||
{
|
||||
@@ -13,5 +12,4 @@ class AddBudgetPhaseTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Budget::Phase.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddBudgetGroupTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Budget::Group.create_translation_table!(
|
||||
{
|
||||
@@ -12,5 +11,4 @@ class AddBudgetGroupTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Budget::Group.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class AddBudgetHeadingTranslations < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
Budget::Heading.create_translation_table!(
|
||||
{
|
||||
@@ -12,5 +11,4 @@ class AddBudgetHeadingTranslations < ActiveRecord::Migration[4.2]
|
||||
def self.down
|
||||
Budget::Heading.drop_translation_table!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class CreateBudgetTrackerAssignments < ActiveRecord::Migration[5.0]
|
||||
t.references :tracker, foreign_key: true
|
||||
t.integer :investment_id, index: true
|
||||
|
||||
t.timestamps null:false
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,4 +14,3 @@ class CreateVotationTypes < ActiveRecord::Migration[5.0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,4 +4,3 @@ class AddOrderAndPositiveInPollAnswers < ActiveRecord::Migration[5.0]
|
||||
add_column :poll_answers, :order, :integer
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class AddHelpLinkToBudgets < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :budgets, :help_link, :string
|
||||
add_column :budgets, :budget_milestone_tags,:string
|
||||
add_column :budgets, :budget_valuation_tags,:string
|
||||
add_column :budgets, :budget_milestone_tags, :string
|
||||
add_column :budgets, :budget_valuation_tags, :string
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,4 +10,3 @@ class CreatePollPairAnswers < ActiveRecord::Migration[5.0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@ class AddHiddenFieldToPollQuestionAnswers < ActiveRecord::Migration[5.0]
|
||||
add_column :poll_question_answers, :hidden, :boolean, default: false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@ class AddValueToPollAnswers < ActiveRecord::Migration[5.0]
|
||||
add_column :poll_answers, :value, :integer
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,4 +9,3 @@ class CreateVotationSetAnswers < ActiveRecord::Migration[5.0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user