[ARVADOS] created: 3251b50fed55eeb1c30fd7bf996f715490ee2104

git at public.curoverse.com git at public.curoverse.com
Tue Aug 12 16:53:20 EDT 2014


        at  3251b50fed55eeb1c30fd7bf996f715490ee2104 (commit)


commit 3251b50fed55eeb1c30fd7bf996f715490ee2104
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Aug 12 16:53:13 2014 -0400

    3036: More work verifying that migration does the right thing.

diff --git a/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb b/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
index cd7979a..9dc19ff 100644
--- a/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
+++ b/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
@@ -7,15 +7,14 @@ class CollectionUseRegularUuids < ActiveRecord::Migration
     remove_column :collections, :locator
 
     # Step 1.  Move manifest hashes into portable_data_hash field
-    ActiveRecord::Base.connection.execute("update collections set portable_data_hash=uuid, uuid=null;")
+    ActiveRecord::Base.connection.execute("update collections set portable_data_hash=uuid, uuid=null")
 
     # Step 2.  Create new collection objects from the name links in the table.
     links = ActiveRecord::Base.connection.select_all %{
 select links.uuid, head_uuid, tail_uuid, links.name, manifest_text, links.created_at, links.updated_at
 from links inner join collections on head_uuid=collections.portable_data_hash
-where link_class='name'
+where link_class='name' and collections.uuid is null
 }
-    deletelinks = []
     links.each do |d|
       ActiveRecord::Base.connection.execute %{
 insert into collections (uuid, portable_data_hash, owner_uuid, name, manifest_text, created_at, updated_at)
@@ -27,16 +26,16 @@ values (#{ActiveRecord::Base.connection.quote Collection.generate_uuid},
 #{ActiveRecord::Base.connection.quote d['created_at']},
 #{ActiveRecord::Base.connection.quote d['updated_at']})
 }
-      deletelinks << d['uuid']
+      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d['uuid']}")
     end
 
     # Step 3.  Create new collection objects from the can_read links in the table.
