--	Order and Subscription
--	License User
CREATE USER 'sc_license'@'%' IDENTIFIED BY '816H7fp_w#.<';

--	Order User
CREATE USER 'sc_order'@'%' IDENTIFIED BY 'aoIl0^z-#m[q';

--	Subscription User
CREATE USER 'sc_subscription'@'%' IDENTIFIED BY '7vTK@7vPYH/z';

--	Release Build User
CREATE USER 'sc_build'@'%' IDENTIFIED BY 'h.DW+umMt3d8';

--	Administration Users
--	Utilities User
CREATE USER 'sc_utils'@'%' IDENTIFIED BY 'A3i3tqhfCYR+ia';

--	Sparkle User
CREATE USER 'sc_sparkle'@'%' IDENTIFIED BY '^ju9D8u_+uRy2';


--	User Manager User
CREATE USER 'sc_users'@'%' IDENTIFIED BY 'ua*7t56FD-+G';

--	Sendy User
CREATE USER 'sc_sendy'@'%' IDENTIFIED BY 'dggJUgg@jk-8';

--	AWS Users
CREATE USER 'sc_aws'@'%' IDENTIFIED BY 'y7ak^$jteMS';
CREATE USER 'sc_aws_sum'@'%' IDENTIFIED BY 't88O#-!a7dmtP';



--	Grant rights to the users in the appropriate ways
-- Need to use this script for each host we want to give access to - just replace % with the host name or ip

--	Order and Subscription
--	License User
GRANT SELECT ON `registration`.`subscription` to 'sc_license'@'%';
GRANT SELECT, INSERT, UPDATE ON `registration`.`license` to 'sc_license'@'%';
GRANT SELECT, INSERT ON `registration`.`activation` to 'sc_license'@'%';
--	Changed on 10 September 2020
GRANT SELECT, INSERT ON `registration`.`blocklist` to 'sc_license'@'%';
--	Changed on 14 October 2020
GRANT SELECT, INSERT ON `registration`.`license_sub_link` to 'sc_license'@'%';

--	Order User
GRANT SELECT, INSERT, UPDATE ON `registration`.`order` to 'sc_order'@'%';
GRANT SELECT, INSERT ON `registration`.`subscription_order_link` to 'sc_order'@'%';
--	Added on 08 October 2021
GRANT SELECT, INSERT ON `registration`.`fs_event` to 'sc_order'@'%';
--	Added on 31 January 2022
GRANT SELECT, INSERT, UPDATE ON `registration`.`coupons` to 'sc_order'@'%';

--	Subscription User
GRANT SELECT, INSERT, DELETE ON `registration`.`subscription_activation` to 'sc_subscription'@'%';
GRANT SELECT, INSERT, UPDATE ON `registration`.`subscription` to 'sc_subscription'@'%';
GRANT SELECT, UPDATE ON `registration`.`subscription_order_link` to 'sc_subscription'@'%';
--	Added on 10 September 2020
GRANT SELECT, INSERT ON `registration`.`blocklist` to 'sc_subscription'@'%';
GRANT SELECT ON `registration`.`license` to 'sc_subscription'@'%';
--	Added on 08 October 2020
GRANT SELECT, INSERT ON `registration`.`fs_event` to 'sc_subscription'@'%';
--	Changed on 14 October 2020
GRANT SELECT, INSERT ON `registration`.`license_sub_link` to 'sc_subscription'@'%';

--	Release Build User
GRANT SELECT, INSERT, UPDATE ON `release`.`release_information` to 'sc_build'@'%';

--	Administration Users
--	Utilities User
GRANT SELECT, INSERT, UPDATE ON `utilities`.`log_messages` to 'sc_utils'@'%';
GRANT SELECT, INSERT, UPDATE ON `utilities`.`usage` to 'sc_utils'@'%';
GRANT SELECT, INSERT, UPDATE ON `utilities`.`detail_usage` to 'sc_utils'@'%';
GRANT SELECT, INSERT, UPDATE ON `utilities`.`message` to 'sc_utils'@'%';
GRANT SELECT, INSERT, UPDATE ON `utilities`.`message_shown` to 'sc_utils'@'%';

--	User Manager User
GRANT SELECT, INSERT, UPDATE ON `utilities`.`user` to 'sc_users'@'%';
GRANT SELECT, INSERT, DELETE ON `utilities`.`session` to 'sc_users'@'%';

--	AWS User
GRANT SELECT, INSERT, DELETE ON `aws_logs`.`logged_files` to 'sc_aws'@'%';
GRANT SELECT, INSERT, DELETE ON `aws_logs`.`log_data` to 'sc_aws'@'%';
GRANT SELECT, INSERT, UPDATE ON `aws_logs`.`location_data` to 'sc_aws'@'%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `aws_logs`.`summary_log_data` to 'sc_aws'@'%';

--	AWS Summary User
GRANT SELECT ON `aws_logs`.`log_data` to 'sc_aws_sum'@'%';
GRANT SELECT ON `aws_logs`.`location_data` to 'sc_aws_sum'@'%';
GRANT SELECT ON `aws_logs`.`summary_log_data` to 'sc_aws_sum'@'%';

--	Sendy User
GRANT SELECT, UPDATE ON `sendy`.`subscribers` to 'sc_sendy'@'%';

