DROP USER IF EXISTS 'serviceAgent'@'%';
DROP USER IF EXISTS 'managerAgent'@'%';
CREATE USER 'serviceAgent'@'%' IDENTIFIED BY 'password123';
CREATE USER 'managerAgent'@'%' IDENTIFIED BY 'password123';

GRANT SELECT ON ManagerDatabase.Managers TO 'managerAgent'@'%';
GRANT ALL PRIVILEGES ON ServiceDatabase.Flights TO 'managerAgent'@'%';

GRANT ALL PRIVILEGES ON ServiceDatabase.Passengers TO 'serviceAgent'@'%';
GRANT ALL PRIVILEGES ON ServiceDatabase.Orders TO 'serviceAgent'@'%';
GRANT ALL PRIVILEGES ON ServiceDatabase.Users TO 'serviceAgent'@'%';
GRANT ALL PRIVILEGES ON ServiceDatabase.Airports TO 'serviceAgent'@'%';
GRANT ALL PRIVILEGES ON ServiceDatabase.Tickets TO 'serviceAgent'@'%';
GRANT SELECT, UPDATE (First_class_seats_remaining, Business_class_seats_remaining, Economy_class_seats_remaining)
ON ServiceDatabase.Flights TO 'serviceAgent'@'%';

FLUSH PRIVILEGES;