[ARVADOS] updated: 155e542971974020412ad41d22e616290be5cc94

git at public.curoverse.com git at public.curoverse.com
Mon Dec 8 13:02:32 EST 2014


Summary of changes:
 .../db/migrate/20141208164553_owner_uuid_index.rb  |  26 ++++
 services/api/db/structure.sql                      | 143 ++++++++++++++++++++-
 services/api/test/unit/arvados_model_test.rb       |  40 ++++++
 3 files changed, 205 insertions(+), 4 deletions(-)
 create mode 100644 services/api/db/migrate/20141208164553_owner_uuid_index.rb

       via  155e542971974020412ad41d22e616290be5cc94 (commit)
      from  3147edd07223f5ecac0c12d4ec34cc4c4cb7d657 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 155e542971974020412ad41d22e616290be5cc94
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Mon Dec 8 12:48:41 2014 -0500

    4523: add owner_uuid index on all tables that support this column.

diff --git a/services/api/db/migrate/20141208164553_owner_uuid_index.rb b/services/api/db/migrate/20141208164553_owner_uuid_index.rb
new file mode 100644
index 0000000..9ba0c5a
--- /dev/null
+++ b/services/api/db/migrate/20141208164553_owner_uuid_index.rb
@@ -0,0 +1,26 @@
+class OwnerUuidIndex < ActiveRecord::Migration
+  def tables_with_owner_uuid
+    all_tables = ActiveRecord::Base.connection.tables
+    my_tables = []
+    all_tables.each do |table|
+      columns = ActiveRecord::Base.connection.columns(table)
+      uuid_column = columns.select do |column|
+        column.name == 'owner_uuid'
+      end
+      my_tables << table if !uuid_column.empty?
+    end
+    my_tables
+  end
+
+  def up
+    tables_with_owner_uuid.each do |table|
+      add_index table.to_sym, :owner_uuid
+    end
+  end
+
+  def down
+    tables_with_owner_uuid.each do |table|
+      remove_index table.to_sym, :owner_uuid
+    end
+  end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 0a2dc8d..2862f0b 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -683,11 +683,11 @@ CREATE TABLE pipeline_instances (
     components text,
     updated_at timestamp without time zone NOT NULL,
     properties text,
-    components_summary text,
     state character varying(255),
+    components_summary text,
+    description text,
     started_at timestamp without time zone,
-    finished_at timestamp without time zone,
-    description text
+    finished_at timestamp without time zone
 );
 
 
