]> git.openstreetmap.org Git - rails.git/blobdiff - db/migrate/042_add_foreign_keys_to_oauth_tables.rb
Merge remote-tracking branch 'upstream/pull/2794'
[rails.git] / db / migrate / 042_add_foreign_keys_to_oauth_tables.rb
index ee8048a36328f975371db0281e36af20a7ac1eb2..b302458c7cd97fd8d202caa8f22795ba1ce0baac 100644 (file)
@@ -1,15 +1,9 @@
-require 'migrate'
+require "migrate"
 
-class AddForeignKeysToOauthTables < ActiveRecord::Migration
-  def self.up
-    add_foreign_key :oauth_tokens, [:user_id], :users, [:id]
-    add_foreign_key :oauth_tokens, [:client_application_id], :client_applications, [:id]
-    add_foreign_key :client_applications, [:user_id], :users, [:id]
-  end
-
-  def self.down
-    remove_foreign_key :oauth_tokens, [:user_id], :users
-    remove_foreign_key :oauth_tokens, [:client_application_id], :client_applications
-    remove_foreign_key :client_applications, [:user_id], :users
+class AddForeignKeysToOauthTables < ActiveRecord::Migration[4.2]
+  def change
+    add_foreign_key :oauth_tokens, :users, :name => "oauth_tokens_user_id_fkey"
+    add_foreign_key :oauth_tokens, :client_applications, :name => "oauth_tokens_client_application_id_fkey"
+    add_foreign_key :client_applications, :users, :name => "client_applications_user_id_fkey"
   end
 end