# 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, use the Reshape CLI directly:

```bash
# List all available actions
reshape docs /actions

# Get documentation for a specific action
reshape docs /actions/create-table
reshape docs /actions/add-column
reshape docs /actions/alter-column
reshape docs /actions/remove-column
reshape docs /actions/create-enum
reshape docs /actions/alter-enum
reshape docs /actions/remove-enum
reshape docs /actions/add-index
reshape docs /actions/remove-index
reshape docs /actions/add-foreign-key
reshape docs /actions/remove-foreign-key
reshape docs /actions/rename-table
reshape docs /actions/remove-table
reshape docs /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 `reshape docs /actions/{ACTION}` for detailed action documentation
