INSERT INTO accounts 
  (account_id,preferred_email,registered_on)
VALUES
  (<%= @userid %>,'<%= @useremail %>',now());
INSERT INTO account_group_members
  (account_id, group_id)
VALUES (
  (SELECT account_id FROM accounts WHERE preferred_email='<%= @useremail %>'),
  (SELECT group_id FROM account_groups WHERE name='<%= @usergroup %>')
);
INSERT INTO account_external_ids
  (account_id, external_id)
VALUES (
  (SELECT account_id FROM accounts WHERE preferred_email='<%= @useremail %>'),
  'gerrit:<%= @useremail %>'
);
INSERT INTO account_external_ids
  (account_id, external_id, email_address, password)
VALUES (
  (SELECT account_id FROM accounts WHERE preferred_email='<%= @useremail %>'),
  'username:<%= @username %>',
  '<%= @useremail %>',
  'mylyntest'
);
INSERT INTO account_ssh_keys
  (ssh_public_key,valid,account_id)
VALUES (
 '<%= @userkey %>',
 'Y',
 (SELECT account_id FROM accounts WHERE preferred_email='<%= @useremail %>'),
);
