Skip to content

Commit

Permalink
Merge pull request #16053 from hellcp-work/decision-kind-remove
Browse files Browse the repository at this point in the history
Remove kind column from the decisions table
  • Loading branch information
danidoni committed Apr 25, 2024
2 parents d8ce88f + 2977127 commit f68ce1b
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/api/app/models/decision.rb
Expand Up @@ -10,8 +10,6 @@ class Decision < ApplicationRecord

after_create :track_decision

self.ignored_columns += ['kind']

def description
'The moderator decided on the report'
end
Expand Down Expand Up @@ -60,9 +58,8 @@ def hours_before_decision
# Table name: decisions
#
# id :bigint not null, primary key
# kind :integer default("cleared")
# reason :text(65535) not null
# type :string(255) not null, default("DecisionCleared")
# type :string(255) default("DecisionCleared"), not null
# created_at :datetime not null
# updated_at :datetime not null
# moderator_id :integer not null, indexed
Expand Down
3 changes: 1 addition & 2 deletions src/api/app/models/decision_cleared.rb
Expand Up @@ -21,9 +21,8 @@ def create_event
# Table name: decisions
#
# id :bigint not null, primary key
# kind :integer default("cleared")
# reason :text(65535) not null
# type :string(255) not null, default("DecisionCleared")
# type :string(255) default("DecisionCleared"), not null
# created_at :datetime not null
# updated_at :datetime not null
# moderator_id :integer not null, indexed
Expand Down
3 changes: 1 addition & 2 deletions src/api/app/models/decision_favored.rb
Expand Up @@ -21,9 +21,8 @@ def create_event
# Table name: decisions
#
# id :bigint not null, primary key
# kind :integer default("cleared")
# reason :text(65535) not null
# type :string(255) not null, default("DecisionCleared")
# type :string(255) default("DecisionCleared"), not null
# created_at :datetime not null
# updated_at :datetime not null
# moderator_id :integer not null, indexed
Expand Down
Expand Up @@ -37,9 +37,8 @@ def create_event
# Table name: decisions
#
# id :bigint not null, primary key
# kind :integer default("cleared")
# reason :text(65535) not null
# type :string(255) not null, default("DecisionCleared")
# type :string(255) default("DecisionCleared"), not null
# created_at :datetime not null
# updated_at :datetime not null
# moderator_id :integer not null, indexed
Expand Down
20 changes: 20 additions & 0 deletions src/api/app/models/decision_favored_with_delete_request.rb
Expand Up @@ -39,3 +39,23 @@ def create_event
Event::FavoredDecision.create(event_parameters)
end
end

# == Schema Information
#
# Table name: decisions
#
# id :bigint not null, primary key
# reason :text(65535) not null
# type :string(255) default("DecisionCleared"), not null
# created_at :datetime not null
# updated_at :datetime not null
# moderator_id :integer not null, indexed
#
# Indexes
#
# index_decisions_on_moderator_id (moderator_id)
#
# Foreign Keys
#
# fk_rails_... (moderator_id => users.id)
#
3 changes: 1 addition & 2 deletions src/api/app/models/decision_favored_with_user_deletion.rb
Expand Up @@ -42,9 +42,8 @@ def create_event
# Table name: decisions
#
# id :bigint not null, primary key
# kind :integer default("cleared")
# reason :text(65535) not null
# type :string(255) not null, default("DecisionCleared")
# type :string(255) default("DecisionCleared"), not null
# created_at :datetime not null
# updated_at :datetime not null
# moderator_id :integer not null, indexed
Expand Down
Expand Up @@ -2,6 +2,8 @@

class SetTheDecisionTypeFromDecisionKind < ActiveRecord::Migration[7.0]
def up
return unless Decision.columns.any? { |c| c.name == 'kind' }

Decision.in_batches do |batch|
batch.each do |decision|
decision.type = decision.favor? ? 'DecisionFavored' : 'DecisionCleared'
Expand Down
@@ -0,0 +1,5 @@
class RemoveKindFromDecision < ActiveRecord::Migration[7.0]
def change
safety_assured { remove_column :decisions, :kind, :integer }
end
end
3 changes: 1 addition & 2 deletions src/api/db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_04_24_141833) do
ActiveRecord::Schema[7.0].define(version: 2024_04_25_084914) do
create_table "appeals", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.text "reason", null: false
t.integer "appellant_id", null: false
Expand Down Expand Up @@ -406,7 +406,6 @@
create_table "decisions", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "moderator_id", null: false
t.text "reason", null: false
t.integer "kind", default: 0
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "type", default: "DecisionCleared", null: false
Expand Down

0 comments on commit f68ce1b

Please sign in to comment.