32 lines
2.2 KiB
SQL
32 lines
2.2 KiB
SQL
-- Menu reorganisation (run on a database where GRAINS_SCREEN_PERMISSIONS already exists; safe to re-run; not run by the app).
|
|
-- 1. New screen "طلبية التموين" (grains.orders.supply, orders menu): granted to GTO and GOO (it replaces the old pivot table
|
|
-- that lived inside توزيع الطلبيات, which used grains.permits.distribution).
|
|
-- 2. GOO loses the weighbridge control screen (ضبط الميزان, grains.registry.weighbridge) if it was ever granted.
|
|
-- 3. GOO keeps only two reports: حركات قبان التحميل والتفريغ (weighbridge-events) and دور الشركات (companies-turn).
|
|
-- GOO rows of the two other weighbridge reports (waybridge-summary, waybridge-details) are removed.
|
|
-- 4. GTO keeps only five reports: weighbridge-events, companies-turn, owners-turn, loading-weights, closed-permits
|
|
-- (its waybridge-summary / waybridge-details rows are removed; GTO keeps the القبّان screen).
|
|
-- Take any right away by deleting its row; the API applies it within about a minute, the browser on the next reload / sign-in.
|
|
|
|
INSERT INTO GRAINS_SCREEN_PERMISSIONS (ROLECODE, RESOURCE_KEY)
|
|
SELECT v.rolecode, v.resource_key
|
|
FROM (SELECT 'GTO' AS rolecode, 'grains.orders.supply' AS resource_key FROM dual UNION ALL
|
|
SELECT 'GOO', 'grains.orders.supply' FROM dual UNION ALL
|
|
SELECT 'GOO', 'grains.reports.t.weighbridge-events' FROM dual UNION ALL
|
|
SELECT 'GOO', 'grains.reports.t.companies-turn' 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);
|
|
|
|
DELETE FROM GRAINS_SCREEN_PERMISSIONS
|
|
WHERE rolecode = 'GOO'
|
|
AND resource_key IN ('grains.registry.weighbridge', 'grains.permits.weighbridge',
|
|
'grains.reports.t.waybridge-summary', 'grains.reports.t.waybridge-details');
|
|
|
|
DELETE FROM GRAINS_SCREEN_PERMISSIONS
|
|
WHERE rolecode = 'GTO'
|
|
AND resource_key IN ('grains.reports.t.waybridge-summary', 'grains.reports.t.waybridge-details');
|
|
|
|
COMMIT;
|
|
|
|
-- Check: GOO should have these report rows only
|
|
-- SELECT resource_key FROM GRAINS_SCREEN_PERMISSIONS WHERE rolecode = 'GOO' AND resource_key LIKE 'grains.reports.%' ORDER BY 1;
|