@@ -1335,6 +1335,13 @@ CREATE INDEX index_api_clients_on_modified_at ON api_clients USING btree (modifi
 
 
 --
+-- Name: index_api_clients_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_api_clients_on_owner_uuid ON api_clients USING btree (owner_uuid);
+
+
+--
 -- Name: index_api_clients_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1349,6 +1356,13 @@ CREATE INDEX index_authkeys_on_user_and_expires_at ON authorized_keys USING btre
 
 
 --
+-- Name: index_authorized_keys_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_authorized_keys_on_owner_uuid ON authorized_keys USING btree (owner_uuid);
+
+
+--
 -- Name: index_authorized_keys_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1370,6 +1384,13 @@ CREATE INDEX index_collections_on_modified_at ON collections USING btree (modifi
 
 
 --
+-- Name: index_collections_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_collections_on_owner_uuid ON collections USING btree (owner_uuid);
+
+
+--
 -- Name: index_collections_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1412,6 +1433,13 @@ CREATE INDEX index_groups_on_modified_at ON groups USING btree (modified_at);
 
 
 --
+-- Name: index_groups_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_groups_on_owner_uuid ON groups USING btree (owner_uuid);
+
+
+--
 -- Name: index_groups_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1419,6 +1447,13 @@ CREATE UNIQUE INDEX index_groups_on_uuid ON groups USING btree (uuid);
 
 
 --
+-- Name: index_humans_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_humans_on_owner_uuid ON humans USING btree (owner_uuid);
+
+
+--
 -- Name: index_humans_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1447,6 +1482,13 @@ CREATE INDEX index_job_tasks_on_modified_at ON job_tasks USING btree (modified_a
 
 
 --
+-- Name: index_job_tasks_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_job_tasks_on_owner_uuid ON job_tasks USING btree (owner_uuid);
+
+
+--
 -- Name: index_job_tasks_on_sequence; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1496,6 +1538,13 @@ CREATE INDEX index_jobs_on_output ON jobs USING btree (output);
 
 
 --
+-- Name: index_jobs_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_jobs_on_owner_uuid ON jobs USING btree (owner_uuid);
+
+
+--
 -- Name: index_jobs_on_script; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1545,6 +1594,13 @@ CREATE INDEX index_keep_disks_on_node_uuid ON keep_disks USING btree (node_uuid)
 
 
 --
+-- Name: index_keep_disks_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_keep_disks_on_owner_uuid ON keep_disks USING btree (owner_uuid);
+
+
+--
 -- Name: index_keep_disks_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1552,6 +1608,13 @@ CREATE UNIQUE INDEX index_keep_disks_on_uuid ON keep_disks USING btree (uuid);
 
 
 --
+-- Name: index_keep_services_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_keep_services_on_owner_uuid ON keep_services USING btree (owner_uuid);
+
+
+--
 -- Name: index_keep_services_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1580,6 +1643,13 @@ CREATE INDEX index_links_on_modified_at ON links USING btree (modified_at);
 
 
 --
+-- Name: index_links_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_links_on_owner_uuid ON links USING btree (owner_uuid);
+
+
+--
 -- Name: index_links_on_tail_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1629,6 +1699,13 @@ CREATE INDEX index_logs_on_object_uuid ON logs USING btree (object_uuid);
 
 
 --
+-- Name: index_logs_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_logs_on_owner_uuid ON logs USING btree (owner_uuid);
+
+
+--
 -- Name: index_logs_on_summary; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1664,6 +1741,13 @@ CREATE INDEX index_nodes_on_modified_at ON nodes USING btree (modified_at);
 
 
 --
+-- Name: index_nodes_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_nodes_on_owner_uuid ON nodes USING btree (owner_uuid);
+
+
+--
 -- Name: index_nodes_on_slot_number; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1692,6 +1776,13 @@ CREATE INDEX index_pipeline_instances_on_modified_at ON pipeline_instances USING
 
 
 --
+-- Name: index_pipeline_instances_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_pipeline_instances_on_owner_uuid ON pipeline_instances USING btree (owner_uuid);
+
+
+--
 -- Name: index_pipeline_instances_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1713,6 +1804,13 @@ CREATE INDEX index_pipeline_templates_on_modified_at ON pipeline_templates USING
 
 
 --
+-- Name: index_pipeline_templates_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_pipeline_templates_on_owner_uuid ON pipeline_templates USING btree (owner_uuid);
+
+
+--
 -- Name: index_pipeline_templates_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1727,6 +1825,13 @@ CREATE UNIQUE INDEX index_repositories_on_name ON repositories USING btree (name
 
 
 --
+-- Name: index_repositories_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_repositories_on_owner_uuid ON repositories USING btree (owner_uuid);
+
+
+--
 -- Name: index_repositories_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1748,6 +1853,13 @@ CREATE INDEX index_specimens_on_modified_at ON specimens USING btree (modified_a
 
 
 --
+-- Name: index_specimens_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_specimens_on_owner_uuid ON specimens USING btree (owner_uuid);
+
+
+--
 -- Name: index_specimens_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1762,6 +1874,13 @@ CREATE INDEX index_traits_on_name ON traits USING btree (name);
 
 
 --
+-- Name: index_traits_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_traits_on_owner_uuid ON traits USING btree (owner_uuid);
+
+
+--
 -- Name: index_traits_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1783,6 +1902,13 @@ CREATE INDEX index_users_on_modified_at ON users USING btree (modified_at);
 
 
 --
+-- Name: index_users_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_users_on_owner_uuid ON users USING btree (owner_uuid);
+
+
+--
 -- Name: index_users_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -1797,6 +1923,13 @@ CREATE INDEX index_virtual_machines_on_hostname ON virtual_machines USING btree
 
 
 --
+-- Name: index_virtual_machines_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE INDEX index_virtual_machines_on_owner_uuid ON virtual_machines USING btree (owner_uuid);
+
+
+--
 -- Name: index_virtual_machines_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -2032,4 +2165,6 @@ INSERT INTO schema_migrations (version) VALUES ('20140918153705');
 
 INSERT INTO schema_migrations (version) VALUES ('20140924091559');
 
-INSERT INTO schema_migrations (version) VALUES ('20141111133038');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20141111133038');
+
+INSERT INTO schema_migrations (version) VALUES ('20141208164553');
\ No newline at end of file
diff --git a/services/api/test/unit/arvados_model_test.rb b/services/api/test/unit/arvados_model_test.rb
index e47aa3b..a3b7adc 100644
--- a/services/api/test/unit/arvados_model_test.rb
+++ b/services/api/test/unit/arvados_model_test.rb
@@ -86,4 +86,44 @@ class ArvadosModelTest < ActiveSupport::TestCase
                    properties: {'foo' => 'bar'}.with_indifferent_access)
     end
   end
+
+  test "unique uuid index exists on all models with the column uuid" do 
+    tables = ActiveRecord::Base.connection.tables
+    tables.each do |table|
+      columns = ActiveRecord::Base.connection.columns(table)
+
+      uuid_column = columns.select do |column|
+        column.name == 'uuid'
+      end
+
+      if !uuid_column.empty?
+        indexes = ActiveRecord::Base.connection.indexes(table)
+        uuid_index = indexes.select do |index|
+          index.columns == ['uuid'] and index.unique == true
+        end
+
+        assert !uuid_index.empty?, "#{table} does not have unique uuid index"
+      end
+    end
+  end
+
+  test "owner uuid index exists on all models with the owner_uuid column" do
+    all_tables = ActiveRecord::Base.connection.tables
+
+    all_tables.each do |table|
+      columns = ActiveRecord::Base.connection.columns(table)
+
+      uuid_column = columns.select do |column|
+        column.name == 'owner_uuid'
+      end
+
+      if !uuid_column.empty?
+        indexes = ActiveRecord::Base.connection.indexes(table)
+        owner_uuid_index = indexes.select do |index|
+          index.columns == ['owner_uuid']
+        end
+        assert !owner_uuid_index.empty?, "#{table} does not have owner_uuid index"
+      end
+    end
+  end
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list