rails migration polymorphic references

class CreateComments < ActiveRecord::Migration[6.0]
  def change
    create_table :comments do |t|
      t.text :body
      t.references :commentable, polymorphic: true

      t.timestamps
    end
  end
end
  1. Create a new migration file using the rails generate migration command.
  2. In the migration file, define a new table for comments with a text column for the body of the comment.
  3. Add a references column named commentable to the comments table, making it polymorphic using polymorphic: true.
  4. Include timestamps for tracking creation and update times in the comments table.
  5. Run the migration using the rails db:migrate command to apply the changes to the database. ```