Revision 2947
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
1011 | 1011 |
|
1012 | 1012 |
def add_col(db, table, col, **kw_args): |
1013 | 1013 |
assert isinstance(col, sql_gen.TypedCol) |
1014 |
run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD COLUMN '+col.to_str(db), |
|
1015 |
**kw_args) |
|
1014 |
try: run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD COLUMN ' |
|
1015 |
+col.to_str(db), recover=True, cacheable=True, **kw_args) |
|
1016 |
except DuplicateException: pass # column already existed |
|
1016 | 1017 |
|
1017 | 1018 |
row_num_typed_col = sql_gen.TypedCol(row_num_col, 'serial', nullable=False, |
1018 | 1019 |
constraints='PRIMARY KEY') |
Also available in: Unified diff
sql.py: add_col(): Catch DuplicateExceptions so that columns that already existed are ignored