Database schema

On this page:

About the JIRA database schema

The PDFs below show the database schema for JIRA 6.1 EAP 3 (m03) and JIRA 5.1.2.

The database schema is also described in WEB-INF/classes/entitydefs/entitymodel.xml in the JIRA web application. The entitymodel.xml file has an XML definition of all JIRA's database tables, table columns and their data type. Some of the relationships between tables also appear in the file.

Generating JIRA database schema information

To generate schema information for the JIRA database, e.g. the PDF above, follow the instructions below. You can generate schema information in pdf, txt and dot formats. Note, if you want to generate the schema in PDF format, you need to have Graphviz installed.

  1. Download the attached plugin: 
    1. For JIRA 5:  jira-schema-diagram-generator-plugin-1.0.jar
    2. For JIRA 6: jira-schema-diagram-generator-plugin-1.0.1.jar
  2. Install the plugin in your JIRA instance by following the instructions on Managing JIRA's Plugins.

    1. Go to the JIRA administration console and navigate to System > Troubleshooting and Support > Generate Schema Diagram
      (tick)Keyboard shortcut: g + g + start typing generate
    2. Enter the tables/columns to omit from the generated schema information, if desired.
    3. If you want to generate a pdf, enter the path to the Graphviz executable.
    4. Click Generate Schema.
    5. The 'Database Schema' page will be displayed with links to the schema file in txt, dot and pdf format.

Entity Engine and working with the JIRA database

JIRA uses Entity Engine module of the OfBiz suite to communicate with the database. You can learn more about the Entity Engine by reading its online documentation.

If you are using JIRA's API you will notice that a lot of code deals with GenericValue objects. The GenericValue is an OfBiz entity engine object. Each GenericValue object represents a record in the database.

To get a value of a field from a GenericValue you will need to use the relevant getter method for the field's type. For example:

The list of valid fields for each entity can be obtained by looking the entity's definition in the WEB-INF/classes/entitydefs/entitymodel.xml file. For the above example, one needs to look at the "Project" entity.

Notes about working with the JIRA database:

Relationships between tables

Some of the relationships between JIRA's tables in the database are documented below:

Issue Fields

Unable to render {include} The included page could not be found.

Custom fields

Unable to render {include} The included page could not be found.

Change History

Change History Database Tables

JIRA stores the Change History records of each issue in the changegroup and changeitem tables.

Each change to the issue triggered by a user inserts one record into the changegroup table. Each changegroup table record describes which issue it refers to, the time of the change and the user who has performed the change (null for a non-logged in user).

Each changegroup record refers to one or many changeitem records. Each changeitem record describes the issue field that has been updated and its old and new values. The OLDVALUE column records the id of the changed enity (e.g. status) while OLDSTRING records the name fo the entity, so that if the entity is removed from the system the change history for an issue can still be displayed. The NEWVALUE and NEWSTRING columns are similar in nature.

Inserting change history records

When writing tools that import data into JIRA, it is sometimes required to import change history. To do this please first insert a record into the changegroup table with a valid issue id:

The issues are stored in the jiraissue table:

And then insert the required number of changeitem records referencing the inserted changegroup record:

The SEQUENCE_VALUE_ITEM table

The SEQUENCE_VALUE_ITEM table is used to record, in a database independent way, the maximum ID used in each of JIRA's database tables:

Actually, Ofbiz allocates IDs in batches of 10, so the SEQ_ID is the next available ID rounded up to the nearest 10. So you might have:

Where 10310 is the nearest 10 above 10303.

The SEQ_NAME column refers to the database table name defined in WEB-INF/classes/entitydefs/entitymodel.xml (eg. "Action" is jiraaction).

Manually inserting records

The implication of this is that if you want to manually insert records into JIRA database tables, you must update SEQUENCE_VALUE_ITEM yourself. Set the relevant rows' SEQ_ID values to a value greater than the actual maximum ID in the table. You will then need to restart JIRA to ensure all database caches are reset.

Retrieving Change History using JIRA's API

The best way to retrieve change history entries is:

You can declare dependency on JiraAuthenticationContext and ActionManager in the constructor of your plugin as described in PicoContainer and JIRA.

The getChangeHistory method returns ChangeHistory objects on which you can call the getChangeItems() method. This returns a List of GenericValue objects, each one representing an issue field update. To check the field that was updated do:

