Skip to content

Commit

Permalink
References #41 - Added the manual ordering field for upcoming drag-an…
Browse files Browse the repository at this point in the history
…d-drop support.
  • Loading branch information
jefflunt committed Jun 6, 2012
1 parent 819e4fd commit 38e0e9d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions db/migrate/20120606021309_add_manual_order_field_to_thoughts.rb
@@ -0,0 +1,18 @@
class AddManualOrderFieldToThoughts < ActiveRecord::Migration
def up
add_column :thoughts, :manual_order, :integer

Thought.reset_column_information

ThoughtWall.all.each_with_index do |tw|
thoughts = tw.thoughts.except(:order).order("id ASC")
thoughts.each_with_index do |t, index|
t.update_attribute(:manual_order, index)
end
end
end

def down
remove_column :thoughts, :manual_order
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120604114724) do
ActiveRecord::Schema.define(:version => 20120606021309) do

create_table "stats", :force => true do |t|
t.string "group"
Expand Down Expand Up @@ -44,6 +44,7 @@
t.datetime "updated_at", :null => false
t.integer "up_votes", :default => 0
t.integer "down_votes", :default => 0
t.integer "manual_order"
end

end

0 comments on commit 38e0e9d

Please sign in to comment.