misc/migration/3.22.0_Any.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Dec 2015 09:23:23 +0100
changeset 11033 63d860a14a17
child 11101 66fb68c25f83
permissions -rw-r--r--
[schema] Use TZDatetime for creation_date and modification_date No work has been done for form fields/widgets since creation_date / modification_date are by default not editable through the default UI. One may want to add such feature at some point. Time will be displayed as UTC, let the end-application decide otherwise by customizing the tzdatetime printer if desired. Closes #4848923

if confirm('use Europe/Paris as timezone?'):
    timezone = 'Europe/Paris'
else:
    import pytz
    while True:
        timezone = raw_input('enter your timezone')
        if timezone in pytz.common_timezones:
            break

dbdriver = repo.system_source.dbdriver
if dbdriver == 'postgres':
    sql("SET TIME ZONE '%s'" % timezone)

for entity in schema.entities():
    if entity.final:
        continue
    change_attribute_type(entity.type, 'creation_date', 'TZDatetime', ask_confirm=False)
    change_attribute_type(entity.type, 'modification_date', 'TZDatetime', ask_confirm=False)

if dbdriver == 'postgres':
    sql("SET TIME ZONE UTC")