Packages
ecto_sql
3.5.0-rc.0
3.14.0
3.13.5
3.13.4
3.13.3
3.13.2
3.13.1
3.13.0
3.12.1
3.12.0
3.11.3
3.11.2
3.11.1
3.11.0
3.10.2
3.10.1
3.10.0
3.9.2
3.9.1
3.9.0
3.8.3
3.8.2
3.8.1
3.8.0
3.7.2
3.7.1
3.7.0
3.6.2
3.6.1
3.6.0
3.5.4
3.5.3
3.5.2
3.5.1
3.5.0
3.5.0-rc.1
3.5.0-rc.0
3.4.5
3.4.4
3.4.3
3.4.2
3.4.1
3.4.0
3.3.4
3.3.3
3.3.2
3.3.1
3.3.0
3.2.2
3.2.1
3.2.0
3.1.6
3.1.5
3.1.4
3.1.3
3.1.2
3.1.1
3.1.0
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-rc.1
3.0.0-rc.0
SQL-based adapters for Ecto and database migrations
Current section
Files
Jump to
Current section
Files
lib/ecto/adapter/migration.ex
defmodule Ecto.Adapter.Migration do
@moduledoc """
Specifies the adapter migrations API.
"""
alias Ecto.Migration.Table
alias Ecto.Migration.Index
alias Ecto.Migration.Reference
@type adapter_meta :: Ecto.Adapter.adapter_meta()
@typedoc "All migration commands"
@type command ::
raw ::
String.t()
| {:create, Table.t(), [table_subcommand]}
| {:create_if_not_exists, Table.t(), [table_subcommand]}
| {:alter, Table.t(), [table_subcommand]}
| {:drop, Table.t()}
| {:drop_if_exists, Table.t()}
| {:create, Index.t()}
| {:create_if_not_exists, Index.t()}
| {:drop, Index.t()}
| {:drop_if_exists, Index.t()}
@typedoc "All commands allowed within the block passed to `table/2`"
@type table_subcommand ::
{:add, field :: atom, type :: Ecto.Type.t() | Reference.t() | binary(), Keyword.t()}
| {:add_if_not_exists, field :: atom, type :: Ecto.Type.t() | Reference.t() | binary(), Keyword.t()}
| {:modify, field :: atom, type :: Ecto.Type.t() | Reference.t() | binary(), Keyword.t()}
| {:remove, field :: atom, type :: Ecto.Type.t() | Reference.t() | binary(), Keyword.t()}
| {:remove, field :: atom}
| {:remove_if_exists, type :: Ecto.Type.t() | Reference.t() | binary()}
@typedoc """
A struct that represents a table or index in a database schema.
These database objects can be modified through the use of a Data
Definition Language, hence the name DDL object.
"""
@type ddl_object :: Table.t() | Index.t()
@doc """
Checks if the adapter supports ddl transaction.
"""
@callback supports_ddl_transaction? :: boolean
@doc """
Executes migration commands.
"""
@callback execute_ddl(adapter_meta, command, options :: Keyword.t()) ::
{:ok, [{Logger.level, Logger.message, Logger.metadata}]}
@doc """
Locks the migrations table and emits the locked versions for callback execution.
It returns the result of calling the given function with a list of versions.
"""
@callback lock_for_migrations(adapter_meta, Ecto.Query.t(), options :: Keyword.t(), fun) ::
result
when fun: (Ecto.Query.t() -> result), result: var
end