[ARVADOS] updated: 49ca83c5f0d6f17ca6fac5f6082fdcb4f0cec036
git at public.curoverse.com
git at public.curoverse.com
Mon Aug 18 08:44:25 EDT 2014
Summary of changes:
.../20140817035914_add_unique_name_constraints.rb | 20 ++++++++++-
services/api/db/structure.sql | 39 +++++++++++++++++++++-
2 files changed, 57 insertions(+), 2 deletions(-)
via 49ca83c5f0d6f17ca6fac5f6082fdcb4f0cec036 (commit)
from 20378927432d882bed657806b6c7e026d3e2b986 (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 49ca83c5f0d6f17ca6fac5f6082fdcb4f0cec036
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Aug 18 08:44:20 2014 -0400
3036: Migration will rename rows if necessary to ensure (owner_uuid, name) uniqueness
diff --git a/services/api/db/migrate/20140817035914_add_unique_name_constraints.rb b/services/api/db/migrate/20140817035914_add_unique_name_constraints.rb
index 749b455..f84c635 100644
--- a/services/api/db/migrate/20140817035914_add_unique_name_constraints.rb
+++ b/services/api/db/migrate/20140817035914_add_unique_name_constraints.rb
@@ -1,6 +1,24 @@
class AddUniqueNameConstraints < ActiveRecord::Migration
def change
- # Need some code to ensure uniqueness before adding constraints.
+ # Ensure uniqueness before adding constraints.
+ ["collections", "pipeline_templates", "pipeline_instances", "jobs", "groups"].each do |table|
+ rows = ActiveRecord::Base.connection.select_all %{
+select uuid, owner_uuid, name from #{table} order by owner_uuid, name
+}
+ prev = {}
+ n = 1
+ rows.each do |r|
+ if r["owner_uuid"] == prev["owner_uuid"] and !r["name"].nil? and r["name"] == prev["name"]
+ n += 1
+ ActiveRecord::Base.connection.execute %{
+update #{table} set name='#{r["name"]} #{n}' where uuid='#{r["uuid"]}'
+}
+ else
+ n = 1
+ end
+ prev = r
+ end
+ end
add_index(:collections, [:owner_uuid, :name], unique: true,
name: 'collection_owner_uuid_name_unique')
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 4b32d38..a71bf8a 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -1273,6 +1273,20 @@ ALTER TABLE ONLY virtual_machines
--
+-- Name: collection_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX collection_owner_uuid_name_unique ON collections USING btree (owner_uuid, name);
+
+
+--
+-- Name: groups_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX groups_owner_uuid_name_unique ON groups USING btree (owner_uuid, name);
+
+
+--
-- Name: index_api_client_authorizations_on_api_client_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1784,6 +1798,13 @@ CREATE UNIQUE INDEX index_virtual_machines_on_uuid ON virtual_machines USING btr
--
+-- Name: jobs_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX jobs_owner_uuid_name_unique ON jobs USING btree (owner_uuid, name);
+
+
+--
-- Name: links_tail_name_unique_if_link_class_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1791,6 +1812,20 @@ CREATE UNIQUE INDEX links_tail_name_unique_if_link_class_name ON links USING btr
--
+-- Name: pipeline_instance_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX pipeline_instance_owner_uuid_name_unique ON pipeline_instances USING btree (owner_uuid, name);
+
+
+--
+-- Name: pipeline_template_owner_uuid_name_unique; Type: INDEX; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE UNIQUE INDEX pipeline_template_owner_uuid_name_unique ON pipeline_templates USING btree (owner_uuid, name);
+
+
+--
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1985,4 +2020,6 @@ INSERT INTO schema_migrations (version) VALUES ('20140714184006');
INSERT INTO schema_migrations (version) VALUES ('20140811184643');
-INSERT INTO schema_migrations (version) VALUES ('20140815171049');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20140815171049');
+
+INSERT INTO schema_migrations (version) VALUES ('20140817035914');
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list