String fieldName = changeItem.getString("field")

GenericValues are described in Database schema.

Work logs

Work log entries are kept in the worklog table. For instance, some worklogs in JIRA (from JRA-10393):

are stored in worklog table as:

id

issueid

author

grouplevel

rolelevel

worklogbody

created

updateauthor

updated

timeworked

startdate

83332

38315

mtokar

Implemented method to calculate number of active users + tests

2008-01-22 19:44:04.867-06

mtokar

2008-01-22 19:44:04.867-06

5400

2008-01-22 19:43:00-06

83333

38315

andreask@atlassian.com

Implemented a method to check if the user limit of the license has been exceeded.

2008-01-22 21:33:18.23-06

andreask@atlassian.com

2008-01-22 21:33:18.23-06

7200

2008-01-22 21:31:00-06

83334

38315

andreask@atlassian.com

Added new license types

2008-01-22 23:49:27.794-06

andreask@atlassian.com

2008-01-22 23:51:06.029-06

7200

2008-01-22 23:48:00-06

83335

38315

andreask@atlassian.com

Integrate new license types in JIRA.

2008-01-22 23:51:23.799-06

andreask@atlassian.com

200

where:

  • issueid maps to jiraissue.id
  • timeworked is in seconds

Whenever a worklog entry is added, the jiraissue.timespent and jiraissue.timeestimate values are incremented and decremented respectively.

Users and Groups

Changed:

JIRA 4.3 and higher uses "Embedded Crowd" as its user management framework.
For the old user and group tables, see Database Schema v4.2.

User and Group Tables

Users

Users are stored in the CWD_USER table:

COLUMN_NAME

DATA_TYPE

COMMENTS

ID

NUMBER(18,0)

DIRECTORY_ID

NUMBER(18,0)

Links to CWD_DIRECTORY

USER_NAME

VARCHAR(255)

LOWER_USER_NAME

VARCHAR(255)

used for case-insensitive search

ACTIVE

NUMBER(9,0)

CREATED_DATE

DATE

UPDATED_DATE

DATE

FIRST_NAME

VARCHAR(255)

Not used

LOWER_FIRST_NAME

VARCHAR(255)

Not used

LAST_NAME

VARCHAR(255)

Not used

LOWER_LAST_NAME

VARCHAR(255)

Not used

DISPLAY_NAME

VARCHAR(255)

LOWER_DISPLAY_NAME

VARCHAR(255)

EMAIL_ADDRESS

VARCHAR(255)

LOWER_EMAIL_ADDRESS

VARCHAR(255)

CREDENTIAL

VARCHAR(255)

See also CWD_USER_ATTRIBUTES which stores arbitrary "Attributes" against the User.

Group Tables

The groups are stored in the CWD_GROUP table:

COLUMN_NAME

DATA_TYPE

COMMENTS

ID

NUMBER(18,0)

GROUP_NAME

VARCHAR(255)

LOWER_GROUP_NAME

VARCHAR(255)

used for case-insensitive search

ACTIVE

NUMBER(9,0)

LOCAL

NUMBER(9,0)

CREATED_DATE

DATE

UPDATED_DATE

DATE

DESCRIPTION

VARCHAR(255)

LOWER_DESCRIPTION

VARCHAR(255)

GROUP_TYPE

VARCHAR(60)

DIRECTORY_ID

NUMBER(18,0)

Links to CWD_DIRECTORY

See also CWD_GROUP_ATTRIBUTES which stores arbitrary "Attributes" against the Group.

Group Membership

The CWD_MEMBERSHIP table records which users belong to which groups.
Note that it is also used to store parent/child relationships for nested groups.

COLUMN_NAME

DATA_TYPE

COMMENTS

ID

NUMBER(18,0)

PARENT_ID

NUMBER(18,0)

Parent Group

CHILD_ID

NUMBER(18,0)

User or nested Group ID

MEMBERSHIP_TYPE

VARCHAR(60)

Indicates a Group-User membership or Group-Group membership

GROUP_TYPE

VARCHAR(60)

not used

PARENT_NAME

VARCHAR(255)

Parent Group

LOWER_PARENT_NAME

VARCHAR(255)

used for case-insensitive search

CHILD_NAME

VARCHAR(255)

User or child Group

LOWER_CHILD_NAME

VARCHAR(255)

used for case-insensitive search

