From f782340259e2ead6f2cae0aa9e5561d956e50ae1 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:21:03 +0100 Subject: [PATCH] Add organisation_name_changes table --- ...0416111741_create_organisation_name_changes.rb | 15 +++++++++++++++ db/schema.rb | 14 +++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250416111741_create_organisation_name_changes.rb diff --git a/db/migrate/20250416111741_create_organisation_name_changes.rb b/db/migrate/20250416111741_create_organisation_name_changes.rb new file mode 100644 index 000000000..b0db49c65 --- /dev/null +++ b/db/migrate/20250416111741_create_organisation_name_changes.rb @@ -0,0 +1,15 @@ +class CreateOrganisationNameChanges < ActiveRecord::Migration[7.0] + def change + create_table :organisation_name_changes do |t| + t.references :organisation, null: false, foreign_key: true + t.string :name, null: false + t.date :startdate, null: false + t.date :discarded_at + t.integer :change_type + + t.timestamps + end + + add_index :organisation_name_changes, %i[organisation_id startdate], unique: true, name: "index_org_name_changes_on_org_id_and_startdate" + end +end diff --git a/db/schema.rb b/db/schema.rb index e29560461..b0ddb0273 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: 2025_03_05_092900) do +ActiveRecord::Schema[7.2].define(version: 2025_04_16_111741) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -497,6 +497,18 @@ ActiveRecord::Schema[7.2].define(version: 2025_03_05_092900) do t.boolean "show_additional_page" end + create_table "organisation_name_changes", force: :cascade do |t| + t.bigint "organisation_id", null: false + t.string "name", null: false + t.date "startdate", null: false + t.date "discarded_at" + t.integer "change_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["organisation_id", "startdate"], name: "index_org_name_changes_on_org_id_and_startdate", unique: true + t.index ["organisation_id"], name: "index_organisation_name_changes_on_organisation_id" + end + create_table "organisation_relationships", force: :cascade do |t| t.integer "child_organisation_id" t.integer "parent_organisation_id"