cubicweb/misc/migration/3.22.0_Any.py
changeset 11057 0b59724cb3f2
parent 11033 63d860a14a17
child 11129 97095348b3ee
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/misc/migration/3.22.0_Any.py	Sat Jan 16 13:48:51 2016 +0100
@@ -0,0 +1,21 @@
+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")