Project

General

Profile

« Previous | Next » 

Revision 2614

sql.py: add_pkey(): Version the index name just in case add_suffix() doesn't correctly preserve a needed version #

View differences:

lib/sql.py
813 813
    
814 814
    index = sql_gen.as_Table(sql_gen.add_suffix(table.name, '_pkey'))
815 815
    col = sql_gen.to_name_only_col(pkey(db, table, recover))
816
    run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD CONSTRAINT '
817
        +index.to_str(db)+' PRIMARY KEY('+col.to_str(db)+')', recover=recover,
818
        log_level=3)
816
    try:
817
        run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD CONSTRAINT '
818
            +index.to_str(db)+' PRIMARY KEY('+col.to_str(db)+')',
819
            recover=True, cacheable=True, log_level=3,
820
            log_ignore_excs=(DuplicateTableException,))
821
    except DuplicateTableException, e:
822
        index.name = next_version(index.name)
823
        # try again with next version of name
819 824

  
820 825
def add_row_num(db, table):
821 826
    '''Adds a row number column to a table. Its name is in row_num_col. It will

Also available in: Unified diff