-    data = ActiveRecord::Base.connection.select_all %{
-select head_uuid, tail_uuid, manifest_text, links.created_at, links. updated_at
+    links = ActiveRecord::Base.connection.select_all %{
+select links.uuid, head_uuid, tail_uuid, manifest_text, links.created_at, links.updated_at
 from links inner join collections on head_uuid=collections.portable_data_hash
 where link_class='permission' and links.name='can_read' and collections.uuid is null
 }
-    data.each do |d|
+    links.each do |d|
       ActiveRecord::Base.connection.execute %{
 insert into collections (uuid, portable_data_hash, owner_uuid, manifest_text, created_at, updated_at)
 values (#{ActiveRecord::Base.connection.quote Collection.generate_uuid},
@@ -46,17 +45,23 @@ values (#{ActiveRecord::Base.connection.quote Collection.generate_uuid},
 #{ActiveRecord::Base.connection.quote d['created_at']},
 #{ActiveRecord::Base.connection.quote d['updated_at']})
 }
-      deletelinks << d['uuid']
+      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d['uuid']}")
+    end
+
+    # Step 4.  Delete permission links with tail_uuid of a collection (these records are just invalid)
+    links = ActiveRecord::Base.connection.select_all "select links.uuid from links inner join collections on links.tail_uuid=collections.portable_data_hash where link_class='permission'"
+    links.each do |d|
+      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d['uuid']}")
     end
 
-    # Step 4. Migrate links
-    # 4.1 migrate head_uuid that look like collections
-    data = ActiveRecord::Base.connection.select_all %{
+    # Step 5. Migrate other links
+    # 5.1 migrate head_uuid that look like collections
+    links = ActiveRecord::Base.connection.select_all %{
 select links.uuid, collections.uuid as coluuid, tail_uuid, link_class, links.properties, links.name, links.created_at, links.updated_at, links.owner_uuid
 from links inner join collections on links.head_uuid=portable_data_hash
-where head_uuid like '________________________________+%' and collections.uuid is not null and links.link_class != 'name' and links.link_class != 'permission'
+where collections.uuid is not null and links.link_class != 'name' and links.link_class != 'permission'
 }
-    data.each do |d|
+    links.each do |d|
       ActiveRecord::Base.connection.execute %{
 insert into links (uuid, head_uuid, tail_uuid, link_class, name, properties, created_at, updated_at, owner_uuid)
 values (#{ActiveRecord::Base.connection.quote Link.generate_uuid},
@@ -69,16 +74,16 @@ values (#{ActiveRecord::Base.connection.quote Link.generate_uuid},
 #{ActiveRecord::Base.connection.quote d['updated_at']},
 #{ActiveRecord::Base.connection.quote d['owner_uuid']})
 }
-      deletelinks << d['uuid']
+      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d['uuid']}")
     end
 
-    # 4.2 migrate tail_uuid that look like collections
-    data = ActiveRecord::Base.connection.select_all %{
+    # 5.2 migrate tail_uuid that look like collections
+    links = ActiveRecord::Base.connection.select_all %{
 select links.uuid, head_uuid, collections.uuid as coluuid, link_class, links.properties, links.name, links.created_at, links.updated_at, links.owner_uuid
 from links inner join collections on links.tail_uuid=portable_data_hash
 where tail_uuid like '________________________________+%' and collections.uuid is not null and links.link_class != 'name' and links.link_class != 'permission'
 }
-    data.each do |d|
+    links.each do |d|
       newuuid = Link.generate_uuid
       ActiveRecord::Base.connection.execute %{
 insert into links (uuid, head_uuid, tail_uuid, link_class, name, properties, created_at, updated_at, owner_uuid)
@@ -92,15 +97,10 @@ values (#{ActiveRecord::Base.connection.quote newuuid},
 #{ActiveRecord::Base.connection.quote d['updated_at']},
 #{ActiveRecord::Base.connection.quote d['owner_uuid']})
 }
-      deletelinks << d['uuid']
-    end
-
-    # Step 5. Delete migrated links
-    deletelinks.each do |d|
-      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d} or head_uuid=#{ActiveRecord::Base.connection.quote d}")
+      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d['uuid']}")
     end
 
-    # Step 6. Delete old collection objects.
+    # Step 7. Delete old collection objects.
     ActiveRecord::Base.connection.execute("delete from collections where uuid is null")
   end
 
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index aa05031..b31825e 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -154,7 +154,6 @@ ALTER SEQUENCE authorized_keys_id_seq OWNED BY authorized_keys.id;
 
 CREATE TABLE collections (
     id integer NOT NULL,
-    locator character varying(255),
     owner_uuid character varying(255),
     created_at timestamp without time zone NOT NULL,
     modified_by_client_uuid character varying(255),
@@ -167,7 +166,11 @@ CREATE TABLE collections (
     redundancy_confirmed_as integer,
     updated_at timestamp without time zone NOT NULL,
     uuid character varying(255),
-    manifest_text text
+    manifest_text text,
+    name character varying(255),
+    description character varying(255),
+    properties character varying(255),
+    expire_time date
 );
 
 
@@ -1976,4 +1979,6 @@ INSERT INTO schema_migrations (version) VALUES ('20140627210837');
 
 INSERT INTO schema_migrations (version) VALUES ('20140709172343');
 
-INSERT INTO schema_migrations (version) VALUES ('20140714184006');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20140714184006');
+
+INSERT INTO schema_migrations (version) VALUES ('20140811184643');
\ No newline at end of file

commit 696822adee174ad70cfaa4315f035c54e09c0912
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Aug 12 11:35:27 2014 -0400

    3036: More work on migration code.  Now updates links table.  SQL syntax errors fixed.

diff --git a/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb b/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
index d82dcf9..cd7979a 100644
--- a/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
+++ b/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
@@ -3,32 +3,112 @@ class CollectionUseRegularUuids < ActiveRecord::Migration
     add_column :collections, :name, :string
     add_column :collections, :description, :string
     add_column :collections, :properties, :string
+    add_column :collections, :expire_time, :date
+    remove_column :collections, :locator
 
+    # Step 1.  Move manifest hashes into portable_data_hash field
     ActiveRecord::Base.connection.execute("update collections set portable_data_hash=uuid, uuid=null;")
 
-    data = ActiveRecord::Base.connection.select_all("select head_uuid, tail_uuid, links.name, manifest_text from links inner join collections on head_uuid=collections.portable_data_hash where link_class='name'")
-    created_at = Time.now
+    # Step 2.  Create new collection objects from the name links in the table.
+    links = ActiveRecord::Base.connection.select_all %{
+select links.uuid, head_uuid, tail_uuid, links.name, manifest_text, links.created_at, links.updated_at
+from links inner join collections on head_uuid=collections.portable_data_hash
+where link_class='name'
+}
+    deletelinks = []
+    links.each do |d|
+      ActiveRecord::Base.connection.execute %{
+insert into collections (uuid, portable_data_hash, owner_uuid, name, manifest_text, created_at, updated_at)
+values (#{ActiveRecord::Base.connection.quote Collection.generate_uuid},
+#{ActiveRecord::Base.connection.quote d['head_uuid']},
+#{ActiveRecord::Base.connection.quote d['tail_uuid']},
+#{ActiveRecord::Base.connection.quote d['name']},
+#{ActiveRecord::Base.connection.quote d['manifest_text']},
+#{ActiveRecord::Base.connection.quote d['created_at']},
+#{ActiveRecord::Base.connection.quote d['updated_at']})
+}
+      deletelinks << d['uuid']
+    end
+
+    # Step 3.  Create new collection objects from the can_read links in the table.
+    data = ActiveRecord::Base.connection.select_all %{
+select head_uuid, tail_uuid, manifest_text, links.created_at, links. updated_at
+from links inner join collections on head_uuid=collections.portable_data_hash
+where link_class='permission' and links.name='can_read' and collections.uuid is null
+}
+    data.each do |d|
+      ActiveRecord::Base.connection.execute %{
+insert into collections (uuid, portable_data_hash, owner_uuid, manifest_text, created_at, updated_at)
+values (#{ActiveRecord::Base.connection.quote Collection.generate_uuid},
+#{ActiveRecord::Base.connection.quote d['head_uuid']},
+#{ActiveRecord::Base.connection.quote d['tail_uuid']},
+#{ActiveRecord::Base.connection.quote d['manifest_text']},
+#{ActiveRecord::Base.connection.quote d['created_at']},
+#{ActiveRecord::Base.connection.quote d['updated_at']})
+}
+      deletelinks << d['uuid']
+    end
+
+    # Step 4. Migrate links
+    # 4.1 migrate head_uuid that look like collections
+    data = ActiveRecord::Base.connection.select_all %{
+select links.uuid, collections.uuid as coluuid, tail_uuid, link_class, links.properties, links.name, links.created_at, links.updated_at, links.owner_uuid
+from links inner join collections on links.head_uuid=portable_data_hash
+where head_uuid like '________________________________+%' and collections.uuid is not null and links.link_class != 'name' and links.link_class != 'permission'
+}
     data.each do |d|
-      c = Collection.generate_uuid
-      s = "insert into collections (uuid, portable_data_hash, owner_uuid, name, manifest_text, created_at, updated_at) values (#{ActiveRecord::Base.connection.quote c}, #{ActiveRecord::Base.connection.quote d['head_uuid']}, #{ActiveRecord::Base.connection.quote d['tail_uuid']}, #{ActiveRecord::Base.connection.quote d['name']}, #{ActiveRecord::Base.connection.quote d['manifest_text']}, #{ActiveRecord::Base.connection.quote created_at}, #{ActiveRecord::Base.connection.quote created_at})"
-      ActiveRecord::Base.connection.execute(s)
+      ActiveRecord::Base.connection.execute %{
+insert into links (uuid, head_uuid, tail_uuid, link_class, name, properties, created_at, updated_at, owner_uuid)
+values (#{ActiveRecord::Base.connection.quote Link.generate_uuid},
+#{ActiveRecord::Base.connection.quote d['coluuid']},
+#{ActiveRecord::Base.connection.quote d['tail_uuid']},
+#{ActiveRecord::Base.connection.quote d['link_class']},
+#{ActiveRecord::Base.connection.quote d['name']},
+#{ActiveRecord::Base.connection.quote d['properties']},
+#{ActiveRecord::Base.connection.quote d['created_at']},
+#{ActiveRecord::Base.connection.quote d['updated_at']},
+#{ActiveRecord::Base.connection.quote d['owner_uuid']})
+}
+      deletelinks << d['uuid']
     end
 
-    data = ActiveRecord::Base.connection.select_all("select head_uuid, tail_uuid, manifest_text from links inner join collections on head_uuid=collections.portable_data_hash where link_class='permission' and links.name='can_read'")
-    created_at = Time.now
+    # 4.2 migrate tail_uuid that look like collections
+    data = ActiveRecord::Base.connection.select_all %{
+select links.uuid, head_uuid, collections.uuid as coluuid, link_class, links.properties, links.name, links.created_at, links.updated_at, links.owner_uuid
+from links inner join collections on links.tail_uuid=portable_data_hash
+where tail_uuid like '________________________________+%' and collections.uuid is not null and links.link_class != 'name' and links.link_class != 'permission'
+}
     data.each do |d|
-      c = Collection.generate_uuid
-      s = "insert into collections (uuid, portable_data_hash, owner_uuid, name, manifest_text, created_at, updated_at) values (#{ActiveRecord::Base.connection.quote c}, #{ActiveRecord::Base.connection.quote d['head_uuid']}, #{ActiveRecord::Base.connection.quote d['tail_uuid']}, #{ActiveRecord::Base.connection.quote 'something something'}, #{ActiveRecord::Base.connection.quote d['manifest_text']}, #{ActiveRecord::Base.connection.quote created_at}, #{ActiveRecord::Base.connection.quote created_at})"
-      ActiveRecord::Base.connection.execute(s)
+      newuuid = Link.generate_uuid
+      ActiveRecord::Base.connection.execute %{
+insert into links (uuid, head_uuid, tail_uuid, link_class, name, properties, created_at, updated_at, owner_uuid)
+values (#{ActiveRecord::Base.connection.quote newuuid},
+#{ActiveRecord::Base.connection.quote d['head_uuid']},
+#{ActiveRecord::Base.connection.quote d['coluuid']},
+#{ActiveRecord::Base.connection.quote d['link_class']},
+#{ActiveRecord::Base.connection.quote d['name']},
+#{ActiveRecord::Base.connection.quote d['properties']},
+#{ActiveRecord::Base.connection.quote d['created_at']},
+#{ActiveRecord::Base.connection.quote d['updated_at']},
+#{ActiveRecord::Base.connection.quote d['owner_uuid']})
+}
+      deletelinks << d['uuid']
     end
 
+    # Step 5. Delete migrated links
+    deletelinks.each do |d|
+      ActiveRecord::Base.connection.execute("delete from links where uuid=#{ActiveRecord::Base.connection.quote d} or head_uuid=#{ActiveRecord::Base.connection.quote d}")
+    end
 
+    # Step 6. Delete old collection objects.
+    ActiveRecord::Base.connection.execute("delete from collections where uuid is null")
   end
 
   def down
     #remove_column :collections, :name
     #remove_column :collections, :description
     #remove_column :collections, :properties
+    #remove_column :collections, :expire_time
 
   end
 end

commit 53b8734add5e99bb2d6f3cf1b3e2a5b1f3664ef0
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Aug 12 11:33:34 2014 -0400

    Delete obsolete, undesirable HTML page templates.

diff --git a/services/api/app/views/api_client_authorizations/index.html.erb b/services/api/app/views/api_client_authorizations/index.html.erb
deleted file mode 100644
index f80ecef..0000000
--- a/services/api/app/views/api_client_authorizations/index.html.erb
+++ /dev/null
@@ -1,36 +0,0 @@
-<table style="width:100%">
-  <tr class="contain-align-left">
-    <th>
-      API client
-    </th><th>
-      Token
-    </th><th>
-      Created at
-    </th><th>
-      Used at
-    </th><th>
-      Expires
-    </th>
-  </tr>
-
-  <% @objects.each do |o| %>
-
-  <tr>
-    <td>
-      <%= o.api_client.name || o.api_client.url_prefix || o.api_client.uuid %>
-    </td><td>
-      <%= o.api_token %>
-    </td><td>
-      <%= o.created_at %>
-    </td><td>
-      <%= o.last_used_at %>
-      /
-      <%= o.last_used_by_ip_address %>
-    </td><td>
-      <%= o.expires_at %>
-    </td>
-  </tr>
-
-  <% end %>
-
-</table>
diff --git a/services/api/app/views/collections/index.html.erb b/services/api/app/views/collections/index.html.erb
deleted file mode 100644
index a73c74b..0000000
--- a/services/api/app/views/collections/index.html.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<table style="width:100%">
-  <tr class="contain-align-left">
-    <th>
-      redundancy
-    </th><th>
-      uuid
-    </th><th>
-      name
-    </th><th>
-      locator
-    </th><th>
-      last updated
-    </th>
-  </tr>
-
-  <% @objects.each do |o| %>
-
-  <tr class="collection-redundancy-status collection-redundancy-status-<%= o.redundancy_status %>" data-showhide-selector="tr#extra-info-<%= o.uuid %>" style="cursor:pointer">
-    <td>
-      <%= o.redundancy_status %> (<%= o.redundancy %>)
-    </td><td>
-      <%= o.uuid %>
-    </td><td>
-      <%= o.name %>
-    </td><td>
-      <%= o.locator %>
-    </td><td>
-      <%= distance_of_time_in_words(o.updated_at, Time.now, true) + ' ago' if o.updated_at %>
-    </td>
-  </tr>
-
-  <% if  %>
-  <tr id="extra-info-<%= o.uuid %>" data-showhide-default>
-    <td colspan="5">
-      <table>
-	<tr>
-	  <td>
-	    (file list not available)
-	  </td>
-	</tr>
-      </table>
-    </td>
-  </tr>
-
-  <% end %>
-  <% end %>
-</table>
diff --git a/services/api/app/views/nodes/index.html.erb b/services/api/app/views/nodes/index.html.erb
deleted file mode 100644
index bb346e9..0000000
--- a/services/api/app/views/nodes/index.html.erb
+++ /dev/null
@@ -1,66 +0,0 @@
-<table style="width:100%">
-  <tr class="contain-align-left">
-    <th>
-      status
-    </th><th>
-      sinfo
-    </th><th>
-      uuid
-    </th><th>
-      hostname
-    </th><th>
-      domain
-    </th><th>
-      ip address
-    </th><th>
-      created
-    </th><th>
-      startup delay
-    </th><th>
-      last ping
-    </th><th>
-      instance_id
-    </th>
-  </tr>
-
-  <% @objects.each do |o| %>
-
-  <tr class="node-status-<%= o.status %>">
-    <td class="node-status" data-showhide-selector="tr#extra-info-<%= o.uuid %>" style="cursor:pointer">
-      <%= o.status %>
-    </td><td class="node-slurm-state node-slurm-state-<%= @slurm_state[o.hostname] %>">
-      <%= @slurm_state[o.hostname] %>
-    </td><td>
-      <%= o.uuid %>
-    </td><td>
-      <%= o.hostname %>
-    </td><td>
-      <%= o.domain %>
-    </td><td>
-      <%= o.ip_address %>
-    </td><td>
-      <%= o.created_at %>
-    </td><td>
-      <%= distance_of_time_in_words(o.first_ping_at, o.created_at, true) if o.first_ping_at %>
-    </td><td>
-      <%= distance_of_time_in_words(o.last_ping_at, Time.now, true) + ' ago' if o.last_ping_at %>
-    </td><td>
-      <%= o.info[:ec2_instance_id] %>
-    </td>
-  </tr>
-
-  <% if  %>
-  <tr id="extra-info-<%= o.uuid %>" <%= 'data-showhide-default' unless o.info[:ec2_start_command] and !o.first_ping_at %>>
-    <td colspan="9">
-      <dl>
-      <% o.info.each do |k,v| %>
-      <dt><em><%= k %></em></dt>
-      <dd><%= v %></dd>
-      <% end %>
-      </dl>
-    </td>
-  </tr>
-
-  <% end %>
-  <% end %>
-</table>
diff --git a/services/api/app/views/pipeline_instances/index.html.erb b/services/api/app/views/pipeline_instances/index.html.erb
deleted file mode 100644
index cfadd26..0000000
--- a/services/api/app/views/pipeline_instances/index.html.erb
+++ /dev/null
@@ -1,63 +0,0 @@
-<table style="width:100%">
-  <tr class="contain-align-left">
-    <th>
-      success
-    </th><th>
-      active
-    </th><th>
-      % complete
-    </th><th>
-      uuid
-    </th><th>
-      pipeline template
-    </th><th>
-      name
-    </th><th>
-      last updated
-    </th>
-  </tr>
-
-  <% @objects.each do |o| %>
-
-  <% status = (o.state == 'Complete') ? 'success' : ((o.state == 'Failed') ? 'failure' : 'pending') %>
-
-  <tr class="pipeline-instance-status pipeline-instance-status-<%= status %>" data-showhide-selector="tr#extra-info-<%= o.uuid %>" style="cursor:pointer">
-    <td>
-      <%= status %>
-    </td><td>
-      <%= (o.state == 'RunningOnServer') ? 'yes' : '-' %>
-    </td><td>
-      <%= (o.progress_ratio * 1000).floor / 10 %>
-    </td><td>
-      <%= o.uuid %>
-    </td><td>
-      <%= o.pipeline_template_uuid %>
-    </td><td>
-      <%= o.name %>
-    </td><td>
-      <%= distance_of_time_in_words(o.updated_at, Time.now, true) + ' ago' if o.updated_at %>
-    </td>
-  </tr>
-
-  <% if  %>
-  <tr id="extra-info-<%= o.uuid %>" data-showhide-default>
-    <td colspan="7">
-      <table>
-	<% o.progress_table.each do |r| %>
-	<tr>
-	  <% r[2] = "#{(r[2]*100).floor}%" %>
-	  <% r[4] = r[4][0..5] rescue '' %>
-	  <% r.each do |c| %>
-	  <td>
-	    <%= (c.is_a? Time) ? distance_of_time_in_words(c, Time.now, true) + ' ago' : c %>
-	  </td>
-	  <% end %>
-	</tr>
-	<% end %>
-      </table>
-    </td>
-  </tr>
-
-  <% end %>
-  <% end %>
-</table>

commit c3b48996e1177336d97b44d30a3aaf41d8276142
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Aug 11 17:02:21 2014 -0400

    3036: Work on migration code for 'name' and 'can_read' links to distinct collection entries.

diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 50dd42c..41f25b0 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -28,39 +28,6 @@ class Collection < ArvadosModel
     end
   end
 
-  def assign_uuid
-    if not self.manifest_text
-      errors.add :manifest_text, 'not supplied'
-      return false
-    end
-    expect_uuid = Digest::MD5.hexdigest(self.manifest_text)
-    if self.uuid
-      self.uuid.gsub! /\+.*/, ''
-      if self.uuid != expect_uuid
-        errors.add :uuid, 'must match checksum of manifest_text'
-        return false
-      end
-    else
-      self.uuid = expect_uuid
-    end
-    self.uuid.gsub! /$/, '+' + self.manifest_text.length.to_s
-    true
-  end
-
-  # TODO (#3036/tom) replace above assign_uuid method with below assign_uuid and self.generate_uuid
-  # def assign_uuid
-  #   # Even admins cannot assign collection uuids.
-  #   self.uuid = self.class.generate_uuid
-  # end
-  # def self.generate_uuid
-  #   # The last 10 characters of a collection uuid are the last 10
-  #   # characters of the base-36 SHA256 digest of manifest_text.
-  #   [Server::Application.config.uuid_prefix,
-  #    self.uuid_prefix,
-  #    rand(2**256).to_s(36)[-5..-1] + Digest::SHA256.hexdigest(self.manifest_text).to_i(16).to_s(36)[-10..-1],
-  #   ].join '-'
-  # end
-
   def data_size
     inspect_manifest_text if @data_size.nil? or manifest_text_changed?
     @data_size
diff --git a/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb b/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
new file mode 100644
index 0000000..d82dcf9
--- /dev/null
+++ b/services/api/db/migrate/20140811184643_collection_use_regular_uuids.rb
@@ -0,0 +1,34 @@
+class CollectionUseRegularUuids < ActiveRecord::Migration
+  def up
+    add_column :collections, :name, :string
+    add_column :collections, :description, :string
+    add_column :collections, :properties, :string
+
+    ActiveRecord::Base.connection.execute("update collections set portable_data_hash=uuid, uuid=null;")
+
+    data = ActiveRecord::Base.connection.select_all("select head_uuid, tail_uuid, links.name, manifest_text from links inner join collections on head_uuid=collections.portable_data_hash where link_class='name'")
+    created_at = Time.now
+    data.each do |d|
+      c = Collection.generate_uuid
+      s = "insert into collections (uuid, portable_data_hash, owner_uuid, name, manifest_text, created_at, updated_at) values (#{ActiveRecord::Base.connection.quote c}, #{ActiveRecord::Base.connection.quote d['head_uuid']}, #{ActiveRecord::Base.connection.quote d['tail_uuid']}, #{ActiveRecord::Base.connection.quote d['name']}, #{ActiveRecord::Base.connection.quote d['manifest_text']}, #{ActiveRecord::Base.connection.quote created_at}, #{ActiveRecord::Base.connection.quote created_at})"
+      ActiveRecord::Base.connection.execute(s)
+    end
+
+    data = ActiveRecord::Base.connection.select_all("select head_uuid, tail_uuid, manifest_text from links inner join collections on head_uuid=collections.portable_data_hash where link_class='permission' and links.name='can_read'")
+    created_at = Time.now
+    data.each do |d|
+      c = Collection.generate_uuid
+      s = "insert into collections (uuid, portable_data_hash, owner_uuid, name, manifest_text, created_at, updated_at) values (#{ActiveRecord::Base.connection.quote c}, #{ActiveRecord::Base.connection.quote d['head_uuid']}, #{ActiveRecord::Base.connection.quote d['tail_uuid']}, #{ActiveRecord::Base.connection.quote 'something something'}, #{ActiveRecord::Base.connection.quote d['manifest_text']}, #{ActiveRecord::Base.connection.quote created_at}, #{ActiveRecord::Base.connection.quote created_at})"
+      ActiveRecord::Base.connection.execute(s)
+    end
+
+
+  end
+
+  def down
+    #remove_column :collections, :name
+    #remove_column :collections, :description
+    #remove_column :collections, :properties
+
+  end
+end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list