Skip to content

Commit

Permalink
Merge pull request #16036 from saraycp/remove_canned_response_decisio…
Browse files Browse the repository at this point in the history
…n_kind

Remove canned response `decision_kind`
  • Loading branch information
saraycp committed Apr 25, 2024
2 parents cd30c13 + 0d9c2eb commit 654b0c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/api/app/models/canned_response.rb
@@ -1,9 +1,6 @@
# Canned responses are predetermined comment responses to common questions in a project/package/request
# Each user can manage their own set of canned responses
class CannedResponse < ApplicationRecord
# TODO: remove after the migration is in production
self.ignored_columns += ['decision_kind']

#### Includes and extends

#### Constants
Expand Down Expand Up @@ -47,7 +44,6 @@ class CannedResponse < ApplicationRecord
#
# id :bigint not null, primary key
# content :text(65535)
# decision_kind :integer
# title :string(255)
# decision_type :integer
# created_at :datetime not null
Expand Down
Expand Up @@ -2,12 +2,16 @@

class BackfillDecisionTypeInCannedResponses < ActiveRecord::Migration[7.0]
def up
return unless CannedResponse.columns.any? { |c| c.name == 'decision_kind' }

CannedResponse.where.not(decision_kind: nil).find_each do |canned_response|
canned_response.update(decision_type: CannedResponse.decision_kinds[canned_response[:decision_kind]])
end
end

def down
return unless CannedResponse.columns.any? { |c| c.name == 'decision_kind' }

# rubocop:disable Rails/SkipsModelValidations
CannedResponse.where.not(decision_type: nil).in_batches.update_all(decision_type: nil)
# rubocop:enable Rails/SkipsModelValidations
Expand Down
@@ -0,0 +1,5 @@
class RemoveDecisionKindFromCannedResponses < ActiveRecord::Migration[7.0]
def change
safety_assured { remove_column :canned_responses, :decision_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_23_073041) do
ActiveRecord::Schema[7.0].define(version: 2024_04_24_141833) 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 @@ -247,7 +247,6 @@
t.text "content", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "decision_kind"
t.integer "decision_type"
t.index ["user_id"], name: "index_canned_responses_on_user_id"
end
Expand Down

0 comments on commit 654b0c2

Please sign in to comment.