Database Script For Creating a Mailbox in JBMS 1.0M4/1.0M5_pre1
versions: 1.0M4
MySQL Example
insert into Folder (name, parent_id,defaultinFolder_id, defaultoutfolder_id,type,id) values (null,null, null , null ,'org.jboss.mail.mailbox.Mailbox', null ); SELECT @last := LAST_INSERT_ID(); insert into Folder (name, parent_id,defaultinfolder_id, defaultoutfolder_id,type,id) values ('INBOX',@last ,null,null,'org.jboss.mail.mailbox.Folder',null); update Folder set defaultinfolder_id = last_insert_id() , defaultoutfolder_id = last_insert_id() where id = @last; insert into alias(id,name,folder_id) values (null,'testuser', @last); insert into alias(id,name,folder_id) values (null ,'testuser@localhost', @last);
(assuming you wanted one local domain called "localhost" and had one account "testuser" which has the address "testuser@localhost")
PostgreSQL Example
> psql -d jbmsDB -U jbms begin; insert into Folder(name, parent_id,defaultinfolder_id, defaultoutfolder_id,type,id) values (null,null,null,null,'org.jboss.mail.mailbox.Mailbox',27); insert into Folder(name, parent_id,defaultinfolder_id, defaultoutfolder_id,type,id) values ('INBOX',27,null,null,'org.jboss.mail.mailbox.Folder',28); update folder set defaultinfolder_id=28, defaultoutfolder_id=28 where id=27; insert into alias(id,name,folder_id) values (29,'test',27); insert into alias(id,name,folder_id) values (30,'test@superlinksoftware.com',27); commit;
This assumes that the last folder was numbered 26 and the last alias was numbered 28. There is a sequence that is normally created called 'hibernate_sequence' that can be used by issuing the appropriate combination of nextval('hibernate_sequence') currval('hibernate_sequence') in place of the hard coded numerics above. However if used for folders this will create a sparse set of ids. It is the same sequence used for message IDs.
versions: 1.0M5-pre1
MySQL Example
insert into Folder (name, parent_id,defaultinFolder_id, defaultoutfolder_id,type,id) values (null,null, null , null ,'Mailbox', null ); SELECT @last := LAST_INSERT_ID(); insert into Folder (name, parent_id,defaultinfolder_id, defaultoutfolder_id,type,id) values ('INBOX',@last ,null,null,'Folder',null); update Folder set defaultinfolder_id = last_insert_id() , defaultoutfolder_id = last_insert_id() where id = @last; insert into alias(id,name,folder_id) values (null,'testuser', @last); insert into alias(id,name,folder_id) values (null ,'testuser@localhost', @last);
(assuming you wanted one local domain called "localhost" and had one account "testuser" which has the address "testuser@localhost")
PostgreSQL Example
> psql -d jbmsDB -U jbms begin; insert into Folder(name, parent_id,defaultinfolder_id, defaultoutfolder_id,type,id) values (null,null,null,null,'Mailbox',27); insert into Folder(name, parent_id,defaultinfolder_id, defaultoutfolder_id,type,id) values ('INBOX',27,null,null,'Folder',28); update folder set defaultinfolder_id=28, defaultoutfolder_id=28 where id=27; insert into alias(id,name,folder_id) values (29,'test',27); insert into alias(id,name,folder_id) values (30,'test@superlinksoftware.com',27); commit;
This assumes that the last folder was numbered 26 and the last alias was numbered 28. There is a sequence that is normally created called 'hibernate_sequence' that can be used by issuing the appropriate combination of nextval('hibernate_sequence') currval('hibernate_sequence') in place of the hard coded numerics above. However if used for folders this will create a sparse set of ids. It is the same sequence used for message IDs.
Other DBs
Other database scripts can be created by adapting the above. For MySQL type "show tables" and "desc" the appropriate tables. Remember that mysql is actually case sensitive for table and field names. For Oracle type "select table_name from user_tables" and desc the individual tables. The above will work directly in oracle as it is also not case sensitive.
Comments