
ALTER TABLE was_hub_milestone
	ADD COLUMN `milestone_order` tinyint (1) unsigned NOT NULL AFTER `business_type_id`,
	ADD KEY `idx_business_type_id` (business_type_id, milestone_order);

UPDATE
	was_hub_milestone m
	JOIN (
		SELECT
			row_number() OVER (ORDER BY CASE slug
				WHEN 'privacy_policy' THEN
					7
				ELSE
					milestone_order
				END) AS rn,
			milestone_id,
			slug
		FROM
			was_hub_milestone
		WHERE
			business_type_id = 1) AS sub ON m.milestone_id = sub.milestone_id SET m.milestone_order = sub.rn;

UPDATE
	was_hub_milestone m
	JOIN (
		SELECT
			row_number() OVER (ORDER BY CASE slug
				WHEN 'privacy_policy' THEN
					7
				ELSE
					milestone_order
				END) AS rn,
			milestone_id,
			slug
		FROM
			was_hub_milestone
		WHERE
			business_type_id = 2) AS sub ON m.milestone_id = sub.milestone_id SET m.milestone_order = sub.rn;
