Ensure no null settings context hash for extensions settings
Issue: Enforce not-null constraint on settings_context... (#503812 - closed)
What does this MR do and why?
- Adds
not-nullvalidation for extensions setting type at the application level only. This is because non-extensions setting types are expected to havenullsettings context hash. - Backfills existing extensions settings with
nullsettings context hash to default extensions marketplace settings.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Setup:
Before pulling this branch, let's create vs_code_settings records in the Rails console:
|
Extension settings |
Non-extension settings |
|---|---|
|
|
Backfill:
-
Pull this branch run migrations (
bundle exec rake db:migrate) -
Confirm backfill successful: extensions setting no longer has
nilsettings context hash by runningVsCode::Settings::VsCodeSetting.find_by(settings_context_hash: nil, setting_type: 'extensions') # nil -
Confirm non-extensions settings are not affected
VsCode::Settings::VsCodeSetting.find_by(settings_context_hash: nil, setting_type: 'globalState') # returns record
Model Validation:
- Using the command outlined in the setup step, create another extensions settings record with
nilsettings context hash. - Should result in validation error:
ActiveRecord::RecordInvalid: Validation failed: Settings context hash cannot be blank for extensions setting type - Create another non-extensions settings record with
nilsettings context hash andsetting_type: 'keybindings' - Should not result in validation error.