Created
April 29, 2019 02:37
-
-
Save clarkbab/8e9be0b36f5d5e77076acb513d17419e to your computer and use it in GitHub Desktop.
Generate many records.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
CREATE PROCEDURE generate_data() | |
BEGIN | |
DECLARE i INT DEFAULT 1; | |
DECLARE num_records INT DEFAULT 6000000; | |
DECLARE hours_per_5_years INT DEFAULT 43800; | |
DECLARE rand_time DATETIME; | |
WHILE i < num_records DO | |
SELECT NOW() - INTERVAL FLOOR(hours_per_5_years * RAND()) HOUR INTO rand_time; | |
INSERT INTO outgoing_channels_conversions (id, account_id, text, comment_id, ticket_id, resource_type, created_at, updated_at) VALUES (i + 1000000, i, 'text', i, i, 'resource_type', rand_time, rand_time); | |
SET i = i + 1; | |
END WHILE; | |
END$$ | |
DELIMITER ; | |
CALL generate_data(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment