Search documentation of phoenix_kit

# PhoenixKit.Migrations.Postgres.V58 (phoenix_kit v1.7.87)

Copy Markdown View Source

V58: Timestamp Column Type Standardization (timestamptz)

Converts ALL timestamp columns across all 68 PhoenixKit tables from `timestamp without time zone` (aka `timestamp(0)`) to `timestamp with time zone` (aka `timestamptz`).

This completes the DateTime standardization:

- Steps 1-4 (prior): Elixir schemas → `:utc_datetime` / `DateTime.utc_now()`
- V58: PostgreSQL columns → `timestamptz`

## Why timestamptz?

PostgreSQL `timestamp` stores values without timezone context. While PhoenixKit always stores UTC, `timestamptz` makes this explicit at the database level and is the PostgreSQL-recommended type for timestamps. Ecto's `:utc_datetime` type maps to `timestamptz` natively.

## Conversion Safety

The `up` direction needs no `USING` clause — PostgreSQL implicitly treats existing `timestamp` values as UTC when casting to `timestamptz`.

The `down` direction requires `USING col AT TIME ZONE 'UTC'` to explicitly convert `timestamptz` back to `timestamp(0)`.

## Idempotency

All operations check:

- `table_exists?/2` — skip if table doesn't exist (optional modules)
- `column_exists?/3` — skip if column doesn't exist
- `column_is_timestamptz?/3` — skip if already converted (up) or already reverted (down)

## Summary

### Functions

down(opts)
up(opts)

## Functions

# down(opts)

# up(opts)