Skip to content

Change services.properties type to jsonb

Andy Schoenen requested to merge change_services_properties_to_jsonb into master

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

Availability and Testing

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 🤖

Merge request reports

Loading