From 2b70eaf61e024d62dfacb8f57a1dc80619ec7043 Mon Sep 17 00:00:00 2001 From: Holden Hinkle Date: Thu, 11 Apr 2024 12:00:45 -0400 Subject: [PATCH 1/5] create accredited_individuals table --- ...411153910_create_accredited_individuals.rb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 db/migrate/20240411153910_create_accredited_individuals.rb diff --git a/db/migrate/20240411153910_create_accredited_individuals.rb b/db/migrate/20240411153910_create_accredited_individuals.rb new file mode 100644 index 00000000000..a08e572a2ec --- /dev/null +++ b/db/migrate/20240411153910_create_accredited_individuals.rb @@ -0,0 +1,37 @@ +class CreateAccreditedIndividuals < ActiveRecord::Migration[7.1] + def change + create_table :accredited_individuals, id: :uuid do |t| + t.uuid :individual_id, null: false + t.string :registration_number, null: false + t.string :poa_code, limit: 3 + t.string :individual_type, null: false + t.string :first_name + t.string :middle_initial + t.string :last_name + t.string :full_name + t.string :email + t.string :phone + t.string :address_type + t.string :address_line1 + t.string :address_line2 + t.string :address_line3 + t.string :city + t.string :country_code_iso3 + t.string :country_name + t.string :county_name + t.string :county_code + t.string :international_postal_code + t.string :province + t.string :state_code + t.string :zip_code + t.string :zip_suffix + t.jsonb :raw_address + t.float :lat + t.float :long + t.geography :location, limit: { srid: 4326, type: 'st_point', geographic: true } + t.timestamps + + t.index %i[ registration_number individual_type ], name: 'index_reg_num_and_indi_type', unique: true + end + end +end From 8974d69ff2c4bbb74063bc4f9f2650c96ebfb5be Mon Sep 17 00:00:00 2001 From: Holden Hinkle Date: Thu, 11 Apr 2024 12:44:08 -0400 Subject: [PATCH 2/5] wip --- db/migrate/20240411153910_create_accredited_individuals.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/migrate/20240411153910_create_accredited_individuals.rb b/db/migrate/20240411153910_create_accredited_individuals.rb index a08e572a2ec..09857af3752 100644 --- a/db/migrate/20240411153910_create_accredited_individuals.rb +++ b/db/migrate/20240411153910_create_accredited_individuals.rb @@ -1,14 +1,14 @@ class CreateAccreditedIndividuals < ActiveRecord::Migration[7.1] def change create_table :accredited_individuals, id: :uuid do |t| - t.uuid :individual_id, null: false + t.uuid :ogc_id, null: false t.string :registration_number, null: false t.string :poa_code, limit: 3 t.string :individual_type, null: false t.string :first_name t.string :middle_initial t.string :last_name - t.string :full_name + t.string :full_name, index: true t.string :email t.string :phone t.string :address_type @@ -31,7 +31,8 @@ def change t.geography :location, limit: { srid: 4326, type: 'st_point', geographic: true } t.timestamps - t.index %i[ registration_number individual_type ], name: 'index_reg_num_and_indi_type', unique: true + t.index :location, using: :gist + t.index %i[ registration_number individual_type ], name: 'index_on_reg_num_and_type_for_accredited_individuals', unique: true end end end From 44035ec2a891a801f2f7ac698e79aba79def999e Mon Sep 17 00:00:00 2001 From: Holden Hinkle Date: Thu, 11 Apr 2024 12:49:33 -0400 Subject: [PATCH 3/5] add # frozen_string_literal: true --- db/migrate/20240411153910_create_accredited_individuals.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/migrate/20240411153910_create_accredited_individuals.rb b/db/migrate/20240411153910_create_accredited_individuals.rb index 09857af3752..031df1ab5d6 100644 --- a/db/migrate/20240411153910_create_accredited_individuals.rb +++ b/db/migrate/20240411153910_create_accredited_individuals.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CreateAccreditedIndividuals < ActiveRecord::Migration[7.1] def change create_table :accredited_individuals, id: :uuid do |t| From 771995918de9fa9c980a4b63a4977787b236edb9 Mon Sep 17 00:00:00 2001 From: Holden Hinkle Date: Thu, 11 Apr 2024 12:52:13 -0400 Subject: [PATCH 4/5] run migration --- db/schema.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/db/schema.rb b/db/schema.rb index 686d2f0e861..876aa259626 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -53,6 +53,42 @@ t.index ["uuid"], name: "index_accounts_on_uuid", unique: true end + create_table "accredited_individuals", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "ogc_id", null: false + t.string "registration_number", null: false + t.string "poa_code", limit: 3 + t.string "individual_type", null: false + t.string "first_name" + t.string "middle_initial" + t.string "last_name" + t.string "full_name" + t.string "email" + t.string "phone" + t.string "address_type" + t.string "address_line1" + t.string "address_line2" + t.string "address_line3" + t.string "city" + t.string "country_code_iso3" + t.string "country_name" + t.string "county_name" + t.string "county_code" + t.string "international_postal_code" + t.string "province" + t.string "state_code" + t.string "zip_code" + t.string "zip_suffix" + t.jsonb "raw_address" + t.float "lat" + t.float "long" + t.geography "location", limit: {:srid=>4326, :type=>"st_point", :geographic=>true} + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["full_name"], name: "index_accredited_individuals_on_full_name" + t.index ["location"], name: "index_accredited_individuals_on_location", using: :gist + t.index ["registration_number", "individual_type"], name: "index_on_reg_num_and_type_for_accredited_individuals", unique: true + end + create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false From bc963fb1d67635253aa3d53de702d6da67a35791 Mon Sep 17 00:00:00 2001 From: Holden Hinkle Date: Thu, 11 Apr 2024 14:49:25 -0400 Subject: [PATCH 5/5] index poa_code --- db/migrate/20240411153910_create_accredited_individuals.rb | 2 +- db/schema.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/20240411153910_create_accredited_individuals.rb b/db/migrate/20240411153910_create_accredited_individuals.rb index 031df1ab5d6..78e6999a888 100644 --- a/db/migrate/20240411153910_create_accredited_individuals.rb +++ b/db/migrate/20240411153910_create_accredited_individuals.rb @@ -5,7 +5,7 @@ def change create_table :accredited_individuals, id: :uuid do |t| t.uuid :ogc_id, null: false t.string :registration_number, null: false - t.string :poa_code, limit: 3 + t.string :poa_code, limit: 3, index: true t.string :individual_type, null: false t.string :first_name t.string :middle_initial diff --git a/db/schema.rb b/db/schema.rb index 876aa259626..a996325aa71 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -86,6 +86,7 @@ t.datetime "updated_at", null: false t.index ["full_name"], name: "index_accredited_individuals_on_full_name" t.index ["location"], name: "index_accredited_individuals_on_location", using: :gist + t.index ["poa_code"], name: "index_accredited_individuals_on_poa_code" t.index ["registration_number", "individual_type"], name: "index_on_reg_num_and_type_for_accredited_individuals", unique: true end