From deec1863f6c250a04537abdd6b27d76cf24a0337 Mon Sep 17 00:00:00 2001 From: Fabian Semal Date: Thu, 18 Sep 2008 14:31:16 +0200 Subject: [PATCH] Concert date to datetime bzr revid: fabian@tinyerp.com-20080918123116-r5999hs4i7fe0qw4 --- bin/osv/orm.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 96f91b36ea3..e0722cbe4dc 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1441,6 +1441,12 @@ class orm(orm_template): cr.execute("UPDATE \"%s\" SET \"%s\"=temp_change_size::VARCHAR(%d)" % (self._table, k, f.size)) cr.execute("ALTER TABLE \"%s\" DROP COLUMN temp_change_size" % (self._table,)) cr.commit() + if f_pg_type == 'date' and f._type == 'datetime': + cr.execute("ALTER TABLE \"%s\" RENAME COLUMN \"%s\" TO temp_change_type" % (self._table, k)) + cr.execute("ALTER TABLE \"%s\" ADD COLUMN \"%s\" TIMESTAMP " % (self._table, k)) + cr.execute("UPDATE \"%s\" SET \"%s\"=temp_change_type::TIMESTAMP" % (self._table, k)) + cr.execute("ALTER TABLE \"%s\" DROP COLUMN temp_change_type" % (self._table,)) + cr.commit() # if the field is required and hasn't got a NOT NULL constraint if f.required and f_pg_notnull == 0: # set the field to the default value if any