Skip to content

Commit

Permalink
adds parent_id to threadxs
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Jul 3, 2018
1 parent c79786a commit 7861cab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/threadx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Threadx < ActiveRecord::Base
has_many :media, :through => :media_threadxes

belongs_to :owner, :class_name => "User"
belongs_to :parent, class_name: 'Threadx', foreign_key: 'parent_id'

has_many :threadx_collaborators
has_many :collaborators, :through => :threadx_collaborators, :source => :user
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20180703105721_add_parent_id_to_threads.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddParentIdToThreads < ActiveRecord::Migration
def change
add_column :threadxes, :parent_id, :integer
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20140516094821) do
ActiveRecord::Schema.define(:version => 20180703105721) do

create_table "areas", :force => true do |t|
t.integer "x1"
Expand Down Expand Up @@ -98,6 +98,7 @@
t.integer "owner_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "parent_id"
end

create_table "users", :force => true do |t|
Expand Down

0 comments on commit 7861cab

Please sign in to comment.