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

Copy Markdown View Source

V67: Make all remaining legacy NOT NULL integer FK columns nullable.

After the UUID cleanup (V56+), schemas only write _uuid foreign keys. Many tables still have legacy integer FK columns with NOT NULL constraints, causing inserts to fail with not_null_violation.

This migration makes all remaining affected columns nullable in one pass. All operations are idempotent (guarded by table/column existence checks).

Tables & Columns (42 total)

Roles (3)

  • user_role_assignments.user_id, user_role_assignments.role_id
  • role_permissions.role_id

Posts (3)

  • posts.user_id
  • comment_likes.user_id
  • comment_dislikes.user_id

Tickets (2)

  • ticket_comments.user_id
  • ticket_status_history.changed_by_id

Storage (1)

  • files.user_id

Admin/Auth/Audit (5)

  • admin_notes.user_id, admin_notes.author_id
  • user_oauth_providers.user_id
  • audit_logs.target_user_id, audit_logs.admin_user_id

Connections (13)

  • user_follows: follower_id, followed_id
  • user_connections: requester_id, recipient_id
  • user_blocks: blocker_id, blocked_id
  • user_follows_history: follower_id, followed_id
  • user_connections_history: user_a_id, user_b_id, actor_id
  • user_blocks_history: blocker_id, blocked_id

Billing (6)

  • invoices.user_id
  • transactions.user_id, transactions.invoice_id
  • subscriptions.user_id, subscriptions.subscription_type_id (was plan_id)
  • payment_methods.user_id

Entities (3)

  • entities.created_by
  • entity_data.entity_id, entity_data.created_by

Referrals (3)

  • referral_codes.created_by
  • referral_code_usage.code_id, referral_code_usage.used_by

Standalone Comments (2)

  • comments_likes.user_id
  • comments_dislikes.user_id

Shop (1)

  • shop_cart_items.cart_id

Summary

Functions

down(opts)

up(opts)