nordabiz/database/migrations/097_add_created_by_id.sql
Maciej Pienczyn 3862706197
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
feat(users): track who created each account (created_by_id)
- Add created_by_id FK to users table (NULL = self-registration)
- Set created_by_id in admin create, bulk create, and team add routes
- Show "samorejestracja" or "dodał: [name]" in admin users panel

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 12:48:48 +02:00

12 lines
464 B
SQL

-- Migration 097: Add created_by_id to users table
-- Tracks who created the user account:
-- NULL = self-registration
-- user_id = created by that admin/manager
ALTER TABLE users ADD COLUMN IF NOT EXISTS created_by_id INTEGER REFERENCES users(id) ON DELETE SET NULL;
-- Backfill: mark existing admin-created users where we can infer from audit logs
-- (Skip for now — new column will be populated going forward)
GRANT ALL ON TABLE users TO nordabiz_app;