sql: do not specify "IF EXISTS" as we got the column list from postgresql

This commit is contained in:
Frédéric Péters 2013-08-07 11:10:45 +02:00
parent 5d25719ce2
commit dd46e9b505
1 changed files with 2 additions and 16 deletions

View File

@ -160,14 +160,7 @@ def do_formdef_tables(formdef):
# delete obsolete fields
for field in (existing_fields - needed_fields):
try:
cur.execute('''ALTER TABLE %s DROP COLUMN IF EXISTS %s''' % (table_name, field))
except psycopg2.ProgrammingError:
# Postgreql < 9 doesn't have support for "IF EXISTS"
try:
cur.execute('''ALTER TABLE %s DROP COLUMN %s''' % (table_name, field))
except psycopg2.ProgrammingError:
pass
cur.execute('''ALTER TABLE %s DROP COLUMN %s''' % (table_name, field))
conn.commit()
cur.close()
@ -220,14 +213,7 @@ def do_user_table():
# delete obsolete fields
for field in (existing_fields - needed_fields):
try:
cur.execute('''ALTER TABLE %s DROP COLUMN IF EXISTS %s''' % (table_name, field))
except psycopg2.ProgrammingError:
# Postgreql < 9 doesn't have support for "IF EXISTS"
try:
cur.execute('''ALTER TABLE %s DROP COLUMN %s''' % (table_name, field))
except psycopg2.ProgrammingError:
pass
cur.execute('''ALTER TABLE %s DROP COLUMN %s''' % (table_name, field))
conn.commit()
cur.close()