# `PhoenixKit.Migrations.Postgres.V18`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/phoenix_kit/migrations/postgres/v18.ex#L1)

PhoenixKit V18 Migration: User Custom Fields

Adds JSONB `custom_fields` column to phoenix_kit_users table for storing
arbitrary custom data per user (phone numbers, addresses, preferences, metadata, etc.)

## Changes

### Users Table (phoenix_kit_users)
- Adds `custom_fields` JSONB column (nullable, default: %{})
- Stores flexible key-value data without schema changes
- Leverages PostgreSQL's native JSONB type for performance

## Features

- **Flexible Schema**: Add any custom user data without migrations
- **PostgreSQL JSONB**: Native JSON storage with indexing support
- **Default Empty Map**: New users start with `%{}`
- **Queryable**: Use PostgreSQL JSONB operators for filtering

## Usage Examples

```elixir
# Store custom fields
Auth.register_user(%{
  email: "user@example.com",
  custom_fields: %{
    "phone" => "555-1234",
    "department" => "Engineering"
  }
})

# Update fields
Auth.update_user_custom_fields(user, %{"linkedin" => "https://..."})

# Access directly
user.custom_fields["phone"]
```

# `down`

Rollback the V18 migration.

# `up`

Run the V18 migration to add custom_fields column to users table.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
