From 00a6a10e0fd0efa74e41b12d8e7d2d74c6d1235e Mon Sep 17 00:00:00 2001 From: Jack S Date: Tue, 30 May 2023 14:49:50 +0100 Subject: [PATCH] Add data sharing agreement --- app/models/data_sharing_agreement.rb | 4 ++++ app/models/organisation.rb | 1 + ...20230530094653_add_data_sharing_agreement.rb | 17 +++++++++++++++++ db/schema.rb | 13 ++++++++++++- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/models/data_sharing_agreement.rb create mode 100644 db/migrate/20230530094653_add_data_sharing_agreement.rb diff --git a/app/models/data_sharing_agreement.rb b/app/models/data_sharing_agreement.rb new file mode 100644 index 000000000..7b366c9fe --- /dev/null +++ b/app/models/data_sharing_agreement.rb @@ -0,0 +1,4 @@ +class DataSharingAgreement < ApplicationRecord + belongs_to :organisation + belongs_to :data_protection_officer, class_name: "User" +end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 7df43c429..e87854120 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -4,6 +4,7 @@ class Organisation < ApplicationRecord has_many :managed_lettings_logs, class_name: "LettingsLog", foreign_key: "managing_organisation_id" has_many :owned_sales_logs, class_name: "SalesLog", foreign_key: "owning_organisation_id", dependent: :delete_all has_many :data_protection_confirmations + has_one :data_sharing_agreement has_many :organisation_rent_periods has_many :owned_schemes, class_name: "Scheme", foreign_key: "owning_organisation_id", dependent: :delete_all has_many :parent_organisation_relationships, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship" diff --git a/db/migrate/20230530094653_add_data_sharing_agreement.rb b/db/migrate/20230530094653_add_data_sharing_agreement.rb new file mode 100644 index 000000000..b3f79c04d --- /dev/null +++ b/db/migrate/20230530094653_add_data_sharing_agreement.rb @@ -0,0 +1,17 @@ +class AddDataSharingAgreement < ActiveRecord::Migration[7.0] + def change + create_table :data_sharing_agreements do |t| + t.belongs_to :organisation + t.belongs_to :data_protection_officer, class_name: "User" + + t.datetime :signed_at, null: false + + t.timestamps + end + + add_index :data_sharing_agreements, + %i[organisation_id data_protection_officer_id], + unique: true, + name: "data_sharing_agreements_unique" + end +end diff --git a/db/schema.rb b/db/schema.rb index 6c33dd973..9a63c06d3 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: 2023_05_15_114101) do +ActiveRecord::Schema[7.0].define(version: 2023_05_30_094653) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -56,6 +56,17 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_15_114101) do t.index ["organisation_id"], name: "index_data_protection_confirmations_on_organisation_id" end + create_table "data_sharing_agreements", force: :cascade do |t| + t.bigint "organisation_id" + t.bigint "data_protection_officer_id" + t.datetime "signed_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["data_protection_officer_id"], name: "index_data_sharing_agreements_on_data_protection_officer_id" + t.index ["organisation_id", "data_protection_officer_id"], name: "data_sharing_agreements_unique", unique: true + t.index ["organisation_id"], name: "index_data_sharing_agreements_on_organisation_id" + end + create_table "la_rent_ranges", force: :cascade do |t| t.integer "ranges_rent_id" t.integer "lettype"