PhoenixKit.Migrations.Postgres.V02 (phoenix_kit v1.7.71)

Copy Markdown View Source

PhoenixKit Migration V02: Remove is_active column from role assignments.

This migration removes the is_active column from role assignments table, simplifying the role system to use direct deletion instead of soft deletion.

Changes

  • Remove is_active column from phoenix_kit_user_role_assignments table
  • Remove performance indexes that used is_active column
  • Clean up existing inactive role assignments (convert to actual deletions)

Migration Strategy

  1. Remove inactive assignments (where is_active = false)
  2. Drop indexes that reference is_active column
  3. Drop is_active column from role assignments table

Rollback Strategy

  • Adds back is_active column with default true
  • Recreates performance indexes
  • All existing assignments become active by default

Note: This migration cannot preserve inactive assignment history. Consider backing up inactive assignments if audit trail is required.

Summary

Functions

Returns migration description for logging and status display.

Returns whether this migration is destructive (cannot be safely rolled back).

Rollback V02 migration by restoring is_active column.

Returns estimated migration time for progress tracking.

Pre-migration checks and warnings.

Run the V02 migration to remove is_active column.

Validates prerequisites before running migration.

Returns the migration version.

Functions

description()

Returns migration description for logging and status display.

destructive?()

Returns whether this migration is destructive (cannot be safely rolled back).

down(opts)

Rollback V02 migration by restoring is_active column.

Warning: This cannot restore previously deleted inactive assignments.

estimated_time()

Returns estimated migration time for progress tracking.

pre_migration_report(repo, prefix \\ nil)

Pre-migration checks and warnings.

Counts inactive assignments that will be permanently deleted.

up(opts)

Run the V02 migration to remove is_active column.

validate_prerequisites(repo, prefix \\ nil)

Validates prerequisites before running migration.

Ensures V01 migration has been applied.

version()

Returns the migration version.