13562: Add "properties" field to groups, supports subproperty query.
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 8 Jun 2018 12:59:56 +0000 (08:59 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 8 Jun 2018 12:59:56 +0000 (08:59 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

services/api/app/models/group.rb
services/api/db/migrate/20180608123145_add_properties_to_groups.rb [new file with mode: 0644]
services/api/db/structure.sql

index fe183678c155855a19e6acd2fc4cf8089cd6749e..7a7f0a3a600643cd43afe4d0eca3a2f66ef2a2b1 100644 (file)
@@ -12,6 +12,8 @@ class Group < ArvadosModel
   include CanBeAnOwner
   include Trashable
 
+  serialize :properties, Hash
+
   after_create :invalidate_permissions_cache
   after_update :maybe_invalidate_permissions_cache
   before_create :assign_name
@@ -24,6 +26,7 @@ class Group < ArvadosModel
     t.add :delete_at
     t.add :trash_at
     t.add :is_trashed
+    t.add :properties
   end
 
   def maybe_invalidate_permissions_cache
diff --git a/services/api/db/migrate/20180608123145_add_properties_to_groups.rb b/services/api/db/migrate/20180608123145_add_properties_to_groups.rb
new file mode 100644 (file)
index 0000000..a969456
--- /dev/null
@@ -0,0 +1,11 @@
+class AddPropertiesToGroups < ActiveRecord::Migration
+  def up
+    add_column :groups, :properties, :jsonb, default: {}
+    ActiveRecord::Base.connection.execute("CREATE INDEX group_index_on_properties ON groups USING gin (properties);")
+  end
+
+  def down
+    ActiveRecord::Base.connection.execute("DROP INDEX IF EXISTS group_index_on_properties")
+    remove_column :groups, :properties
+  end
+end
index 0ab30c5e1cf0d2b7af810c0a264ae888a52ebeb5..20ce89c22db2969b38a62f62267a9349edf76a17 100644 (file)
@@ -396,7 +396,8 @@ CREATE TABLE groups (
     group_class character varying(255),
     trash_at timestamp without time zone,
     is_trashed boolean DEFAULT false NOT NULL,
-    delete_at timestamp without time zone
+    delete_at timestamp without time zone,
+    properties jsonb DEFAULT '{}'::jsonb
 );
 
 
@@ -1654,6 +1655,13 @@ CREATE INDEX container_requests_search_index ON container_requests USING btree (
 CREATE INDEX containers_search_index ON containers USING btree (uuid, owner_uuid, modified_by_client_uuid, modified_by_user_uuid, state, log, cwd, output_path, output, container_image, auth_uuid, locked_by_uuid);
 
 
+--
+-- Name: group_index_on_properties; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX group_index_on_properties ON groups USING gin (properties);
+
+
 --
 -- Name: groups_full_text_search_idx; Type: INDEX; Schema: public; Owner: -
 --
@@ -3080,3 +3088,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180501182859');
 
 INSERT INTO schema_migrations (version) VALUES ('20180514135529');
 
+INSERT INTO schema_migrations (version) VALUES ('20180608123145');
+