author | Denis Laxalde <denis.laxalde@logilab.fr> |
Fri, 12 Feb 2016 16:13:43 +0100 | |
changeset 11113 | 7f83e6a5acc3 |
parent 11101 | 66fb68c25f83 |
permissions | -rw-r--r-- |
11033
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
1 |
if confirm('use Europe/Paris as timezone?'): |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
timezone = 'Europe/Paris' |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
else: |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
import pytz |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
while True: |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
timezone = raw_input('enter your timezone') |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
if timezone in pytz.common_timezones: |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
break |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
|
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
dbdriver = repo.system_source.dbdriver |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
if dbdriver == 'postgres': |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
sql("SET TIME ZONE '%s'" % timezone) |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
|
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
for entity in schema.entities(): |
11101
66fb68c25f83
[migration] fix crash on 3.22 upgrade if entity type doesn't exist in fsschema (pending removal)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11033
diff
changeset
|
15 |
if entity.final or entity.type not in fsschema: |
11033
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
continue |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
change_attribute_type(entity.type, 'creation_date', 'TZDatetime', ask_confirm=False) |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
change_attribute_type(entity.type, 'modification_date', 'TZDatetime', ask_confirm=False) |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
|
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
20 |
if dbdriver == 'postgres': |
63d860a14a17
[schema] Use TZDatetime for creation_date and modification_date
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
sql("SET TIME ZONE UTC") |