CREATE DEFINER=`jhise`@`localhost` PROCEDURE `project_create`(in i_owner_account_key char(32), in i_title varchar(255), in i_description text)
BEGIN

	declare new_id int;
    declare l_access_key char(32);

    select md5(now()) into l_access_key;

	insert into project
		(title, description, owner_account_key, access_key) values (i_title, i_description, i_owner_account_key, l_access_key);

	select last_insert_id() into new_id;

    insert into permissions_project values
		(new_id, i_owner_account_key, null, true, true);

	select new_id as new_project_id;

END
