 insert ignore into USERS (UUID, USERNAME, ENCODED_USERNAME, EMAIL, PASSWORD, ROLE, SALT, ENABLED) VALUES
   ((SELECT UUID() FROM dual), 'registered', 'registered', 'registered@jtalks.org', MD5('registered'), 'USER_ROLE', '',true),
   ((SELECT UUID() FROM dual), 'moderator', 'moderator', 'moderator@jtalks.org', MD5('moderator'), 'USER_ROLE', '', true),
-  ((SELECT UUID() FROM dual), 'banned', 'banned', 'banned@jtalks.org', MD5('banned'), 'USER_ROLE', '', true);
+  ((SELECT UUID() FROM dual), 'banned', 'banned', 'banned@jtalks.org', MD5('banned'), 'USER_ROLE', '', true),
+  ((select UUID() from dual), 'post_creator', 'post_creator', 'post_creator@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'sticked_post_creator', 'sticked_post_creator', 'sticked_post_creator@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'announcement_creator', 'announcement_creator', 'announcement_creator@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'ownpost_editor', 'ownpost_editor', 'ownpost_editor@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'otherpost_editor', 'otherpost_editor', 'otherpost_editor@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'ownpost_remover', 'ownpost_remover', 'ownpost_remover@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'otherpost_remover', 'otherpost_remover', 'otherpost_remover@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'topic_mover', 'topic_mover', 'topic_mover@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'topic_closer', 'topic_closer', 'topic_closer@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'codeReview_creator', 'codeReview_creator', 'codeReview_creator@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true),
+  ((select UUID() from dual), 'codeReview_commentator', 'codeReview_commentator', 'codeReview_commentator@jtalks.org', MD5('qwerty'), 'USER_ROLE', '',true);
 insert ignore into JC_USER_DETAILS (USER_ID, REGISTRATION_DATE, POST_COUNT) values
   ((select ID from USERS where USERNAME = 'registered'), NOW(), 0),
   ((select ID from USERS where USERNAME = 'moderator'), NOW(), 0),
-  ((select ID from USERS where USERNAME = 'banned'), NOW(), 0) ;
+  ((select ID from USERS where USERNAME = 'banned'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'post_creator'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'sticked_post_creator'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'announcement_creator'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'ownpost_editor'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'otherpost_editor'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'ownpost_remover'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'otherpost_remover'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'topic_mover'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'topic_closer'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'codeReview_creator'), NOW(), 0),
+  ((select ID from USERS where USERNAME = 'codeReview_commentator'), NOW(), 0);
 -- ****USERS CREATION END****
 
 -- Add users to appropriate groups
 insert ignore into GROUP_USER_REF select @registered_group_id, ID from USERS;
 insert ignore into GROUP_USER_REF select @moderator_group_id, ID from USERS where USERNAME in ('moderator', 'admin');
 insert ignore into GROUP_USER_REF select @banned_group_id, ID from USERS where USERNAME = 'banned';
+insert ignore into GROUP_USER_REF select @createPosts_group_id, ID from USERS where USERNAME = 'post_creator';
+insert ignore into GROUP_USER_REF select @createStickedPosts_group_id, ID from USERS where USERNAME = 'sticked_post_creator';
+insert ignore into GROUP_USER_REF select @createAnnouncements_group_id, ID from USERS where USERNAME = 'announcement_creator';
+insert ignore into GROUP_USER_REF select @editOwnPosts_group_id, ID from USERS where USERNAME = 'ownpost_editor';
+insert ignore into GROUP_USER_REF select @editOtherPosts_group_id, ID from USERS where USERNAME = 'otherpost_editor';
+insert ignore into GROUP_USER_REF select @deleteOwnPosts_group_id, ID from USERS where USERNAME = 'ownpost_remover';
+insert ignore into GROUP_USER_REF select @deleteOthersPosts_group_id, ID from USERS where USERNAME = 'otherpost_remover';
+insert ignore into GROUP_USER_REF select @moveTopics_group_id, ID from USERS where USERNAME = 'topic_mover';
+insert ignore into GROUP_USER_REF select @closetopics_group_id, ID from USERS where USERNAME = 'topic_closer';
+insert ignore into GROUP_USER_REF select @createCodeReview_group_id, ID from USERS where USERNAME = 'codeReview_creator';
+insert ignore into GROUP_USER_REF select @leaveCommentsInCodeReview_group_id, ID from USERS where USERNAME = 'codeReview_commentator';
 
 set @component_acl_class=1;
 set @group_acl_class=2;

  (7,(SELECT UUID() FROM dual),'TV', 'Has this zombobox something interesting?', 7, @forum_component_id),
  (8,(SELECT UUID() FROM dual),'Hi-tech', 'Technologies', 8, @forum_component_id),
  (9,(SELECT UUID() FROM dual),'People', 'All about mankind', 9, @forum_component_id),
  (10,(SELECT UUID() FROM dual),'Leisure', 'Have free time?', 10, @forum_component_id);
  
-- GROUPS BEGIN
insert ignore into GROUPS (UUID, `NAME`, DESCRIPTION)
  select UUID(), 'Moderators', 'General group for all moderators'
  from dual
  where not exists (select GROUP_ID from GROUPS where `NAME` = 'Moderators');

SET @admin_group_id := (select GROUP_ID from GROUPS where `NAME`='Administrators');
SET @registered_group_id := (select GROUP_ID from GROUPS where `NAME`='Registered Users');
SET @banned_group_id := (select GROUP_ID from GROUPS where `NAME`='Banned Users');
SET @moderator_group_id := (select GROUP_ID from GROUPS where `NAME`='Moderators');

SET @admin_group_sid := concat('usergroup:',@admin_group_id);
SET @registered_group_sid := concat('usergroup:',@registered_group_id);
SET @banned_group_sid := concat('usergroup:',@banned_group_id);
SET @moderator_group_sid := concat('usergroup:',@moderator_group_id);
-- GROUPS END

insert ignore into BRANCHES (BRANCH_ID, UUID, `NAME`, DESCRIPTION, POSITION, SECTION_ID, MODERATORS_GROUP_ID) VALUES
  (1, UUID(), 'Curling', 'Brooms and stones', 0, 1, 1),
  (2, UUID(), 'Cricet', 'Balls and bats', 1, 1 ,1),

  (46, UUID(), 'Theatre', 'Performances', 0, 10, 1),
  (47, UUID(), 'Cinema', 'New blockbusters', 1, 10 ,1),
  (48, UUID(), 'Exhibitions', 'Art', 2, 10 ,1),
  (49, UUID(), 'Competitions', 'Some sport', 3, 10 ,1),
  (50, UUID(), 'Notification tests', 'All permissions for registered users', 0, 11 ,1),
  (51, UUID(), 'Invisible Branch', 'used to check permission for admin', 0, 12, null);
  -- BRANCHES END

-- ****USERS CREATION BEGIN****
-- Creates a default users with registered/registered, moderator/moderator, banned/banned credentials to be able to log in without manual registration
