Files
openproject/db/migrate
Pavel Balashou 5af7d211c8 [#74977] Modify friendly_id_slugs constraints.
https://community.openproject.org/wp/74977

Add NOT NULL to *sluggable_type* and fix NULL *scope* uniqueness in *friendly_id_slugs*

- Delete duplicate NULL *scope* rows, keeping the most recent per (slug, sluggable_type)
- Delete NULL *sluggable_type* rows before adding NOT NULL constraint
- Replace unique index on (slug, sluggable_type, scope) with NULLS NOT DISTINCT variant (requires Postgres 15+)

Why?

1. *sluggable_type* NOT NULL
  every slug must belong to a model (e.g. Post, User). A slug with no *sluggable_type* is orphaned and meaningless.
2. NULLS NOT DISTINCT in the unique constraint
  not treating every NULL *scope* as unique leads to duplicate records if *scope* is NULL which does not make sense
  and pollutes the table with unnecessary data
2026-05-19 11:14:41 +02:00
..
2025-07-22 14:54:28 +02:00