### Create Postgres Enum Type Migration Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Use this to create a new Postgres enum type with a list of initial values. ```elixir defmodule MyApp.Repo.Migrations.CreateTypeMigration do use Ecto.Migration import EctoEnumMigration def change do create_type(:status, [:registered, :active, :inactive, :archived]) end end ``` -------------------------------- ### Create Enum Type in Custom Schema Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Specify a custom schema for the enum type when creating it. ```elixir create_type(:status, [:registered, :active, :inactive, :archived], schema: "custom_schema") ``` -------------------------------- ### create_type Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Creates a new Postgres Enum Type. By default, the type is created in the `public` schema. ```APIDOC ## create_type(name, values, opts \\ []) ### Description Create a Postgres Enum Type. ### Parameters #### Path Parameters - **name** (atom) - The name of the enum type to create. - **values** ([atom]) - A list of atom values for the enum type. - **opts** (Keyword.t()) - Optional keyword list for configuration. Supports `schema`. ### Request Example ```elixir create_type(:status, [:registered, :active, :inactive, :archived]) create_type(:status, [:registered, :active, :inactive, :archived], schema: "custom_schema") ``` ``` -------------------------------- ### create_type/3 Source: https://hexdocs.pm/ecto_enum_migration/index.html Creates a new Postgres Enum Type with the specified name and values. The type is created in the `public` schema by default. ```APIDOC ## create_type(name, values, opts \\ []) ### Description Create a Postgres Enum Type. ### Parameters - **name** (atom) - The name of the enum type to create. - **values** ([atom()]) - A list of atom values for the enum type. - **opts** (Keyword.t()) - Optional keyword list for configuration. - **schema** (String.t()) - The schema where the type should be created. Defaults to `"public"`. ### Returns - `:ok` | `no_return()` ### Examples ```elixir defmodule MyApp.Repo.Migrations.CreateTypeMigration do use Ecto.Migration import EctoEnumMigration def change do create_type(:status, [:registered, :active, :inactive, :archived]) end end ``` ```elixir # Specify schema create_type(:status, [:registered, :active, :inactive, :archived], schema: "custom_schema") ``` ``` -------------------------------- ### Create Postgres Enum Type Source: https://hexdocs.pm/ecto_enum_migration/index.html Use `create_type/3` to define a new PostgreSQL ENUM type with a given name and a list of values. The type is created in the `public` schema by default, but a different schema can be specified using the `schema` option. ```elixir defmodule MyApp.Repo.Migrations.CreateTypeMigration do use Ecto.Migration import EctoEnumMigration def change do create_type(:status, [:registered, :active, :inactive, :archived]) end end ``` ```elixir create_type(:status, [:registered, :active, :inactive, :archived], schema: "custom_schema") ``` -------------------------------- ### drop_type/2 Source: https://hexdocs.pm/ecto_enum_migration/index.html Drops a Postgres Enum Type. This command is not reversible and requires a corresponding `down/0` step in the migration. ```APIDOC ## drop_type(name, opts \\ []) ### Description Drop a Postgres Enum Type. ### Parameters - **name** (atom) - The name of the enum type to drop. - **opts** (Keyword.t()) - Optional keyword list for configuration. - **schema** (String.t()) - The schema where the type is located. Defaults to `"public"`. ### Returns - `:ok` | `no_return()` ### Examples ```elixir defmodule MyApp.Repo.Migrations.DropTypeMigration do use Ecto.Migration import EctoEnumMigration def up do drop_type(:status) end def down do create_type(:status, [:registered, :active, :inactive, :archived]) end end ``` ```elixir # Specify schema drop_type(:status, schema: "custom_schema") ``` ``` -------------------------------- ### Add Value to Enum Type Before Specific Value Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Insert a new value into an enum type at a specific position by using the `:before` option. ```elixir add_value_to_type(:status, :finished, before: :started) ``` -------------------------------- ### drop_type Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Drops a Postgres Enum Type. This command is not reversible, so ensure a `down/0` step is included in the migration. By default, the type is dropped from the `public` schema. ```APIDOC ## drop_type(name, opts \\ []) ### Description Drop a Postgres Enum Type. ### Parameters #### Path Parameters - **name** (atom) - The name of the enum type to drop. - **opts** (Keyword.t()) - Optional keyword list for configuration. Supports `schema`. ### Request Example ```elixir drop_type(:status) drop_type(:status, schema: "custom_schema") ``` ``` -------------------------------- ### Drop Postgres Enum Type Migration Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Use this to drop an existing Postgres enum type. This operation is not reversible, so ensure a `down/0` step is included to recreate the type. ```elixir defmodule MyApp.Repo.Migrations.DropTypeMigration do use Ecto.Migration import EctoEnumMigration def up do drop_type(:status) end def down do create_type(:status, [:registered, :active, :inactive, :archived]) end end ``` -------------------------------- ### Conditionally Add Value to Enum Type Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Use the `:if_not_exists` option to add a value only if it does not already exist in the enum type. ```elixir add_value_to_type(:status, :finished, if_not_exists: true) ``` -------------------------------- ### Drop Enum Type in Custom Schema Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Specify a custom schema for the enum type when dropping it. ```elixir drop_type(:status, schema: "custom_schema") ``` -------------------------------- ### Add Value to Enum Type After Specific Value Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Insert a new value into an enum type at a specific position by using the `:after` option. ```elixir add_value_to_type(:status, :finished, after: :started) ``` -------------------------------- ### Rename Postgres Enum Type Migration Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Use this to rename an existing Postgres enum type. ```elixir defmodule MyApp.Repo.Migrations.RenameTypeMigration do use Ecto.Migration import EctoEnumMigration def change do rename_type(:status, :status_renamed) end end ``` -------------------------------- ### Rename Enum Type in Custom Schema Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Specify a custom schema for the enum type when renaming it. ```elixir rename_type(:status, :status_renamed, schema: "custom_schema") ``` -------------------------------- ### Add Value to Enum Type in Custom Schema Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Specify a custom schema for the enum type when adding a new value. ```elixir add_value_to_type(:status, :finished, schema: "custom_schema") ``` -------------------------------- ### Drop Postgres Enum Type Source: https://hexdocs.pm/ecto_enum_migration/index.html Use `drop_type/2` to remove a PostgreSQL ENUM type. This operation is irreversible, so ensure a corresponding `create_type/2` is present in the `down/0` function of the migration. The schema can be specified using the `schema` option. ```elixir defmodule MyApp.Repo.Migrations.DropTypeMigration do use Ecto.Migration import EctoEnumMigration def up do drop_type(:status) end def down do create_type(:status, [:registered, :active, :inactive, :archived]) end end ``` ```elixir drop_type(:status, schema: "custom_schema") ``` -------------------------------- ### Add Value to Postgres Enum Type Source: https://hexdocs.pm/ecto_enum_migration/index.html Use `add_value_to_type/3` to add a new value to an existing PostgreSQL ENUM type. Note that this operation is not reversible. For PostgreSQL versions 11 and below, DDL transactions are not supported, so `@disable_ddl_transaction true` must be set in the migration. ```elixir defmodule MyApp.Repo.Migrations.AddValueToTypeMigration do use Ecto.Migration import EctoEnumMigration # Only needed if running on Postgres <= 11 @disable_ddl_transaction true def up do add_value_to_type(:status, :finished) end def down do end end ``` ```elixir add_value_to_type(:status, :finished, schema: "custom_schema") ``` ```elixir add_value_to_type(:status, :finished, before: :started) ``` ```elixir add_value_to_type(:status, :finished, after: :started) ``` ```elixir add_value_to_type(:status, :finished, if_not_exists: true) ``` -------------------------------- ### Rename Postgres Enum Type Source: https://hexdocs.pm/ecto_enum_migration/index.html Use `rename_type/3` to change the name of an existing PostgreSQL ENUM type. The schema can be specified using the `schema` option. ```elixir defmodule MyApp.Repo.Migrations.RenameTypeMigration do use Ecto.Migration import EctoEnumMigration def change do rename_type(:status, :status_renamed) end end ``` ```elixir rename_type(:status, :status_renamed, schema: "custom_schema") ``` -------------------------------- ### Rename Value in Enum Type in Custom Schema Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Specify a custom schema for the enum type when renaming a value. ```elixir rename_value(:status, :finished, :done, schema: "custom_schema") ``` -------------------------------- ### add_value_to_type Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Adds a new value to an existing Postgres Enum Type. This operation is not reversible. For Postgres versions <= 11, DDL transactions are not supported, so `@disable_ddl_transaction true` must be set in the migration. ```APIDOC ## add_value_to_type(name, value, opts \\ []) ### Description Add a value to a existing Postgres type. ### Parameters #### Path Parameters - **name** (atom) - The name of the enum type. - **value** (atom) - The new value to add to the enum type. - **opts** (Keyword.t()) - Optional keyword list for configuration. Supports `schema`, `before`, `after`, and `if_not_exists`. ### Request Example ```elixir add_value_to_type(:status, :finished) add_value_to_type(:status, :finished, schema: "custom_schema") add_value_to_type(:status, :finished, before: :started) add_value_to_type(:status, :finished, after: :started) add_value_to_type(:status, :finished, if_not_exists: true) ``` ``` -------------------------------- ### Add Value to Postgres Enum Type Migration Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Use this to add a new value to an existing Postgres enum type. Note that this operation is not reversible. For Postgres versions 11 and below, this operation cannot be used inside a transaction block, requiring `@disable_ddl_transaction true`. ```elixir defmodule MyApp.Repo.Migrations.AddValueToTypeMigration do use Ecto.Migration import EctoEnumMigration # Only needed if running on Postgres <= 11 @disable_ddl_transaction true def up do add_value_to_type(:status, :finished) end def down do end end ``` -------------------------------- ### Rename Value in Postgres Enum Type Migration Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Use this to rename a specific value within a Postgres enum type. This is only compatible with Postgres version 10 and newer. ```elixir defmodule MyApp.Repo.Migrations.RenameTypeMigration do use Ecto.Migration import EctoEnumMigration def change do rename_value(:status, :finished, :done) end end ``` -------------------------------- ### rename_type/3 Source: https://hexdocs.pm/ecto_enum_migration/index.html Renames a Postgres Enum Type. The type is renamed in the `public` schema by default. ```APIDOC ## rename_type(before_name, after_name, opts \\ []) ### Description Rename a Postgres Enum Type. ### Parameters - **before_name** (atom) - The current name of the enum type. - **after_name** (atom) - The new name for the enum type. - **opts** (Keyword.t()) - Optional keyword list for configuration. - **schema** (String.t()) - The schema where the type is located. Defaults to `"public"`. ### Returns - `:ok` | `no_return()` ### Examples ```elixir defmodule MyApp.Repo.Migrations.RenameTypeMigration do use Ecto.Migration import EctoEnumMigration def change do rename_type(:status, :status_renamed) end end ``` ```elixir # Specify schema rename_type(:status, :status_renamed, schema: "custom_schema") ``` ``` -------------------------------- ### rename_type Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Renames a Postgres Enum Type. By default, the type is assumed to be in the `public` schema. ```APIDOC ## rename_type(before_name, after_name, opts \\ []) ### Description Rename a Postgres Type. ### Parameters #### Path Parameters - **before_name** (atom) - The current name of the enum type. - **after_name** (atom) - The new name for the enum type. - **opts** (Keyword.t()) - Optional keyword list for configuration. Supports `schema`. ### Request Example ```elixir rename_type(:status, :status_renamed) rename_type(:status, :status_renamed, schema: "custom_schema") ``` ``` -------------------------------- ### rename_value Source: https://hexdocs.pm/ecto_enum_migration/EctoEnumMigration.html Renames a value within a Postgres Enum Type. This function is only compatible with Postgres version 10 and later. By default, the type is assumed to be in the `public` schema. ```APIDOC ## rename_value(type_name, before_value, after_value, opts \\ []) ### Description Rename a value of a Postgres Type. ### Parameters #### Path Parameters - **type_name** (atom) - The name of the enum type. - **before_value** (atom) - The current name of the value. - **after_value** (atom) - The new name for the value. - **opts** (Keyword.t()) - Optional keyword list for configuration. Supports `schema`. ### Request Example ```elixir rename_value(:status, :finished, :done) rename_value(:status, :finished, :done, schema: "custom_schema") ``` ``` -------------------------------- ### Rename Value in Postgres Enum Type Source: https://hexdocs.pm/ecto_enum_migration/index.html Use `rename_value/4` to rename a specific value within a PostgreSQL ENUM type. This functionality is only compatible with PostgreSQL version 10 and later. The schema can be specified using the `schema` option. ```elixir defmodule MyApp.Repo.Migrations.RenameTypeMigration do use Ecto.Migration import EctoEnumMigration def change do rename_value(:status, :finished, :done) end end ``` ```elixir rename_value(:status, :finished, :done, schema: "custom_schema") ``` -------------------------------- ### rename_value/4 Source: https://hexdocs.pm/ecto_enum_migration/index.html Renames a value within a Postgres Enum Type. This is only compatible with Postgres version 10 and above. The type is renamed in the `public` schema by default. ```APIDOC ## rename_value(type_name, before_value, after_value, opts \\ []) ### Description Rename a value of a Postgres Type. ### Parameters - **type_name** (atom) - The name of the enum type. - **before_value** (atom) - The current value to be renamed. - **after_value** (atom) - The new name for the value. - **opts** (Keyword.t()) - Optional keyword list for configuration. - **schema** (String.t()) - The schema where the type is located. Defaults to `"public"`. ### Returns - `:ok` | `no_return()` ### Examples ```elixir defmodule MyApp.Repo.Migrations.RenameTypeMigration do use Ecto.Migration import EctoEnumMigration def change do rename_value(:status, :finished, :done) end end ``` ```elixir # Specify schema rename_value(:status, :finished, :done, schema: "custom_schema") ``` ``` -------------------------------- ### add_value_to_type/3 Source: https://hexdocs.pm/ecto_enum_migration/index.html Adds a value to an existing Postgres Enum Type. This operation is not reversible. For Postgres versions 11 and below, this operation cannot be used inside a transaction block, requiring `@disable_ddl_transaction true`. ```APIDOC ## add_value_to_type(name, value, opts \\ []) ### Description Add a value to a existing Postgres type. ### Parameters - **name** (atom) - The name of the enum type. - **value** (atom) - The value to add to the enum type. - **opts** (Keyword.t()) - Optional keyword list for configuration. - **schema** (String.t()) - The schema where the type is located. Defaults to `"public"`. - **before** (atom()) - Specifies the value before which the new value should be inserted. - **after** (atom()) - Specifies the value after which the new value should be inserted. - **if_not_exists** (boolean()) - If true, the value will only be added if it does not already exist. ### Returns - `:ok` | `no_return()` ### Examples ```elixir defmodule MyApp.Repo.Migrations.AddValueToTypeMigration do use Ecto.Migration import EctoEnumMigration @disable_ddl_transaction true def up do add_value_to_type(:status, :finished) end def down do end end ``` ```elixir # Specify schema add_value_to_type(:status, :finished, schema: "custom_schema") ``` ```elixir # Specify insertion order add_value_to_type(:status, :finished, before: :started) add_value_to_type(:status, :finished, after: :started) ``` ```elixir # Add only if not exists add_value_to_type(:status, :finished, if_not_exists: true) ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.