[ARVADOS] updated: 8f9055ed305180509af7e2527a5bfee84d417a58
git at public.curoverse.com
git at public.curoverse.com
Mon Dec 8 15:36:24 EST 2014
Summary of changes:
.../db/migrate/20141208164553_owner_uuid_index.rb | 26 ++++
.../api/db/migrate/20141208185217_search_index.rb | 29 ++++
services/api/db/structure.sql | 169 ++++++++++++++++++++-
services/api/test/unit/arvados_model_test.rb | 58 +++++++
4 files changed, 278 insertions(+), 4 deletions(-)
create mode 100644 services/api/db/migrate/20141208164553_owner_uuid_index.rb
create mode 100644 services/api/db/migrate/20141208185217_search_index.rb
via 8f9055ed305180509af7e2527a5bfee84d417a58 (commit)
via c48d1065413543feff55260bb46b29f984b228df (commit)
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 8f9055ed305180509af7e2527a5bfee84d417a58
Author: Radhika Chippada <radhika at curoverse.com>
Date: Mon Dec 8 15:22:11 2014 -0500
4523: search index migration script
diff --git a/services/api/db/migrate/20141208185217_search_index.rb b/services/api/db/migrate/20141208185217_search_index.rb
new file mode 100644
index 0000000..79dea39
--- /dev/null
+++ b/services/api/db/migrate/20141208185217_search_index.rb
@@ -0,0 +1,29 @@
+class SearchIndex < ActiveRecord::Migration
+ def tables_with_searchable_columns
+ all_tables = ActiveRecord::Base.connection.tables
+ all_tables.delete 'schema_migrations'
+
+ my_tables = []
+ all_tables.each do |table|
+ table_class = table.classify.constantize
+ if table_class.respond_to?('searchable_columns')
+ my_tables << table
+ end
+ end
+
+ my_tables
+ end
+
+ def up
+ tables_with_searchable_columns.each do |table|
+ indices = table.classify.constantize.searchable_columns('ilike')
+ add_index(table.to_sym, indices, name: "#{table}_search_index")
+ end
+ end
+
+ def down
+ tables_with_searchable_columns.each do |table, indices|
+ remove_index(table.to_sym, name: "#{table}_search_index")
+ end
+ end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 0da865d..059b43b 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -1377,13 +1377,6 @@ 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:
--
@@ -1398,13 +1391,6 @@ 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:
--
@@ -1426,13 +1412,6 @@ 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:
--
@@ -1475,13 +1454,6 @@ 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:
--
@@ -1489,13 +1461,6 @@ 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:
--
@@ -1524,13 +1489,6 @@ 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:
--
@@ -1580,13 +1538,6 @@ 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:
--
@@ -1636,13 +1587,6 @@ 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:
--
@@ -1650,13 +1594,6 @@ 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:
--
@@ -1685,13 +1622,6 @@ 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:
--
@@ -1741,13 +1671,6 @@ 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:
--
@@ -1783,13 +1706,6 @@ 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:
--
@@ -1818,13 +1734,6 @@ 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:
--
@@ -1846,13 +1755,6 @@ 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:
--
@@ -1867,13 +1769,6 @@ 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:
--
@@ -1895,13 +1790,6 @@ 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:
--
@@ -1916,13 +1804,6 @@ 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:
--
@@ -1944,38 +1825,52 @@ 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:
+-- Name: index_users_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX index_users_on_uuid ON users USING btree (uuid);
+
+
+--
+-- Name: index_virtual_machines_on_hostname; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE INDEX index_users_on_owner_uuid ON users USING btree (owner_uuid);
+CREATE INDEX index_virtual_machines_on_hostname ON virtual_machines USING btree (hostname);
--
--- Name: index_users_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace:
+-- Name: index_virtual_machines_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE UNIQUE INDEX index_users_on_uuid ON users USING btree (uuid);
+CREATE UNIQUE INDEX index_virtual_machines_on_uuid ON virtual_machines USING btree (uuid);
--
--- Name: index_virtual_machines_on_hostname; Type: INDEX; Schema: public; Owner: -; Tablespace:
+-- Name: job_tasks_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE INDEX index_virtual_machines_on_hostname ON virtual_machines USING btree (hostname);
+CREATE INDEX job_tasks_search_index ON job_tasks USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, job_uuid, parameters, output, created_by_job_task_uuid);
--
--- Name: index_virtual_machines_on_owner_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace:
+-- Name: keep_disks_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE INDEX index_virtual_machines_on_owner_uuid ON virtual_machines USING btree (owner_uuid);
+CREATE INDEX keep_disks_search_index ON keep_disks USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, ping_secret, node_uuid, filesystem_uuid, keep_service_uuid);
--
--- Name: index_virtual_machines_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace:
+-- Name: keep_services_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE UNIQUE INDEX index_virtual_machines_on_uuid ON virtual_machines USING btree (uuid);
+CREATE INDEX keep_services_search_index ON keep_services USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, service_host, service_type);
+
+
+--
+-- Name: links_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX links_search_index ON links USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, tail_uuid, link_class, name, head_uuid, properties);
--
@@ -2299,5 +2194,3 @@ INSERT INTO schema_migrations (version) VALUES ('20140918153705');
INSERT INTO schema_migrations (version) VALUES ('20140924091559');
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 7fab34c..b9bd330 100644
--- a/services/api/test/unit/arvados_model_test.rb
+++ b/services/api/test/unit/arvados_model_test.rb
@@ -140,7 +140,7 @@ class ArvadosModelTest < ActiveSupport::TestCase
search_index = indexes.select do |index|
index.columns == search_index_columns
end
- assert !search_index.empty?, "#{table} does not have search index with all searchable columns"
+ assert !search_index.empty?, "#{table} does not have search index with all searchable columns #{search_index_columns}"
end
end
end
commit c48d1065413543feff55260bb46b29f984b228df
Author: Radhika Chippada <radhika at curoverse.com>
Date: Mon Dec 8 15:20:09 2014 -0500
4523: add search index
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 2862f0b..0da865d 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -1279,6 +1279,27 @@ ALTER TABLE ONLY virtual_machines
--
+-- Name: api_client_authorizations_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX api_client_authorizations_search_index ON api_client_authorizations USING btree (api_token, created_by_ip_address, last_used_by_ip_address, default_owner_uuid, scopes);
+
+
+--
+-- Name: api_clients_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX api_clients_search_index ON api_clients USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, name, url_prefix);
+
+
+--
+-- Name: authorized_keys_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX authorized_keys_search_index ON authorized_keys USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, name, key_type, authorized_user_uuid, public_key);
+
+
+--
-- Name: collection_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1286,6 +1307,13 @@ CREATE UNIQUE INDEX collection_owner_uuid_name_unique ON collections USING btree
--
+-- Name: collections_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX collections_search_index ON collections USING btree (owner_uuid, modified_by_client_uuid, modified_by_user_uuid, portable_data_hash, redundancy_confirmed_by_client_uuid, uuid, manifest_text, name, description, properties);
+
+
+--
-- Name: groups_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1293,6 +1321,20 @@ CREATE UNIQUE INDEX groups_owner_uuid_name_unique ON groups USING btree (owner_u
--
+-- Name: groups_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX groups_search_index ON groups USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, name, description, group_class);
+
+
+--
+-- Name: humans_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX humans_search_index ON humans USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, properties);
+
+
+--
-- Name: index_api_client_authorizations_on_api_client_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1937,6 +1979,34 @@ CREATE UNIQUE INDEX index_virtual_machines_on_uuid ON virtual_machines USING btr
--
+-- Name: job_tasks_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX job_tasks_search_index ON job_tasks USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, job_uuid, parameters, output, created_by_job_task_uuid);
+
+
+--
+-- Name: keep_disks_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX keep_disks_search_index ON keep_disks USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, ping_secret, node_uuid, filesystem_uuid, keep_service_uuid);
+
+
+--
+-- Name: keep_services_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX keep_services_search_index ON keep_services USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, service_host, service_type);
+
+
+--
+-- Name: links_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX links_search_index ON links USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, tail_uuid, link_class, name, head_uuid, properties);
+
+
+--
-- Name: links_tail_name_unique_if_link_class_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1944,6 +2014,27 @@ CREATE UNIQUE INDEX links_tail_name_unique_if_link_class_name ON links USING btr
--
+-- Name: logs_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX logs_search_index ON logs USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, object_uuid, event_type, summary, properties, object_owner_uuid);
+
+
+--
+-- Name: nodes_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX nodes_search_index ON nodes USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, hostname, domain, ip_address, info, properties, job_uuid);
+
+
+--
+-- Name: pipeline_instances_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX pipeline_instances_search_index ON pipeline_instances USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, pipeline_template_uuid, name, components, properties, state, components_summary, description);
+
+
+--
-- Name: pipeline_template_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1951,6 +2042,34 @@ CREATE UNIQUE INDEX pipeline_template_owner_uuid_name_unique ON pipeline_templat
--
+-- Name: pipeline_templates_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX pipeline_templates_search_index ON pipeline_templates USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, name, components, description);
+
+
+--
+-- Name: repositories_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX repositories_search_index ON repositories USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, name, fetch_url, push_url);
+
+
+--
+-- Name: specimens_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX specimens_search_index ON specimens USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, material, properties);
+
+
+--
+-- Name: traits_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX traits_search_index ON traits USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, name, properties);
+
+
+--
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1958,6 +2077,20 @@ CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (v
--
+-- Name: users_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX users_search_index ON users USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, email, first_name, last_name, identity_url, prefs, default_owner_uuid);
+
+
+--
+-- Name: virtual_machines_search_index; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE INDEX virtual_machines_search_index ON virtual_machines USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, hostname);
+
+
+--
-- PostgreSQL database dump complete
--
diff --git a/services/api/test/unit/arvados_model_test.rb b/services/api/test/unit/arvados_model_test.rb
index a3b7adc..7fab34c 100644
--- a/services/api/test/unit/arvados_model_test.rb
+++ b/services/api/test/unit/arvados_model_test.rb
@@ -126,4 +126,22 @@ class ArvadosModelTest < ActiveSupport::TestCase
end
end
end
+
+ test "search index exists on models that go into projects" do
+ all_tables = ActiveRecord::Base.connection.tables
+ all_tables.delete 'schema_migrations'
+
+ all_tables.each do |table|
+ table_class = table.classify.constantize
+ if table_class.respond_to?('searchable_columns')
+ search_index_columns = table_class.searchable_columns('ilike')
+
+ indexes = ActiveRecord::Base.connection.indexes(table)
+ search_index = indexes.select do |index|
+ index.columns == search_index_columns
+ end
+ assert !search_index.empty?, "#{table} does not have search index with all searchable columns"
+ end
+ end
+ end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list