diff --git a/app/models/log.rb b/app/models/log.rb index d1ea40a5c..8a7e6c22e 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -5,6 +5,7 @@ class Log < ApplicationRecord belongs_to :owning_organisation, class_name: "Organisation", optional: true belongs_to :assigned_to, class_name: "User", optional: true + belongs_to :created_by, class_name: "User", optional: true belongs_to :updated_by, class_name: "User", optional: true belongs_to :bulk_upload, optional: true diff --git a/db/migrate/20240408102550_add_created_by.rb b/db/migrate/20240408102550_add_created_by.rb new file mode 100644 index 000000000..b47e382a5 --- /dev/null +++ b/db/migrate/20240408102550_add_created_by.rb @@ -0,0 +1,11 @@ +class AddCreatedBy < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs do |t| + t.references :created_by, class_name: "User" + end + + change_table :lettings_logs do |t| + t.references :created_by, class_name: "User" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 14f200036..8f0100d55 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.0].define(version: 2024_04_08_101139) do +ActiveRecord::Schema[7.0].define(version: 2024_04_08_102550) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -320,8 +320,10 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_101139) do t.integer "partner_under_16_value_check" t.integer "multiple_partners_value_check" t.bigint "assigned_to_id" + t.bigint "created_by_id" t.index ["assigned_to_id"], name: "index_lettings_logs_on_assigned_to_id" t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id" + t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id" t.index ["location_id"], name: "index_lettings_logs_on_location_id" t.index ["managing_organisation_id"], name: "index_lettings_logs_on_managing_organisation_id" t.index ["old_id"], name: "index_lettings_logs_on_old_id", unique: true @@ -686,8 +688,10 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_08_101139) do t.integer "partner_under_16_value_check" t.integer "multiple_partners_value_check" t.bigint "assigned_to_id" + t.bigint "created_by_id" t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" + t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["old_id"], name: "index_sales_logs_on_old_id", unique: true t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"