Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How are table IDs generated/incremented?

TomTom October 9, 2012

Hi!

I am trying to figure out how database table ids (primary keys) are generated/calculated/incremented? I actually thought it's a usual increment by 1.

What I did:

I manually added data rows to CONTENT_PERM_SET and CONTENT_PERM. For the ID I was using the last value and incremented by 1, for each table entry. Then I restarted the Confluence service. The restrictions on all the pages are totally fine. Everything seems to work.

Then I manually added another restriction via Confluence and just figured out, that the ID which was created in CONTENT_PERM_SET is miles away from my last ID I've created directly in the database table.

Is there a special way to calculate the next ID if I want to manually add entries directly into the database tables via script? Is it somehow depenend from other values (creation date, content id, etc.)?

We are using MS-SQL for the database.

Thanks in advance & Cheers
Tom

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 4, 2012

Hi Tom,

The IDs in Confluence are generated using Hibernate - we use a customised ID generator which you can see in the Confluence source if you go hunting for com.atlassian.hibernate.ResettableTableHiLoGenerator

There is no problem if the rows you have added use IDs that are not sequential or contiguous with other rows in the table - everything will still work fine.

However, generally we would discourage you from interacting with the database directly - and instead use something like the Confluence SOAP/XML-RPC API or the Confluence CLI Tool.

TomTom November 6, 2012

Thanks, Joseph, for your response! I will check out the Confluence CLI Tool the next time I get such a request.

Cheers,
Tom

TAGS
AUG Leaders

Atlassian Community Events