DIRECTORY_ID

NUMBER(18,0)

Note that this must match the DirectoryId for the Group and User

User Directories

JIRA can have multiple "User Directories".
The main config is stored in CWD_DIRECTORY

COLUMN_NAME

DATA_TYPE

COMMENTS

ID

NUMBER(18,0)

DIRECTORY_NAME

VARCHAR(255)

LOWER_DIRECTORY_NAME

VARCHAR(255)

CREATED_DATE

DATE

UPDATED_DATE

DATE

ACTIVE

NUMBER(9,0)

DESCRIPTION

VARCHAR(255)

IMPL_CLASS

VARCHAR(255)

LOWER_IMPL_CLASS

VARCHAR(255)

DIRECTORY_TYPE

VARCHAR(60)

Distinguishes Internal, LDAP, Crowd, etc

DIRECTORY_POSITION

VARCHAR(18,0)

Hierarchy of directories

Details and custom settings are stored in CWD_DIRECTORY_ATTRIBUTE.
Available operations (permissions) are stored in CWD_DIRECTORY_OPERATION.

Shadowed Users

Consider a query like:

select user_name, directory_id, display_name, email_address
from cwd_user
where user_name = 'fred'

Normally this should return a single row, however JIRA allows you to set up multiple user directories (eg multiple LDAP directories, or a single LDAP directory mixed with local users).
It is possible that two or more directories contain the same username.
Now the User Directories have a sort hierarchy, and JIRA will only recognise the user in the highest priority directory.
To find which user is in effect, you can change the query to:

select user_name, directory_id, display_name, email_address, dir.directory_position as position
from cwd_user usr
join cwd_directory dir on dir.id = usr.directory_id
where user_name = 'fred'
order by dir.directory_position

The first user in the list is the actual one that JIRA will use.
Any other users are considered as "shadowed" by the first and will be ignored by JIRA.

Watches and Votes

Watches and votes are recorded in the USERASSOCIATION table:

COLUMN_NAME

DATA_TYPE

COMMENTS

SOURCE_NAME

VARCHAR(60)

username

SINK_NODE_ID

NUMBER(18,0)

SINK_NODE_ENTITY

VARCHAR(60)

ASSOCIATION_TYPE

VARCHAR(60)

SEQUENCE

NUMBER(9,0)

For example:

For example, here user 'asmith' is watching issue with id 108433.

Issue status and workflow

This page describes the database tables involved in issue workflow. It will be useful for people who wish to insert issues into the database manually, or diagnose/fix corrupted databases.


JIRA issues have both:

  • a status (Open, Closed, In Progress etc).
  • a workflow step, which governs which transitions are available

Issue status

In the database, the status (Open, Closed etc) is stored on the jiraissue table:

Issue workflow step

Originally JIRA issues only had a status. Then in version 2.0, workflow was added, so that transitions between statuses could be customized. An issue's workflow step is stored in new tables, referenced from jiraissue by the workflow_id:

The TP-1 issue's OS_WFENTRY row indicates that the issue uses the 'jira' (default, built-in) workflow.

The issue's OS_CURRENTSTEP row specifies the issue's current step. The only field really used is STEP_ID. This references a step definition in the workflow:

Icon

The workflow definition for the built-in 'jira' workflow can be seen in atlassian-jira/WEB-INF/classes/jira-workflow.xml

How status and step relate

An issue's status and workflow step are kept in synch:

Status and step are kept in synch is with a workflow post-function (UpdateIssueStatusFunction), which updates the status whenever the step changes.

If the step gets out of synch with the status, then incorrect (or no) workflow operations appear on the issue page. Eg. if OS_CURRENTSTEP.STEP_ID was 6 ("Closed") when jiraissue.issuestatus was 1 ("Open"), then the issue would have only one transition ("Reopen issue") which would break if anyone clicked on it.

Summary of issue status and workflow

  • For each jiraissue row, there is a OS_CURRENTSTEP and OS_WFENTRY row.
  • OS_WFENTRY specifies the applicable workflow. OS_CURRENTSTEP specifies the step in that workflow.
  • The relations are:
    • jiraissue.WORKFLOW_ID == OS_WFENTRY.ID
    • jiraissue.WORKFLOW_ID == OS_CURRENTSTEP.ENTRY_ID

Powered by Confluence and Scroll Viewport