Primary Key error when registering new User

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
7/21/2009 5:28:54 AM
Gravatar
Total Posts 20

Primary Key error when registering new User

Because of several problems with Mono (a few of them I mentioned here in the forum) we decided to put a Windows 2008 Server VM on our server, in which Mojoportal now shall run.

As Database we still use Postresql.

Yesterday I copied the mp-users-table into the new database. Logging in works fine, in the Administration settings it shows me all the users.

But when I want to register a new user, I get following error:

2009-07-21 12:17:20,761 ERROR mojoPortal.Web.Global - 84.178.100.155-de-DE - /mojo/Admin/ManageUsers.aspx?userId=-1
Npgsql.NpgsqlException:
duplicate key value violates unique constraint "pk_users"
Severity: ERROR
Code: 23505
bei Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>c__Iterator1.MoveNext()
bei Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
bei Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
bei Npgsql.ForwardsOnlyDataReader.NextResult()
bei Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)
bei Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
bei Npgsql.NpgsqlCommand.ExecuteScalar()
bei mojoPortal.Data.NpgsqlHelper.ExecuteScalar(NpgsqlConnection connection, CommandType commandType, String commandText, NpgsqlParameter[] commandParameters)
bei mojoPortal.Data.NpgsqlHelper.ExecuteScalar(String connectionString, CommandType commandType, String commandText, NpgsqlParameter[] commandParameters)
bei mojoPortal.Data.DBSiteUser.AddUser(Guid siteGuid, Int32 siteId, String fullName, String loginName, String email, String password, Guid userGuid, DateTime dateCreated)
bei mojoPortal.Business.SiteUser.Create()
bei mojoPortal.Web.AdminUI.ManageUsers.CreateUser()
bei System.Web.UI.WebControls.Button.OnClick(EventArgs e)
bei System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
bei System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 

Are there any other tables with user informations which I have to copy as well? Or are there any settings somewhere which I have to change?

any help is appreciated.

thanks

Andi

7/21/2009 5:51:12 AM
Gravatar
Total Posts 18439

Re: Primary Key error when registering new User

This is not a mojoPortal bug.

There is a sequence that creates the usereid for new rows but its starting with 1 and this is a duplicate key because of the existing rows. I think you would need to alter the sequence so it starts at a number higher than any existing userid.

You also will need to hook the users up to roles correctly in mp_userroles.

Maybe somethinglike this will work:

ALTER SEQUENCE mp_userroles_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;

you would need to change the START WITH to a number higher than any existing userid.

Not sure if this will work as I'm not a pgsql super guru, but thats what I would try.

Hope it helps,

Joe

7/21/2009 6:20:22 AM
Gravatar
Total Posts 20

Re: Primary Key error when registering new User

that worked!! :-)

I made it for the mp_users and the mp_userroles and now the new users are registered fine.

thank you very much Joe, for your fast replay as well.

You must sign in to post in the forums. This thread is closed to new posts.