# Reshape Actions

Reshape migrations are composed of **actions** that define schema changes. Each migration file contains one or more actions that are applied together.

## Available Actions

Reshape supports many different actions for modifying your database schema:

- `create_table` - Create a new table
- `add_column` - Add a column to an existing table
- `alter_column` - Modify an existing column (type, default, nullable)
- `remove_column` - Remove a column from a table
- `create_index` - Create an index
- `remove_index` - Remove an index
- `add_foreign_key` - Add a foreign key constraint
- `remove_foreign_key` - Remove a foreign key constraint
- `create_enum` - Create an enum type
- `alter_enum` - Add or remove variants from an enum
- `remove_enum` - Remove an enum type
- `rename_table` - Rename a table
- `remove_table` - Remove a table
- `custom` - Run custom SQL

## Action Documentation

For detailed documentation on each action including all available options and examples:

```bash
specific docs /postgres/reshape/actions/create-table
specific docs /postgres/reshape/actions/add-column
specific docs /postgres/reshape/actions/alter-column
specific docs /postgres/reshape/actions/remove-column
specific docs /postgres/reshape/actions/create-enum
specific docs /postgres/reshape/actions/alter-enum
specific docs /postgres/reshape/actions/remove-enum
specific docs /postgres/reshape/actions/add-index
specific docs /postgres/reshape/actions/remove-index
specific docs /postgres/reshape/actions/add-foreign-key
specific docs /postgres/reshape/actions/remove-foreign-key
specific docs /postgres/reshape/actions/rename-table
specific docs /postgres/reshape/actions/remove-table
specific docs /postgres/reshape/actions/custom
```

## Example Migration

Here's an example migration that creates a table and adds an index:

```toml
# migrations/001_create_users.toml

[[actions]]
type = "create_table"
name = "users"
primary_key = ["id"]

  [[actions.columns]]
  name = "id"
  type = "INTEGER"
  generated = "ALWAYS AS IDENTITY"

  [[actions.columns]]
  name = "email"
  type = "TEXT"
  nullable = false

  [[actions.columns]]
  name = "created_at"
  type = "TIMESTAMPTZ"
  default = "NOW()"

[[actions]]
type = "add_index"
table = "users"
name = "users_email_idx"
columns = ["email"]
unique = true
```

---

Related topics:
- Run `specific docs /postgres/reshape` for general Reshape documentation
- Run `specific docs /postgres/reshape/actions/{ACTION}` for detailed action documentation
