]> git.openstreetmap.org Git - rails.git/blobdiff - db/migrate/045_create_user_blocks.rb
First version of blocking feature. Allows both time-based (for map protection) and...
[rails.git] / db / migrate / 045_create_user_blocks.rb
diff --git a/db/migrate/045_create_user_blocks.rb b/db/migrate/045_create_user_blocks.rb
new file mode 100644 (file)
index 0000000..7276ef1
--- /dev/null
@@ -0,0 +1,26 @@
+require 'lib/migrate'
+
+class CreateUserBlocks < ActiveRecord::Migration
+  def self.up
+    create_table :user_blocks do |t|
+      t.column :user_id,      :bigint,   :null => false
+      t.column :moderator_id, :bigint,   :null => false
+      t.column :reason,       :text,     :null => false
+      t.column :end_at,       :datetime, :null => false
+      t.column :needs_view,   :boolean,  :null => false, :default => false
+      t.column :revoker_id,   :bigint
+
+      t.timestamps
+    end
+
+    add_foreign_key :user_blocks, [:user_id], :users, [:id]
+    add_foreign_key :user_blocks, [:moderator_id], :users, [:id]
+    add_foreign_key :user_blocks, [:revoker_id], :users, [:id]
+
+    add_index :user_blocks, [:user_id]
+  end
+
+  def self.down
+    drop_table :user_blocks
+  end
+end