From 6a0642743dc8c7792072cd9bb792cd859dafcf7a Mon Sep 17 00:00:00 2001 From: JP <85654561+jp524@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:49:10 -0600 Subject: [PATCH] Remove columns 'for_banks' and 'for_partners' from Questions table --- app/models/question.rb | 10 ++++------ ..._for_banks_and_for_partners_from_questions.rb | 16 ++++++++++++++++ db/schema.rb | 4 +--- spec/factories/questions.rb | 10 ++++------ spec/models/question_spec.rb | 10 ++++------ 5 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20250104193318_remove_for_banks_and_for_partners_from_questions.rb diff --git a/app/models/question.rb b/app/models/question.rb index 7fec5625ee..0bb02d9265 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -2,12 +2,10 @@ # # Table name: questions # -# id :bigint not null, primary key -# for_banks :boolean default(TRUE), not null -# for_partners :boolean default(TRUE), not null -# title :string not null -# created_at :datetime not null -# updated_at :datetime not null +# id :bigint not null, primary key +# title :string not null +# created_at :datetime not null +# updated_at :datetime not null # class Question < ApplicationRecord has_paper_trail diff --git a/db/migrate/20250104193318_remove_for_banks_and_for_partners_from_questions.rb b/db/migrate/20250104193318_remove_for_banks_and_for_partners_from_questions.rb new file mode 100644 index 0000000000..89613605c7 --- /dev/null +++ b/db/migrate/20250104193318_remove_for_banks_and_for_partners_from_questions.rb @@ -0,0 +1,16 @@ +class RemoveForBanksAndForPartnersFromQuestions < ActiveRecord::Migration[7.2] + def up + puts "Removing partner only FAQs..." + Question.where(for_partners: true, for_banks: false).delete_all + puts "Partner only FAQs removed" + safety_assured do + remove_column :questions, :for_banks + remove_column :questions, :for_partners + end + end + + def down + add_column :questions, :for_banks, :boolean, null: false, default: true + add_column :questions, :for_partners, :boolean, null: false, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index afc02b83d7..51424c4401 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_12_20_020009) do +ActiveRecord::Schema[7.2].define(version: 2025_01_04_193318) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -692,8 +692,6 @@ create_table "questions", force: :cascade do |t| t.string "title", null: false - t.boolean "for_partners", default: true, null: false - t.boolean "for_banks", default: true, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end diff --git a/spec/factories/questions.rb b/spec/factories/questions.rb index 8995126d54..f58da23de8 100644 --- a/spec/factories/questions.rb +++ b/spec/factories/questions.rb @@ -2,12 +2,10 @@ # # Table name: questions # -# id :bigint not null, primary key -# for_banks :boolean default(TRUE), not null -# for_partners :boolean default(TRUE), not null -# title :string not null -# created_at :datetime not null -# updated_at :datetime not null +# id :bigint not null, primary key +# title :string not null +# created_at :datetime not null +# updated_at :datetime not null # FactoryBot.define do factory :question do diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb index 93055b9438..4878182c06 100644 --- a/spec/models/question_spec.rb +++ b/spec/models/question_spec.rb @@ -2,12 +2,10 @@ # # Table name: questions # -# id :bigint not null, primary key -# for_banks :boolean default(TRUE), not null -# for_partners :boolean default(TRUE), not null -# title :string not null -# created_at :datetime not null -# updated_at :datetime not null +# id :bigint not null, primary key +# title :string not null +# created_at :datetime not null +# updated_at :datetime not null # RSpec.describe Question, type: :model do