Files
alpenwerk-hr/supabase/migrations/20260811140000_private_email_optional.sql
Maximilian Stubhan c23df08648 Ask for the optional things separately, and stop claiming numbers are issued
A round of interface corrections from use, plus one schema change behind
them.

The private email address is now optional. It was NOT NULL — the wrong
default for a private detail: someone without one had to invent one, and
invented data in a personnel file is worse than missing data. Both fields
are relabelled to say whose they are, "Private E-Mail" and "Private
Telefonnummer", because the company address does not exist until the person
starts. Uniqueness stays; several NULLs coexist in a Postgres unique index,
which is exactly what is wanted.

The summary step still promised that "Personalnummer und
Firmen-E-Mail-Adresse werden automatisch vergeben". Neither is true any
more. Removed rather than reworded — the step lists what was entered, and a
banner claiming otherwise is worse than no banner.

Dependents move into the wizard as step three, optional. They can only be
attached after the hire, because add_employee_dependent needs an id that
does not exist while the form is open, so they are collected in the draft
and written afterwards. That puts them outside the transaction the person is
created in: if one fails the person still exists, so the message names who
is missing instead of failing silently, and the SV number is checked in the
step rather than after.

The emergency contact gets its own step, second to last, and its
relationship is a dropdown of the common ones rather than free text —
otherwise "Gattin", "Ehefrau" and "Frau" end up side by side and nothing can
be counted. "Sonstige" is there because a closed list would otherwise be
presumptuous.

On the master-data tab it now sits below the dependents rather than above:
both are people around the employee, and this is the one you reach for in a
hurry.

Returning from a long absence: the choice read "unverändert", which made you
open the file to find out what you were agreeing to. It now reads "Wie vor
Abwesenheit (38,5 h)" with the hours actually worked, and the alternative is
"Reduziert" — whose hours field starts empty on purpose. A number already
filled in gets confirmed rather than read off the agreement it comes from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 21:47:04 +02:00

38 lines
1.6 KiB
SQL

-- Die E-Mail-Adresse ist privat und freiwillig.
--
-- Sie war NOT NULL, obwohl es sich um die *private* Adresse handelt — nicht
-- um eine Firmenadresse, die mit dem Eintritt entsteht. Wer keine angeben
-- will oder keine hat, muss trotzdem angelegt werden können. Bisher zwang
-- die Spalte dazu, etwas zu erfinden, und erfundene Daten in einer
-- Personalakte sind schlimmer als fehlende.
--
-- Die Eindeutigkeit bleibt: sie verhindert weiterhin, dass dieselbe Adresse
-- zweimal vorkommt. Mehrere NULL-Werte stören sie nicht — in PostgreSQL
-- gelten sie in einem UNIQUE-Index als voneinander verschieden, und genau
-- das ist hier gewollt.
alter table employees alter column email drop not null;
comment on column employees.email is
'Private E-Mail-Adresse. Freiwillig; eindeutig, wenn angegeben.';
comment on column employees.phone is
'Private Telefonnummer. Freiwillig.';
-- ═══ Gegenprobe ══════════════════════════════════════════════════
-- Zwei Personen ohne Adresse müssen nebeneinander bestehen können, zwei mit
-- derselben nicht.
do $$
begin
create temp table probe_mail (email text unique) on commit drop;
insert into probe_mail (email) values (null), (null);
insert into probe_mail (email) values ('a@example.invalid');
begin
insert into probe_mail (email) values ('a@example.invalid');
raise exception 'Doppelte Adressen werden angenommen — die Eindeutigkeit ist verloren.';
exception when unique_violation then null;
end;
end;
$$;