[QUESTION] Timezone related impact when upgrading to latest version.
baxeico opened this issue · 2 comments
Some context
I've a quite old and large Django codebase using SQL Server as database.
During the years I used different versions of the SQL Server driver for Django, here is the list:
# https://bitbucket.org/Manfre/django-mssql/src/master/
django-mssql==1.5.1
django-mssql==1.8
# https://github.com/michiya/django-pyodbc-azure
django-pyodbc-azure==1.8.17.0
# this project
mssql-django==1.1.3
Now I'm planning an upgrade to latest version (1.4.1 at the time of writing).
I read that in version 1.2 you introduced Timezone support, recommending to do a manual migration of DateTime fields.
Some questions
-
If I understand correctly the DATETIMEOFFSET field type should be used for DateTime fields when
USE_TZ=True
. My project haveUSE_TZ=True
since the beginning, but all my DateTime fields use DATETIME2 field type (I checked with SQL Server management studio). Maybe this is due to the drivers I used before (django-mssql and django-pyodbc-azure)? -
What will be the practical effects if I upgrade mssql-django to the latest version and do not migrate all DateTime fields from DATETIME2 to DATETIMEOFFSET?
Of course I will do some tests, but I thought to ask here to gather some advice. Thank you very much for your help!
Hi @baxeico
Since your DateTime fields use DATETIME2, I believe that there is no time zone support (despite setting USE_TZ = TRUE
).
You have 2 options when upgrading:
-
Set
USE_TZ = FALSE
when upgrading. DateTime fields will stay as DATETIME2 and time zones will not be supported (which should be the same behavior). No migration necessary. -
USE_TZ = TRUE
and do the manual migration. This will ensure that time zones are fully supported. (Recommended)
Leaving USE_TZ = TRUE
and not doing the manual migration will create errors as the expected type should be DATETIMEOFFSET
Thank you @dauinsight ! Your explaination is very useful. I'm closing this question as I had the needed information.