Answers.Body: <p>I would use the Contact Identity Extension and add a custom ID type for your membership number (<a href="https://github.com/systopia/de.systopia.identitytracker" rel="nofollow noreferrer">https://github.com/systopia/de.systopia.identitytracker</a>).</p>
  
  <p>Fiddling around with contact ID's in the database could cause strange behaviour of your system because you have to check a lot of tables and changes something goes wrong are quite high. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-28T13:06:42.523Z
Answers.Text: thanks Jaap - not much info for the Contact Identity extension as far as I can see.  what does it do please?
Answers.UserDisplayName: dgk112
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-29T08:12:04.730Z
Answers.Text: It keeps a list of the contact identity numbers of your contact. Even after merging a contact, so that those identity numbers. Conceptual your membership number gets more or less static with the record in the system but more static with the person.
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-30T16:49:05.860Z
Answers.Text: does it autoincrment each time a new contact is created?
Answers.UserDisplayName: dgk112
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-31T11:24:54.057Z
Answers.Text: No it doesnt do that, it just stores the numbers and keeps track of them. In fact the Contact ID is also stored in the history.
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-27T09:53:03.143Z
Answers.LastActivityDate: 2018-08-27T09:53:03.143Z
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.Body: <p>My solution was to make the contact id match the old membership numbers for all the contacts that I imported and then just rely on auto increment of contact id for new members. Of course there will be gaps in the membership numbers for new contacts but that isn't an issue for me.</p>
  
  <p>You need to start with a new system, so that only contact ids 1 &amp; 2 are already in use (I didn't still have these old membership numbers in use fortunately). Before you import the records, you will need to create dummy records for any gaps in your list of membership numbers and identify them so you can easily find and delete them after the import. You need to have the records in order of old membership number for import.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-22T12:03:38.103Z
Answers.LastActivityDate: 2019-02-22T12:03:38.103Z
Answers.UserDisplayName: Mick Kahn
Body: <p>I've imported our membership list with existing membership numbers into CiviCRM.</p>
  
  <p>The old membership numbers are currently under external ID.  I'd like an autoincrementing membership number.</p>
  
  <p>The best solution I have found from digging around various threads and forums is to do the following in order to use the contact id as the membership:</p>
  
  <ul>
  <li>Modify the database schema constraints to allow updating the contact id and to propagate those changes to all tables </li>
  <li>execute a script that would update the contact id to be the same as the member external id</li>
  </ul>
  
  <p>I might be able to figure out the second part given enough time, but the first bit for sure is a bit beyond my SQL skills.  Is anybody able to assist?  Or there a better solution available to what I imagine is a common requirement?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-25T06:55:55.463Z
Comments.Text: Are you trying to match external number with membership or trying to set auto increment with the membership table ?
Comments.UserDisplayName: Ramesh - ARTECH Consultancy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-28T13:09:42.453Z
Comments.Text: if I could do both that would be good.  although the intitial idea above did neither - it just put replaced exisitng contact ids with the external ids and then relies on the contact id to autoincrement.
Comments.UserDisplayName: dgk112
Tags: <mysql><sql><external-id>
Title: how to get an autoincrementing membership id with existing membership numbers
ThreadText: # how to get an autoincrementing membership id with existing membership numbers
  
  (Asked by: username_0 on 2018-08-24)
  
  I've imported our membership list with existing membership numbers into CiviCRM.
  
  The old membership numbers are currently under external ID. I'd like an autoincrementing membership number.
  
  The best solution I have found from digging around various threads and forums is to do the following in order to use the contact id as the membership:
  
  * Modify the database schema constraints to allow updating the contact id and to propagate those changes to all tables
  * execute a script that would update the contact id to be the same as the member external id
  
  I might be able to figure out the second part given enough time, but the first bit for sure is a bit beyond my SQL skills. Is anybody able to assist? Or there a better solution available to what I imagine is a common requirement?
  
  **Tags:** mysql, sql, external-id
  
  > **Comments:**
  > **username_1**: Are you trying to match external number with membership or trying to set auto increment with the membership table ?  
  > **username_0**: if I could do both that would be good.  although the intitial idea above did neither - it just put replaced exisitng contact ids with the external ids and then relies on the contact id to autoincrement.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-08-27. Score: 2
  
  I would use the Contact Identity Extension and add a custom ID type for your membership number (<https://github.com/systopia/de.systopia.identitytracker>).
  
  Fiddling around with contact ID's in the database could cause strange behaviour of your system because you have to check a lot of tables and changes something goes wrong are quite high.
  
  > **Comments:**
  > **username_0**: thanks username_2 - not much info for the Contact Identity extension as far as I can see.  what does it do please?  
  > **username_2**: It keeps a list of the contact identity numbers of your contact. Even after merging a contact, so that those identity numbers. Conceptual your membership number gets more or less static with the record in the system but more static with the person.  
  > **username_0**: does it autoincrment each time a new contact is created?  
  > **username_2**: No it doesnt do that, it just stores the numbers and keeps track of them. In fact the Contact ID is also stored in the history.  
  
  ---
  
  ### Answer by username_3 on 2019-02-22. Score: 0
  
  My solution was to make the contact id match the old membership numbers for all the contacts that I imported and then just rely on auto increment of contact id for new members. Of course there will be gaps in the membership numbers for new contacts but that isn't an issue for me.
  
  You need to start with a new system, so that only contact ids 1 & 2 are already in use (I didn't still have these old membership numbers in use fortunately). Before you import the records, you will need to create dummy records for any gaps in your list of membership numbers and identify them so you can easily find and delete them after the import. You need to have the records in order of old membership number for import.
  
  
  ---
  
  