The Wire · Showcase
POSTGRESQL 18.4 FOREIGN KEY SUPPORT LANDS IN RAILS
By RepoJournal · Filed · About Rails
Rails just shipped native support for PostgreSQL 18.4's NOT ENFORCED foreign keys, letting table owners toggle constraints without superuser privileges for the first time.
The Rails core team merged two complementary features that fundamentally change how you handle foreign key constraints on modern PostgreSQL. First, disable_referential_integrity now uses NOT ENFORCED/ENFORCED syntax on PostgreSQL 18.4+ instead of requiring DISABLE TRIGGER ALL superuser access [1]. Second, a new enforced: option lets you declare foreign keys as NOT ENFORCED directly in migrations, solving the silent data corruption problem where switching back to ENFORCED wouldn't re-validate existing rows [2]. Together, these changes eliminate the superuser requirement that has plagued Rails deployments for years. On the tooling side, Rails also added exclusion_constraint_exists? and unique_constraint_exists? helpers to round out constraint introspection [3]. In other updates, the devcontainer now supports Ruby 4.0.5 [4], and rails/marcel improved MIME type detection with tika.xml regex support while cleaning up trailing spaces in type definitions [5].
Action items
- → If you're on PostgreSQL 18.4+, test the new enforced: option in your next feature branch rails/rails [plan]
- → Update your devcontainer to ruby-2.3.3 when testing local environments rails/devcontainer [monitor]
References
- [1] Use NOT ENFORCED in disable_referential_integrity on PostgreSQL 18.4+ ↗ rails/rails
- [2] Add `enforced:` option for foreign keys on PostgreSQL 18.4+ ↗ rails/rails
- [3] Add `exclusion_constraint_exists?` and `unique_constraint_exists?` helpers rails/rails
- [4] ruby-2.3.3 ↗ rails/devcontainer
- [5] add `tika.xml` regex support ↗ rails/marcel
FAQ
- What changed in Rails on May 20, 2026?
- Rails just shipped native support for PostgreSQL 18.4's NOT ENFORCED foreign keys, letting table owners toggle constraints without superuser privileges for the first time.
- What should Rails teams do about it?
- If you're on PostgreSQL 18.4+, test the new enforced: option in your next feature branch • Update your devcontainer to ruby-2.3.3 when testing local environments
- Which Rails repositories shipped on May 20, 2026?
- rails/rails, rails/devcontainer, rails/marcel