-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
migrations.ex
49 lines (38 loc) · 1.37 KB
/
migrations.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
defmodule Ecto.Adapter.Migrations do
@moduledoc """
Specifies the adapter migrations API.
"""
use Behaviour
alias Ecto.Migration.Table
alias Ecto.Migration.Index
alias Ecto.Migration.Reference
@typedoc "All migration commands"
@type command ::
raw :: String.t |
{:create, Table.t, [table_subcommand]} |
{:alter, Table.t, [table_subcommand]} |
{:drop, Table.t} |
{:create, Index.t} |
{:drop, Index.t}
@type table_subcommand ::
{:add, field :: atom, type :: Ecto.Type.t | Reference.t, Keyword.t} |
{:modify, field :: atom, type :: Ecto.Type.t | Reference.t, Keyword.t} |
{:remove, field :: atom}
@type ddl_object :: Table.t | Index.t
@doc """
Executes migration commands.
## Options
* `:timeout` - The time in milliseconds to wait for the call to finish,
`:infinity` will wait indefinitely (default: 5000);
* `:log` - When false, does not log begin/commit/rollback queries
"""
defcallback execute_ddl(Ecto.Repo.t, command, Keyword.t) :: :ok | no_return
@doc """
Checks if ddl value, like a table or index, exists.
## Options
* `:timeout` - The time in milliseconds to wait for the call to finish,
`:infinity` will wait indefinitely (default: 5000);
* `:log` - When false, does not log begin/commit/rollback queries
"""
defcallback ddl_exists?(Ecto.Repo.t, ddl_object, Keyword.t) :: boolean
end