Added foreign keys to some oauth tables.
authorMatt Amos <zerebubuth@gmail.com>
Mon, 3 Aug 2009 13:58:10 +0000 (13:58 +0000)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 3 Aug 2009 13:58:10 +0000 (13:58 +0000)
db/migrate/040_add_foreign_keys_to_oauth_tables.rb [new file with mode: 0644]

diff --git a/db/migrate/040_add_foreign_keys_to_oauth_tables.rb b/db/migrate/040_add_foreign_keys_to_oauth_tables.rb
new file mode 100644 (file)
index 0000000..09de543
--- /dev/null
@@ -0,0 +1,15 @@
+require 'lib/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
+  end
+end