Rename the tables in the databases, by prefixing the app name. This is
in preparation for merging the two databases and the two Django
projects into one.

Note that this renames *all* standard Autotest DB tables in both the
autotest_web and tko databases.  If you have scripts written directly
against these databases, *they will break*.  If your scripts access
the RPC interfaces, they should continue to work.

Another patch will be along within the next few weeks to actually move
the TKO tables into the autotest_web database.

From: James Ren <jamesren@google.com>
Signed-off-by: Steve Howard <showard@google.com>

Rename the tables in the databases, by prefixing the app name. This is
in preparation for merging the two databases and the two Django projects
into one.

Note that this renames *all* standard Autotest DB tables in both the autotest_web and tko databases.  If you have scripts written directly against these databases, *they will break*.  If your scripts access the RPC interfaces, they should continue to work.

From: James Ren <jamesren@google.com>
Signed-off-by: Steve Howard <showard@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4040 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 26555d9..8b993a8 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -100,9 +100,11 @@
                 (running and finished)), ('Cannot specify more than one '
                                           'filter to this function')
 
-    not_queued = ('(SELECT job_id FROM host_queue_entries WHERE status != "%s")'
+    not_queued = ('(SELECT job_id FROM afe_host_queue_entries '
+                  'WHERE status != "%s")'
                   % models.HostQueueEntry.Status.QUEUED)
-    not_finished = '(SELECT job_id FROM host_queue_entries WHERE not complete)'
+    not_finished = ('(SELECT job_id FROM afe_host_queue_entries '
+                    'WHERE not complete)')
 
     if not_yet_run:
         where = ['id NOT IN ' + not_queued]
@@ -121,7 +123,7 @@
     labels.
     """
     extra_args = {}
-    where_str = ('hosts.id in (select host_id from hosts_labels '
+    where_str = ('afe_hosts.id in (select host_id from afe_hosts_labels '
                  'where label_id=%s)')
     extra_args['where'] = [where_str] * len(multiple_labels)
     extra_args['params'] = [models.Label.smart_get(label).id
@@ -144,8 +146,8 @@
                     str(label['id'])
                     for label in only_if_needed_labels.values('id'))
             query = models.Host.objects.add_join(
-                query, 'hosts_labels', join_key='host_id',
-                join_condition=('hosts_labels_exclude_OIN.label_id IN (%s)'
+                query, 'afe_hosts_labels', join_key='host_id',
+                join_condition=('afe_hosts_labels_exclude_OIN.label_id IN (%s)'
                                 % only_if_needed_ids),
                 suffix='_exclude_OIN', exclude=True)
 
@@ -157,9 +159,10 @@
                     str(atomic_group['id'])
                     for atomic_group in atomic_group_labels.values('id'))
             query = models.Host.objects.add_join(
-                    query, 'hosts_labels', join_key='host_id',
-                    join_condition=('hosts_labels_exclude_AG.label_id IN (%s)'
-                                    % atomic_group_label_ids),
+                    query, 'afe_hosts_labels', join_key='host_id',
+                    join_condition=(
+                            'afe_hosts_labels_exclude_AG.label_id IN (%s)'
+                            % atomic_group_label_ids),
                     suffix='_exclude_AG', exclude=True)
 
     assert 'extra_args' not in filter_data