Initial commit MKD fixes

This commit is contained in:
Arsen
2026-02-04 00:17:04 +05:00
commit de94ad707b
312 changed files with 138754 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
-- История перемещений и событий по оборудованию (закупка, выдача, перемещения, ремонты, списание)
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'office_equipment_history_type') THEN
CREATE TYPE office_equipment_history_type AS ENUM ('purchase', 'issue', 'transfer', 'repair', 'write_off');
END IF;
END$$;
CREATE TABLE IF NOT EXISTS office_equipment_history (
id BIGSERIAL PRIMARY KEY,
equipment_id BIGINT NOT NULL REFERENCES office_equipment(id) ON DELETE CASCADE,
event_type office_equipment_history_type NOT NULL,
event_date DATE NOT NULL,
assigned_to TEXT,
assigned_from TEXT,
reason TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_equipment_history_equipment ON office_equipment_history(equipment_id);
CREATE INDEX IF NOT EXISTS idx_equipment_history_date ON office_equipment_history(event_date DESC);