Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4: [ART] Make POA request and form adjustments migration #19997

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nihil2501
Copy link
Contributor

@nihil2501 nihil2501 commented Dec 23, 2024

Description

This PR adds a migration to modify the Power of Attorney forms table structure by:

  1. Adding BIDX (binary index) columns for city, state, and zip code
  2. Adding ciphertext columns for secure storage of address data
  3. Adding claimant_type column to power_of_attorney_requests table

Details

  • Removes existing index on city_bidx_state_bidx_zipcode_bidx
  • Removes individual zipcode index
  • Safely removes legacy columns (city_bidx, state_bidx, zipcode_bidx)
  • Adds new columns for encrypted data storage:
    • claimant_city_ciphertext/bidx
    • claimant_state_code_ciphertext/bidx
    • claimant_zip_code_ciphertext/bidx
  • Creates a new concurrent index on BIDX columns
  • Adds claimant_type column to requests table

@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 23, 2024 10:34 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 23, 2024 10:54 Inactive
@nihil2501 nihil2501 changed the title [ART] Make POA request and form adjustments migration 4: [ART] Make POA request and form adjustments migration Dec 23, 2024
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 26, 2024 22:35 Inactive
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from ae61f34 to 4583dd1 Compare December 26, 2024 23:02
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 26, 2024 23:04 Inactive
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations branch 2 times, most recently from 07c2552 to c8daeb7 Compare December 26, 2024 23:21
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from 4583dd1 to 51a6985 Compare December 26, 2024 23:28
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 26, 2024 23:30 Inactive
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from 51a6985 to d25e8f0 Compare December 27, 2024 04:08
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 27, 2024 04:10 Inactive
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations branch from c8daeb7 to dc4cb58 Compare December 27, 2024 06:48
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from d25e8f0 to 9ead4aa Compare December 27, 2024 07:05
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 27, 2024 07:07 Inactive
Base automatically changed from art/poa-requests/part-3/migrations to master December 27, 2024 18:04
@ojbucao ojbucao marked this pull request as ready for review December 27, 2024 18:12
@ojbucao ojbucao requested review from a team as code owners December 27, 2024 18:12
@ojbucao ojbucao self-requested a review December 27, 2024 18:13
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 27, 2024 19:10 Inactive
[:claimant_city_bidx, :claimant_state_code_bidx, :claimant_zip_code_bidx],
algorithm: :concurrently

add_column :ar_power_of_attorney_requests, :claimant_type, :string, null: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it absolutely necessary to add columns to both models at the same time? Generally I would avoid this unless I HAVE to

Copy link
Contributor

@amprokop amprokop Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ojbucao can comment but I don't see why it's necessary. Is your suggestion to split this up into two separate migrations, just so running & reverting seem cleaner?

Copy link
Contributor

@ryan-mcneil ryan-mcneil Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we request that indexes are modified in separate transactions migrations. I can already hear a few of you questioning this :) but we've seen things fail, and when it does, it requires a lot of work on our side. So please break this down into separate PRs for each of the index updates, and the two models (unless it's absolutely necessary the two models be updated at the same time)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different transactions or different PRs?

All of these tables should have 0 records in all deployed environments as this isn't yet a production feature, or even one that's been tested in staging, does that make a difference to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I agree with the guidance on having index updates in separate transactions, just not sure of the case for making them separate PRs, they'll run separately anyway if split up into diff migrations no)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can split these up into separate migrations.

Copy link
Contributor

@ryan-mcneil ryan-mcneil Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guys - I didn't make the rules. Fighting me is only going to get your work less attention.

Copy link
Contributor

@ryan-mcneil ryan-mcneil Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had intended to say migrations, which we generally would split into PRs, and is why I stated it that way. I suppose separate migrations in the same PR is ok.

Copy link
Contributor

@amprokop amprokop Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't trying to fight you on the rules! Correct me if I'm wrong and I will apologize profusely but you said two separate things, one of which was transparently reasonable and one of which was harder to understand, and I was trying to distinguish:)

@@ -0,0 +1,24 @@
class MakePoaRequestAndFormAdjustments < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
Copy link
Contributor

@amprokop amprokop Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is necessary, since these tables should have 0 records in all fields, do we know why it's in here or just out of habit/pattern-matching?

Copy link
Contributor

@ojbucao ojbucao Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably just habit. actually no, db:migrate throws an error without it.

@ojbucao ojbucao dismissed stale reviews from chumpy and themself via 996bca0 December 27, 2024 22:13
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from d5b0665 to 996bca0 Compare December 27, 2024 22:13
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 27, 2024 22:16 Inactive
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from 996bca0 to 5e4c619 Compare December 27, 2024 23:04
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 27, 2024 23:07 Inactive
@ojbucao ojbucao force-pushed the art/poa-requests/part-3/migrations.2 branch from 5e4c619 to 4284620 Compare December 30, 2024 16:48
@va-vfs-bot va-vfs-bot temporarily deployed to art/poa-requests/part-3/migrations.2/main/main December 30, 2024 17:09 Inactive
@ryan-mcneil
Copy link
Contributor

@ojbucao I was looking over the PR when you force pushed - I'm keeping an eye out for your team approval, then we'll be good to go

@ojbucao
Copy link
Contributor

ojbucao commented Dec 30, 2024

@ojbucao I was looking over the PR when you force pushed - I'm keeping an eye out for your team approval, then we'll be good to go

Thank you!

@@ -0,0 +1,6 @@
class RemoveOldIndicesFromPoaForms < ActiveRecord::Migration[7.1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to note here that I brought this up in the CoP this morning, and that while it's not always necessary, we generally recommend following the same patterns for removing indexes as we do for adding (regarding transactions/concurrency). Considering there aren't any records in the table, we'll let it go here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the reasoning here, but I’d lean towards sticking with our pattern of using algorithm: :concurrently even if it seems unnecessary in this case. It ensures consistency and might reduce risk if the migration is ever redone in a different context. Would it make sense to make that change as a precaution?

@ryan-mcneil
Copy link
Contributor

Lastly I'll mention that in the future, we'd generally recommend/request separate PRs for the various types of migrations, just because they're easier to revert if, for example, the 3rd out of 5 migrations fail for whatever reason, and can't be easily rolled back because it's outside of a transaction. But in this case, as we're dealing with models without any data (in production... I didn't look at staging), and they're related operations on the same table, we're ok with letting them go in together this time. Thanks for breaking them up, though

@ojbucao ojbucao disabled auto-merge December 31, 2024 01:05
2 Removed obsolete columns: city_bidx, state_bidx, zipcode_bidx
3 Added new columns: claimant_city_ciphertext, claimant_city_bidx,
  claimant_state_code_ciphertext, claimant_state_code_bidx,
  claimant_zip_code_ciphertext, claimant_zip_code_bidx
4 Added a new index for claimant_city_bidx, claimant_state_code_bidx,
  and claimant_zip_code_bidx
5 Added claimant_type column to ar_power_of_attorney_requests
Copy link
Contributor

@LindseySaari LindseySaari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving this a 👍 but please keep an eye on things when you merge (dev and staging). Due to the use of disable_ddl_transaction, the index removal is not wrapped in a transaction, which means that if something goes wrong during the migration process, the index could be left in a partially removed state, requiring manual intervention to resolve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants