Concert date to datetime

bzr revid: fabian@tinyerp.com-20080918123116-r5999hs4i7fe0qw4
This commit is contained in:
Fabian Semal 2008-09-18 14:31:16 +02:00
parent 43daa23bad
commit deec1863f6
1 changed files with 6 additions and 0 deletions

View File

@ -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