Action

Action resource is a custom SQL operation that will be executed.

1action "<namespace>" "<name>" {
2  arguments {
3    ...
4  }
5  transaction = true
6
7  sql = "..."
8}
  • <namespace> - is a action namespace
  • <name> - is a migration reference name to use when connecting to other resources
  • arguments block (optional) - define arguments that can be used in sql as a variable, see Resource arguments for more details
  • sql - code to be executed
  • transaction (optional) - specifies whether to run action in a transaction (default: true)

Arguments

These attributes can be used with arguments:

  • sql

Example

1action "view" "refresh" {
2  arguments {
3    arg "name" {
4      description = "Materialized view to be refreshed"
5    }
6  }
7
8  sql = "REFRESH MATERIALIZED VIEW {{ .Args.name | quote_ident }}"
9}

Fakes

You can generate fake data with fake function template.

1action "seed" "all" {
2  sql = <<-SQL
3  INSERT INTO companies (name) VALUES ({{ fake "Company.Name" | quote }})
4  SQL
5}