NTP_V2/db/registrar-permissions.sql

30 lines
2.2 KiB
SQL

-- Registrar (التسجيل العام): review of the trucks, trailers and drivers registered from the mobile app (legacy AqabaTCS entities
-- TRUCKINFO / TRAILERINFO / DRIVERINFO). Owner decision: only role GOO sees the screens; the Excel reports (registrar.<kind>.report) are for SU only
-- (SU needs no rows), so no report rows are written. Within GOO the legacy STATUS_ACTION_MATRIX still decides which actions exist:
-- GOO may update PENDING records and confirm / reject drivers and trailers (not trucks); reopen needs no GOO row in the legacy matrix.
-- Primary (NAFITHTCS) schema. Safe to re-run; not run by the app.
--
-- registrar.<kind> screen; kind = drivers | trucks | trailers
-- registrar.<kind>.update UPDATE of a PENDING record
-- registrar.<kind>.complete PENDING -> COMPLETED (drivers, trailers)
-- registrar.<kind>.revoke PENDING -> REVOKE (drivers, trailers)
-- To give another role access, copy the rows with its code (legacy holders of each action are listed in docs/HANDOVER.md).
INSERT INTO GRAINS_SCREEN_PERMISSIONS (ROLECODE, RESOURCE_KEY)
SELECT v.rolecode, v.resource_key
FROM (
SELECT 'GOO' AS rolecode, 'registrar.drivers' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.drivers.update' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.drivers.complete' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.drivers.revoke' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.trucks' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.trucks.update' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.trailers' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.trailers.update' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.trailers.complete' AS resource_key FROM dual UNION ALL
SELECT 'GOO' AS rolecode, 'registrar.trailers.revoke' AS resource_key FROM dual
) v
WHERE NOT EXISTS (SELECT 1 FROM GRAINS_SCREEN_PERMISSIONS p WHERE p.ROLECODE = v.rolecode AND p.RESOURCE_KEY = v.resource_key);
COMMIT;