create_enum in rails 7

# Step 1: Open the migration file to create the Enum type
class CreateEnumForModelName < ActiveRecord::Migration[7.0]
  def change
    # Step 2: Create an Enum type with the desired attribute
    create_enum :status, %w[pending approved rejected], default: 'pending'

    # Step 3: Add the Enum attribute to the model table
    add_column :model_name, :status, :status, null: false

    # Step 4: Add an index on the Enum attribute for better performance
    add_index :model_name, :status
  end
end

# Step 5: Create a model file and define the Enum attribute
class ModelName < ApplicationRecord
  enum status: %i[pending approved rejected]
end