Unique_constraint does not work for changeset, although properly setup in data, migrations and controller

Are you sure it’s allowing duplicates when testing with non-NULL emails? Because according to psql docs PostgreSQL: Documentation: 18: 5.5. Constraints

In general, a unique constraint is violated if there is more than one row in the table where the values of all of the columns included in the constraint are equal. However, two null values are never considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns.