-- =========================================================
-- 024_warehouse_permissions.sql
-- Sprint 9: warehouse permissions seed
-- =========================================================

INSERT IGNORE INTO permissions (code, name, module, created_at) VALUES
('warehouse.view','Lihat Data Gudang','warehouse',NOW()),
('warehouse.move','Input Barang Masuk / Keluar Gudang','warehouse',NOW()),
('warehouse.opname','Stok Opname Gudang','warehouse',NOW()),
('warehouse.manage','Kelola Grup & QR Gudang','warehouse',NOW());

-- Owner, Admin, Kepala Toko: full warehouse access
INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT r.id, p.id
FROM roles r
JOIN permissions p ON p.code IN ('warehouse.view','warehouse.move','warehouse.opname','warehouse.manage')
WHERE r.code IN ('owner','admin','kepala_toko');
