fieldColumnType.DatabaseTypeName() returns non capitalized string, while fileType.SQL returns capitalized string. This commit aims to fix this and avoid detecting a type change when the type did not change.
[ x ] Do only one thing
[ x ] Non breaking API changes
[ x ] Tested
What did this pull request do?
Fix same type comparing when running auto-migrate
User Case Description
When running auto migrate, we detected we ended up attempting to execute the statement.
ALTER TABLE "myTable" ALTER COLUMN "myColumn" TYPE JSONB USING "myColumn"::JSONB
This resulted in an error since our database (CockroachDB) does not allow type alter statements on JSONB columns.
After reviewing the code and debugging, I noticed that this behaviour was due to this comparison. fieldColumnType.DatabaseTypeName() returns non capitalised string, while fileType.SQL returns capitalised string.
After using strings.ToUpper on fieldColumnType.DatabaseTypeName() before comparing it to fileType.SQL, this type change is no longer detected and auto-migrate succeeds.
This PR aims to fix this and avoid detecting a type change when the type did not change.
fieldColumnType.DatabaseTypeName()
returns non capitalized string, whilefileType.SQL
returns capitalized string. This commit aims to fix this and avoid detecting a type change when the type did not change.What did this pull request do?
Fix same type comparing when running auto-migrate
User Case Description
When running auto migrate, we detected we ended up attempting to execute the statement.
This resulted in an error since our database (CockroachDB) does not allow type alter statements on JSONB columns.
After reviewing the code and debugging, I noticed that this behaviour was due to this comparison.
fieldColumnType.DatabaseTypeName()
returns non capitalised string, whilefileType.SQL
returns capitalised string.After using
strings.ToUpper
onfieldColumnType.DatabaseTypeName()
before comparing it tofileType.SQL
, this type change is no longer detected and auto-migrate succeeds.This PR aims to fix this and avoid detecting a type change when the type did not change.