Change services.properties type to jsonb
What does this MR do?
It changes the type of services.properties to JSON-B. Currently, it is a text column, but we use it to store JSON objects. Changing it has a couple of advantages:
- The content will be validated on the database level
- The data will be automatically serialized (!33955 (a632b0d0))
- We can introduce schema validations
- The data is searchable
- We can potentially add indexes
@abrandl suggested this in !32665 (comment 356041993)
Database outputs
Migration
== 20200605114612 ChangeServicesPropertiesToJsonb: migrating ==================
-- change_column(:services, :properties, :jsonb, {:default=>{}, :using=>"properties::jsonb"})
-> 0.0098s
== 20200605114612 ChangeServicesPropertiesToJsonb: migrated (0.0098s) =========
Lab
I ran this in database-lab
exec ALTER TABLE services ALTER COLUMN properties TYPE jsonb USING properties::jsonb, ALTER COLUMN properties SET DEFAULT '{}';
Session: joe-brgdrhg350j65v2mjf4g
The query has been executed. Duration: 1.884 min
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