```ruby
class CreateComments < ActiveRecord::Migration
  def change
    create_table :comments do |t|
      t.text :comment

      t.belongs_to :user
      t.belongs_to :query

      t.timestamps
    end
  end
end
```

Change comments migration file to have commentable_id, commentable_type, and ancestry
user
```ruby
class CreateComments < ActiveRecord::Migration
  def change
    create_table :comments do |t|
      t.text :comment

      t.integer :commentable_id
      t.string :commentable_type
      t.string :ancestry

      t.belongs_to :user
      t.belongs_to :query

      t.timestamps
    end
  end
end
```
assistant