SET @username="<%= @settings['gerrit_admin_username'] %>";
SET @mail="<%= @settings['gerrit_admin_mail'] %>";
SET @pubkey="<%= @settings['gerrit_admin_sshkey'] %>";
SET @pubkey2="<%= @settings['gerrit_local_sshkey'] %>";

INSERT INTO account_external_ids VALUES (1,@mail,NULL,CONCAT('gerrit:',@username)),(1,NULL,NULL,CONCAT('username:', @username));
INSERT INTO account_group_members VALUES (1,1),(1,6);
INSERT INTO account_group_members_audit VALUES (1,NULL,NULL,1,CURRENT_TIMESTAMP(),1),(1,NULL,NULL,1,CURRENT_TIMESTAMP(),6);
INSERT INTO account_id VALUES (1);
INSERT INTO account_ssh_keys VALUES (@pubkey,'Y',1,1);
INSERT INTO accounts VALUES (NULL,NULL,NULL,NULL,'N',NULL,NULL,NULL,'SSH',25,'N','N','Y','N',NULL,'Y','N',@mail,CURRENT_TIMESTAMP(),1);

INSERT INTO account_ssh_keys VALUES(@pubkey2,'Y',1,2);

SET @username="<%= @settings['gerrit_admin_username'] %>";
SET @mail="<%= @settings['gerrit_admin_mail'] %>";
SET @pubkey="<%= @settings['gerrit_admin_sshkey'] %>";
SET @pubkey2="<%= @settings['gerrit_local_sshkey'] %>";

INSERT INTO account_external_ids VALUES (1,@mail,NULL,CONCAT('gerrit:',@username)),(1,NULL,NULL,CONCAT('username:', @username));
INSERT INTO account_group_members VALUES (1,1);
INSERT INTO account_group_members_audit VALUES (1,NULL,NULL,1,CURRENT_TIMESTAMP(),1),(1,NULL,NULL,1,CURRENT_TIMESTAMP(),6);
INSERT INTO account_id VALUES (1);
INSERT INTO account_ssh_keys VALUES (@pubkey,'Y',1,1);
INSERT INTO accounts VALUES (NULL,NULL,NULL,NULL,'N',NULL,NULL,NULL,'SSH',25,'N','N','Y','N',NULL,'Y','N',@mail,CURRENT_TIMESTAMP(),1);

INSERT INTO account_ssh_keys VALUES(@pubkey2,'Y',1,2);

Fix duplicate key for admin user in database
Fix duplicate key for admin user in database

This fix avoid the failing of the first
group creation as user admin.

Functional test should no work.

Change-Id: I807638bb3a95b6075d0066a408f03be52f2e78e5
