api: Shorten name of authorized_keys index.
authorBrett Smith <brett@curoverse.com>
Mon, 28 Apr 2014 15:03:22 +0000 (11:03 -0400)
committerBrett Smith <brett@curoverse.com>
Mon, 28 Apr 2014 15:03:22 +0000 (11:03 -0400)
I had trouble running the new TimestampsNotNull migration, because I
ran into the index name limit described in the migration comments.
Running this migration first worked around the problem for me, and I
hope it saves others from tripping over it too.

services/api/db/migrate/20140421151939_rename_auth_keys_user_index.rb [new file with mode: 0644]
services/api/db/schema.rb

diff --git a/services/api/db/migrate/20140421151939_rename_auth_keys_user_index.rb b/services/api/db/migrate/20140421151939_rename_auth_keys_user_index.rb
new file mode 100644 (file)
index 0000000..2b057f0
--- /dev/null
@@ -0,0 +1,11 @@
+class RenameAuthKeysUserIndex < ActiveRecord::Migration
+  # Rails' default name for this index is so long, Rails can't modify
+  # the index later, because the autogenerated temporary name exceeds
+  # PostgreSQL's 64-character limit.  This migration gives the index
+  # an explicit name to work around that issue.
+  def change
+    rename_index("authorized_keys",
+                 "index_authorized_keys_on_authorized_user_uuid_and_expires_at",
+                 "index_authkeys_on_user_and_expires_at")
+  end
+end
index af751fa365f1125cb5404ed01a97c80fa09436ad..988cb872eebe4ae753d1e2fc19a5b7015ed54d20 100644 (file)
@@ -64,7 +64,7 @@ ActiveRecord::Schema.define(:version => 20140422011506) do
     t.datetime "updated_at",              :null => false
   end
 
-  add_index "authorized_keys", ["authorized_user_uuid", "expires_at"], :name => "index_authorized_keys_on_authorized_user_uuid_and_expires_at"
+  add_index "authorized_keys", ["authorized_user_uuid", "expires_at"], :name => "index_authkeys_on_user_and_expires_at"
   add_index "authorized_keys", ["uuid"], :name => "index_authorized_keys_on_uuid", :unique => true
 
   create_table "collections", :force => true do |t|