
CREATE TABLE USERNAME_COUNTER (
  ID_INTERNAL int(11) NOT NULL auto_increment,
  KEY_ROOT_DOMAIN_OBJECT int(11) NOT NULL default '1',
  INVITATION_COUNTER int(11) not null default 1,
  PRIMARY KEY (ID_INTERNAL),
  KEY KEY_ROOT_DOMAIN_OBJECT (KEY_ROOT_DOMAIN_OBJECT)
);

insert into USERNAME_COUNTER values (1, 1, 9100);

alter table ROOT_DOMAIN_OBJECT add column KEY_USERNAME_COUNTER int(11) default null;
alter table ROOT_DOMAIN_OBJECT add index (KEY_USERNAME_COUNTER);
update ROOT_DOMAIN_OBJECT set KEY_USERNAME_COUNTER = 1;