Add foreign key constraints for users.
authorTom Hughes <tom@compton.nu>
Thu, 7 May 2009 17:54:52 +0000 (17:54 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 7 May 2009 17:54:52 +0000 (17:54 +0000)
db/migrate/029_add_user_foreign_keys.rb [new file with mode: 0644]

diff --git a/db/migrate/029_add_user_foreign_keys.rb b/db/migrate/029_add_user_foreign_keys.rb
new file mode 100644 (file)
index 0000000..d11f81c
--- /dev/null
@@ -0,0 +1,18 @@
+class AddUserForeignKeys < ActiveRecord::Migration
+  def self.up
+    add_foreign_key :changesets, [:user_id], :users, [:id]
+    add_foreign_key :diary_comments, [:user_id], :users, [:id]
+    add_foreign_key :diary_entries, [:user_id], :users, [:id]
+    add_foreign_key :friends, [:user_id], :users, [:id]
+    add_foreign_key :friends, [:friend_user_id], :users, [:id]
+    add_foreign_key :gpx_files, [:user_id], :users, [:id]
+    add_foreign_key :messages, [:from_user_id], :users, [:id]
+    add_foreign_key :messages, [:to_user_id], :users, [:id]
+    add_foreign_key :user_preferences, [:user_id], :users, [:id]
+    add_foreign_key :user_tokens, [:user_id], :users, [:id]
+  end
+
+  def self.down
+    raise IrreversibleMigration.new
+  end
+end