[ARVADOS] created: cec0f7c11949b55b1c1589700641788ee3fd3ec4

git at public.curoverse.com git at public.curoverse.com
Tue Feb 9 08:58:43 EST 2016


        at  cec0f7c11949b55b1c1589700641788ee3fd3ec4 (commit)


commit cec0f7c11949b55b1c1589700641788ee3fd3ec4
Author: radhika <radhika at curoverse.com>
Date:   Tue Feb 9 08:57:50 2016 -0500

    8079: add uuid to api_client_authorizations

diff --git a/services/api/db/migrate/20160208210629_add_uuid_to_api_client_authorization.rb b/services/api/db/migrate/20160208210629_add_uuid_to_api_client_authorization.rb
new file mode 100644
index 0000000..73b5fdf
--- /dev/null
+++ b/services/api/db/migrate/20160208210629_add_uuid_to_api_client_authorization.rb
@@ -0,0 +1,26 @@
+require 'has_uuid'
+
+class AddUuidToApiClientAuthorization < ActiveRecord::Migration
+  extend HasUuid::ClassMethods
+
+  def up
+    add_column :api_client_authorizations, :uuid, :string
+    add_index :api_client_authorizations, :uuid, :unique => true
+    
+    prefix = Server::Application.config.uuid_prefix + '-' + 
+             Digest::MD5.hexdigest('ApiClientAuthorization'.to_s).to_i(16).to_s(36)[-5..-1] + '-'
+
+    update_sql <<-EOS
+update api_client_authorizations set uuid = (select concat('#{prefix}', substring(api_token, length(api_token)-4), array_to_string(ARRAY (SELECT substring('0123456789abcdefghijklmnopqrstuvwxyz' FROM (ceil(random()*36))::int FOR 1) FROM generate_series(1, 10)), '')));
+EOS
+
+    change_column_null :api_client_authorizations, :uuid, false
+  end
+
+  def down
+    if column_exists?(:api_client_authorizations, :uuid)
+      remove_index :api_client_authorizations, :uuid
+      remove_column :api_client_authorizations, :uuid
+    end
+  end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 0492c87..5e0c4d0 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -46,7 +46,8 @@ CREATE TABLE api_client_authorizations (
     default_owner_uuid character varying(255),
     scopes text DEFAULT '---
 - all
-'::text NOT NULL
+'::text NOT NULL,
+    uuid character varying(255) NOT NULL
 );
 
 
@@ -1530,6 +1531,13 @@ CREATE INDEX index_api_client_authorizations_on_user_id ON api_client_authorizat
 
 
 --
+-- Name: index_api_client_authorizations_on_uuid; Type: INDEX; Schema: public; Owner: -; Tablespace: 
+--
+
+CREATE UNIQUE INDEX index_api_client_authorizations_on_uuid ON api_client_authorizations USING btree (uuid);
+
+
+--
 -- Name: index_api_clients_on_created_at; Type: INDEX; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -2568,4 +2576,6 @@ INSERT INTO schema_migrations (version) VALUES ('20151202151426');
 
 INSERT INTO schema_migrations (version) VALUES ('20151215134304');
 
-INSERT INTO schema_migrations (version) VALUES ('20151229214707');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20151229214707');
+
+INSERT INTO schema_migrations (version) VALUES ('20160208210629');
\ No newline at end of file

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list