Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/upgrade/3_7_1/update_db_data.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/upgrade/3_7_1/update_db_data.py	(revision 2454)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/upgrade/3_7_1/update_db_data.py	(working copy)
@@ -42,7 +42,7 @@
     UPDATE file_list
     SET file_type_id = file_type_cte.id
     FROM file_type_cte
-    WHERE file_list.file_type_name = file_type_cte.name
+    WHERE file_list.type = file_type_cte.name
       AND file_list.file_type_id IS NULL;
     '''
 
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/upgrade/3_7_1/update_db_schema.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/upgrade/3_7_1/update_db_schema.py	(revision 2454)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/upgrade/3_7_1/update_db_schema.py	(working copy)
@@ -1,5 +1,5 @@
-import sys
 import os
+import sys
 
 # Get the current file's directory
 current_dir = os.path.dirname(os.path.abspath(__file__))
@@ -20,7 +20,7 @@
     update_device_grp_query = '''ALTER TABLE device_group
                            ADD COLUMN IF NOT EXISTS id SERIAL;
                            ALTER TABLE role_device_group DROP CONSTRAINT IF EXISTS role_device_group_device_group_name_fkey;
-                           ALTER TABLE device_group DROP CONSTRAINT IF EXISTS device_group_pkey CASCADE;
+                           ALTER TABLE device_group DROP CONSTRAINT IF EXISTS device_group_id_pkey CASCADE;
                            ALTER TABLE device_group ADD CONSTRAINT device_group_id_pkey PRIMARY KEY (id);
                            ALTER TABLE role_device_group ADD COLUMN IF NOT EXISTS device_group_id int;
                            ALTER TABLE role_device_group ADD CONSTRAINT role_dev_grp_name_fkey FOREIGN KEY(device_group_id)
@@ -30,9 +30,8 @@
                                      ADD COLUMN IF NOT EXISTS id SERIAL;
                                      ALTER TABLE file_list ADD COLUMN IF NOT EXISTS device_id varchar(64);
                                      ALTER TABLE file_list DROP CONSTRAINT IF EXISTS file_list_type_fkey;
-                                     ALTER TABLE file_type DROP CONSTRAINT IF EXISTS file_type_pkey CASCADE;
+                                     ALTER TABLE file_type DROP CONSTRAINT IF EXISTS file_type_id_pkey CASCADE;
                                      ALTER TABLE file_type ADD CONSTRAINT file_type_id_pkey PRIMARY KEY (id);
-                                     ALTER TABLE file_list RENAME COLUMN type TO file_type_name;
                                      ALTER TABLE file_list ADD COLUMN IF NOT EXISTS file_type_id int;
                                      ALTER TABLE file_list ADD CONSTRAINT file_list_type_fkey FOREIGN KEY(file_type_id)
                                      REFERENCES file_type(id) ON DELETE CASCADE; '''
@@ -41,7 +40,7 @@
         db.execute_sql(update_file_type_list_query)
     except Exception as e:
         # Unable to import oper_log. Using print for now
-        print('Exception while executing update queries:{}'.format(e.message))
+        print('Exception while executing update queries(alter_table_file_type_list):{}'.format(e.message))
     finally:
         db.close()
 
@@ -50,16 +49,15 @@
     db = DB.get_connected_db()
     update_log_host_query = '''ALTER TABLE log_host
                                 DROP CONSTRAINT IF EXISTS log_host_pkey CASCADE;
-                                ALTER TABLE log_host
-                                ADD COLUMN IF NOT EXISTS id SERIAL PRIMARY KEY;
-                                ALTER TABLE log_host
-                                ADD CONSTRAINT unique_host_port_protocol UNIQUE (host, port, protocol);'''
+                                ALTER TABLE log_host ADD COLUMN IF NOT EXISTS id SERIAL PRIMARY KEY;
+                                ALTER TABLE log_host DROP CONSTRAINT IF EXISTS unique_host_port_protocol;
+                                ALTER TABLE log_host ADD CONSTRAINT unique_host_port_protocol UNIQUE (host, port, protocol);'''
 
     try:
         db.execute_sql(update_log_host_query)
     except Exception as e:
         # Unable to import oper_log. Using print for now
-        print('Exception while executing update queries:{}'.format(e.message))
+        print('Exception while executing update queries(alter_table_log_host) :{}'.format(e.message))
     finally:
         db.close()
 
@@ -68,16 +66,15 @@
     db = DB.get_connected_db()
     update_proxy_cm_query = '''ALTER TABLE proxy_cm
                                DROP CONSTRAINT IF EXISTS proxy_cm_pkey CASCADE;
-                               ALTER TABLE proxy_cm
-                               ADD COLUMN IF NOT EXISTS id SERIAL PRIMARY KEY;
-                               ALTER TABLE proxy_cm
-                               ADD CONSTRAINT unique_name UNIQUE (name);'''
+                               ALTER TABLE proxy_cm ADD COLUMN IF NOT EXISTS id SERIAL PRIMARY KEY;
+                               ALTER TABLE proxy_cm DROP CONSTRAINT IF EXISTS unique_name;
+                               ALTER TABLE proxy_cm ADD CONSTRAINT unique_name UNIQUE (name);'''
 
     try:
         db.execute_sql(update_proxy_cm_query)
     except Exception as e:
         # Unable to import oper_log. Using print for now
-        print('Exception while executing update queries:{}'.format(e.message))
+        print('Exception while executing update queries(alter_table_proxy_cm) :{}'.format(e.message))
     finally:
         db.close()
 
@@ -93,7 +90,7 @@
         db.execute_sql(update_schedule_backup_query)
     except Exception as e:
         # Unable to import oper_log. Using print for now
-        print('Exception while executing update queries:{}'.format(e.message))
+        print('Exception while executing update queries(alter_table_schedule_backup): {}'.format(e.message))
     finally:
         db.close()
 
@@ -102,4 +99,4 @@
     alter_table_file_type_list()
     alter_table_log_host()
     alter_table_proxy_cm()
-    alter_table_schedule_backup()
\ No newline at end of file
+    alter_table_schedule_backup()
