Skip to content

Commit

Permalink
Remove columns 'for_banks' and 'for_partners' from Questions table
Browse files Browse the repository at this point in the history
  • Loading branch information
jp524 committed Jan 16, 2025
1 parent a5dc184 commit 6a06427
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
10 changes: 4 additions & 6 deletions app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions spec/factories/questions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions spec/models/question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a06427

Please sign in to comment.