Übergabestand 2026-10-14
Alpenwerk HR — HR-Stammdatenverwaltung Mitarbeiter:innen, Organisationsstruktur, Planstellen, Eintritt, Austritt, Versetzung, Beförderung, Karenz, On- und Offboarding, Berichte, Exporte, Massenimport und ein lückenloser Nachweis jeder Änderung. Next.js 16, React 19 und TypeScript; PostgreSQL über Kysely; Anmeldung ausschliesslich über Microsoft Entra ID. Die Fachlogik liegt in der Datenbank, die Zugriffsschranke ist Row Level Security. Betrieb auf Windows Server: siehe deploy/windows/README.md. Sicherheitskonzept: docs/sicherheitskonzept.md.
This commit is contained in:
35
db/migrations/20260714120050_pending_org_changes.sql
Normal file
35
db/migrations/20260714120050_pending_org_changes.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
-- Deferred/effective-dated changes
|
||||
--
|
||||
-- transfer_employee, promote_employee, start_karenz, change_employee_data
|
||||
-- and apply_reorg accept a "Wirksam ab" / effective date. A change dated in
|
||||
-- the future must not overwrite the *current* live record today. When an
|
||||
-- effective date is in the future, the mutating RPC stores the intended
|
||||
-- change here instead of writing it to `employees` right away; a scheduled
|
||||
-- job (apply_due_pending_changes(), see the following migration, invoked by
|
||||
-- a scheduled route handler) applies it once its date arrives. The
|
||||
-- employee_history/audit_log rows are written immediately either way (dated
|
||||
-- with the effective date), which drives the "zukünftig" badge in the
|
||||
-- Historie tab.
|
||||
|
||||
create table pending_org_changes (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
employee_id uuid not null references employees(id) on delete cascade,
|
||||
change_type text not null check (change_type in (
|
||||
'transfer', 'promotion', 'karenz_start', 'karenz_return', 'contract_change', 'reorg'
|
||||
)),
|
||||
effective_date date not null,
|
||||
payload jsonb not null,
|
||||
reorg_scenario_id uuid references reorg_scenarios(id) on delete cascade,
|
||||
status text not null default 'pending' check (status in ('pending', 'applied', 'cancelled')),
|
||||
created_by uuid references auth.users(id),
|
||||
created_at timestamptz not null default now(),
|
||||
applied_at timestamptz
|
||||
);
|
||||
|
||||
create index on pending_org_changes (employee_id);
|
||||
create index on pending_org_changes (status, effective_date);
|
||||
create index on pending_org_changes (reorg_scenario_id);
|
||||
|
||||
alter table pending_org_changes enable row level security;
|
||||
create policy "pending_org_changes_hr_all" on pending_org_changes for all
|
||||
using (is_hr_user()) with check (is_hr_user());
|
||||
Reference in New Issue
Block a user