Method: ActiveRecord::Migration#create_enum

Defined in:
lib/pg_trunk/operations/enums/create_enum.rb

#create_enum(name, **options) {|e| ... } ⇒ void

This method returns an undefined value.

Create an enumerated type by qualified name

create_enum "finances.currency" do |e|
  e.values "BTC", "EUR", "GBP", "USD"
  e.value "JPY" # the alternative way to add a value to the tail
  e.comment <<~COMMENT
    The list of values for supported currencies.
  COMMENT
end

It is always reversible.

Parameters:

  • name (#to_s)

    (nil) The qualified name of the type

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :values (Array<#to_s>) — default: []

    The list of values

  • :comment (#to_s) — default: nil

    The comment describing the constraint

Yields:

  • (e)

    the block with the type's definition

Yield Parameters:

  • Object

    receiver of methods specifying the type



22
# File 'lib/pg_trunk/operations/enums/create_enum.rb', line 22

def create_enum(name, **options, &block); end