Type casting for change_column_type_concurrently
What does this MR do?
In !33955 (closed) I tried to change the type of the properties
column in the services
table from text
to jsonb
. We store json values in this column so it would be useful to use a jsonb type.
However, change_column_type_concurrently :services, :properties, :jsonb
fails with
PG::DatatypeMismatch: ERROR: column "properties_for_type_change" is of type jsonb but expression is of type text
LINE 1: ...ATE "services" SET "properties_for_type_change" = "services"...
This is because text can't be automatically translated to json. The query it executes when the value is copied to the temporary column is
UPDATE "services" SET "properties_for_type_change" = "services"."properties"
With the type_cast option added in this MR, the query will be:
UPDATE "services" SET "properties_for_type_change" = jsonb("services"."properties")
Screenshots
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 Andy Schoenen