Skip to content

Commit

Permalink
Record who created a suitability record
Browse files Browse the repository at this point in the history
This adds a field on the suitability records that we can use to track
who created the record.
  • Loading branch information
thomasleese committed Jul 16, 2024
1 parent 2124a78 commit 47902de
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/models/suitability_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
# note :text not null
# created_at :datetime not null
# updated_at :datetime not null
# created_by_id :bigint not null
#
# Indexes
#
# index_suitability_records_on_created_by_id (created_by_id)
#
# Foreign Keys
#
# fk_rails_... (created_by_id => staff.id)
#
class SuitabilityRecord < ApplicationRecord
has_and_belongs_to_many :application_forms
Expand Down
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
- archived_at
- country_code
- created_at
- created_by
- date_of_birth
- id
- updated_at
Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20240716075611_add_created_by_to_suitability_records.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

class AddCreatedByToSuitabilityRecords < ActiveRecord::Migration[7.1]
def change
# rubocop:disable Rails/NotNullColumn
add_reference :suitability_records,
:created_by,
foreign_key: {
to_table: :staff,
},
null: false
# rubocop:enable Rails/NotNullColumn
end
end
5 changes: 4 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/diagram.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions spec/factories/suitability_records.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: suitability_records
#
# id :bigint not null, primary key
# archive_note :text default(""), not null
# archived_at :datetime
# country_code :text default(""), not null
# date_of_birth :date
# note :text not null
# created_at :datetime not null
# updated_at :datetime not null
# created_by_id :bigint not null
#
# Indexes
#
# index_suitability_records_on_created_by_id (created_by_id)
#
# Foreign Keys
#
# fk_rails_... (created_by_id => staff.id)
#
FactoryBot.define do
factory :suitability_record do
note { Faker::Lorem.sentence }
Expand Down
22 changes: 22 additions & 0 deletions spec/models/suitability_record_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: suitability_records
#
# id :bigint not null, primary key
# archive_note :text default(""), not null
# archived_at :datetime
# country_code :text default(""), not null
# date_of_birth :date
# note :text not null
# created_at :datetime not null
# updated_at :datetime not null
# created_by_id :bigint not null
#
# Indexes
#
# index_suitability_records_on_created_by_id (created_by_id)
#
# Foreign Keys
#
# fk_rails_... (created_by_id => staff.id)
#
require "rails_helper"

RSpec.describe SuitabilityRecord, type: :model do
Expand Down

0 comments on commit 47902de

Please sign in to comment.