hooks/syncschema.py
branchstable
changeset 5801 355d3945c1f3
parent 5772 4283ee58acaf
child 5803 589e2e3fb997
equal deleted inserted replaced
5800:2bc88fb424bc 5801:355d3945c1f3
    81 def add_inline_relation_column(session, etype, rtype):
    81 def add_inline_relation_column(session, etype, rtype):
    82     """add necessary column and index for an inlined relation"""
    82     """add necessary column and index for an inlined relation"""
    83     table = SQL_PREFIX + etype
    83     table = SQL_PREFIX + etype
    84     column = SQL_PREFIX + rtype
    84     column = SQL_PREFIX + rtype
    85     try:
    85     try:
    86         session.system_sql(str('ALTER TABLE %s ADD COLUMN %s integer'
    86         session.system_sql(str('ALTER TABLE %s ADD %s integer'
    87                                % (table, column)), rollback_on_failure=False)
    87                                % (table, column)), rollback_on_failure=False)
    88         session.info('added column %s to table %s', column, table)
    88         session.info('added column %s to table %s', column, table)
    89     except:
    89     except:
    90         # silent exception here, if this error has not been raised because the
    90         # silent exception here, if this error has not been raised because the
    91         # column already exists, index creation will fail anyway
    91         # column already exists, index creation will fail anyway
   374         # added some str() wrapping query since some backend (eg psycopg) don't
   374         # added some str() wrapping query since some backend (eg psycopg) don't
   375         # allow unicode queries
   375         # allow unicode queries
   376         table = SQL_PREFIX + rdef.subject
   376         table = SQL_PREFIX + rdef.subject
   377         column = SQL_PREFIX + rdef.name
   377         column = SQL_PREFIX + rdef.name
   378         try:
   378         try:
   379             session.system_sql(str('ALTER TABLE %s ADD COLUMN %s %s'
   379             session.system_sql(str('ALTER TABLE %s ADD %s %s'
   380                                    % (table, column, attrtype)),
   380                                    % (table, column, attrtype)),
   381                                rollback_on_failure=False)
   381                                rollback_on_failure=False)
   382             self.info('added column %s to table %s', table, column)
   382             self.info('added column %s to table %s', table, column)
   383         except Exception, ex:
   383         except Exception, ex:
   384             # the column probably already exists. this occurs when
   384             # the column probably already exists. this occurs when