-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathstatement.ex
45 lines (40 loc) · 979 Bytes
/
statement.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
defmodule AshPostgres.Statement do
@moduledoc "Represents a custom statement to be run in generated migrations"
@fields [
:name,
:up,
:down,
:code?
]
defstruct @fields
def fields, do: @fields
@schema [
name: [
type: :atom,
required: true,
doc: """
The name of the statement, must be unique within the resource
"""
],
code?: [
type: :boolean,
default: false,
doc: """
By default, we place the strings inside of ecto migration's `execute/1` function and assume they are sql. Use this option if you want to provide custom elixir code to be placed directly in the migrations
"""
],
up: [
type: :string,
doc: """
How to create the structure of the statement
""",
required: true
],
down: [
type: :string,
doc: "How to tear down the structure of the statement",
required: true
]
]
def schema, do: @schema
end