Files
mkd/backend/migrations/create_employee_responsibility.sql

15 lines
817 B
MySQL
Raw Normal View History

2026-02-04 00:17:04 +05:00
-- Зоны ответственности: привязка сотрудников к подразделам модулей (уведомления, эффективность).
-- Запуск: psql -U user -d your_db -f create_employee_responsibility.sql
CREATE TABLE IF NOT EXISTS employee_responsibility (
id BIGSERIAL PRIMARY KEY,
employee_id VARCHAR(50) NOT NULL REFERENCES employees(id) ON DELETE CASCADE,
section VARCHAR(50) NOT NULL,
sub_id VARCHAR(50) NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(employee_id, section, sub_id)
);
CREATE INDEX IF NOT EXISTS idx_employee_responsibility_employee ON employee_responsibility(employee_id);
CREATE INDEX IF NOT EXISTS idx_employee_responsibility_zone ON employee_responsibility(section, sub_id);