Skip to content

Instantly share code, notes, and snippets.

@masterfermin02
Last active January 16, 2020 02:50
Show Gist options
  • Save masterfermin02/555540b98307088f84cbd21bd43a6b41 to your computer and use it in GitHub Desktop.
Save masterfermin02/555540b98307088f84cbd21bd43a6b41 to your computer and use it in GitHub Desktop.
-- PE-13069 Seed data - PATCH
START TRANSACTION;
# Create some riders (9 riders)
INSERT INTO riders (id, active, first_name, last_name, email, password, salt, activation_token, region, phone_number, joined, registered_via_oauth_client_id, shipping_first_name, shipping_last_name, address_1, address_2, city, state, country, zip, shoe_size, bike_bar_height, bike_seat_height, bike_seat_distance, bike_handlebar_depth, bike_extended_handlebars, is_staff, emergency_contact_name, emergency_contact_phone, first_ride, series_vertical_redemption_enabled, notes, sent_first_bike_welcome_email, sent_post_first_ride_email, spotify_custom_playlist_uri, spotify_custom_playlist_link, new_rider_agreement_signed, state_text, gender, birthday, updated_at)
VALUES ('78791', '1', 'Eddy', 'Espinal', '[email protected]', 'aa259b0bdd3bc4e9d39bfa0dd7645ff103e68021', '5d640f914eb73', '5d640f914ed62', '1', '+12123829933', '2019-08-26 16:57:53', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '0', NULL, NULL, NULL, '0', NULL, '0', '0', NULL, NULL, '0', NULL, NULL, NULL, '2019-08-26 16:57:53'),
('78792', '1', 'Eddy', 'Espinal', '[email protected]', 'aa259b0bdd3bc4e9d39bfa0dd7645ff103e68021', '5d640f914eb73', '5d640f914ed62', '1', '+12123829933', '2019-08-26 16:57:53', '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '0', NULL, NULL, NULL, '0', NULL, '0', '0', NULL, NULL, '0', NULL, NULL, NULL, '2019-08-26 16:57:53');
# get student tag
SET @student = (SELECT id FROM tags WHERE name = 'Student');
#Create some rider_tags
INSERT INTO rider_tags (rider_id, tag_id, created_at) VALUES (78791, @student, '2019-06-19');
#Update region_series to be web_purchasable
SET @series_id = (select id from series where products_physical_sku = 'NYC-UNIVERSITY-SKU');
UPDATE region_series SET web_purchasable = 1 WHERE region_id = 1 AND series_id = @serie_id;
COMMIT;
-- PE-13069 Seed data - REVERT
START TRANSACTION;
SET FOREIGN_KEY_CHECKS = 0;
# get student tag
SET @student = (SELECT id FROM tags WHERE name = 'Student');
# Delete
DELETE riders,
rider_tags
FROM riders
LEFT JOIN rider_tags on riders.id = rider_tags.rider_id AND rider_tags.tag_id = @student
WHERE id in(78791, 78792);
#Update region_series to be web_purchasable
SET @series_id = (select id from series where products_physical_sku = 'NYC-UNIVERSITY-SKU');
UPDATE region_series SET web_purchasable = 0 WHERE region_id = 1 AND series_id = @serie_id;
SET FOREIGN_KEY_CHECKS = 1;
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment