2022-07-22 05:34:38 +12:00
defmodule AshPostgres.Statement do
2023-09-23 08:14:25 +12:00
@moduledoc " Represents a custom statement to be run in generated migrations "
2023-04-27 14:23:43 +12:00
@fields [
2022-07-22 05:34:38 +12:00
:name ,
:up ,
:down ,
:code?
]
2023-04-27 14:23:43 +12:00
defstruct @fields
def fields , do : @fields
2022-07-22 05:34:38 +12:00
@schema [
name : [
type : :atom ,
required : true ,
doc : """
The name of the statement , must be unique within the resource
"""
] ,
code? : [
type : :boolean ,
default : false ,
doc : """
2023-09-23 08:14:25 +12:00
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
2022-07-22 05:34:38 +12:00
"""
] ,
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