#! /usr/bin/perl

use strict;
use warnings;

my $NUM_MESSAGES = 1000000;
my $PUSH_MODE = $ENV{PUSH_MODE} || undef;

my $num_messages = 0;

while ($num_messages < $NUM_MESSAGES) {
    my $user_id = int(rand(1000) ** 1.5) + 1;
    next if $user_id>10000;
    printf(
        qq(insert into message (user_id,body) values (%d,'%s');\n),
        $user_id,
        "hello from $user_id",
    );
    print "insert into mailbox (user_id,message_id) select user_id,last_insert_id() from follower where follower_id=$user_id;\n"
        if $PUSH_MODE;
    $num_messages++;
}
