How to make a plugin create a table in jira database

I've created a jira plugin in my own postgres database. For so, I needed to create a table in the jira database to save some informations (I called it environments). Now I'm trying to integrate it in another Jira software that uses mysql database.

What's really gonna be ideal is to write some script that make my table (environments) to be created automatically. I mean, is there an alternative to not create the table manually? Most of plugins do this but I have no idea how they do it. can anyone suggest me a tutorial or give me some good informations about this?

1 answer

1 accepted

This widget could not be displayed.

Use active objects - the plugins you've seen creating their own tables do it with tables named AO_<plugin key>_name.

See https://developer.atlassian.com/docs/atlassian-platform-common-components/active-objects

Thank you for the fast response. I'll do some reading about this active objects and come back to you. thanks again!

Actually i saw someone who created the table this way:

In entitymodel.xml he adds:

<entity entity-name="EnvTest" table-name="EnvTest" packagename="">
<field name="id" type="numeric"/>
<field name="name" type="long-varchar"/>
<field name="address" col-name="empaddress" type="long-varchar"/>
<field name="company" type="long-varchar"/>
<prim-key field="id"/>
<index name="emp_entity_name">
<index-field name="name"/>
</index>
</entity>

 

and in entitygroup.xml:
<entity-group group="default" entity="EnvTest"/>

 

I tried this but unfortunately this didn't work for me. Can you please tell me the reason why?

That it a really bad way to do it.  This file is used when creating an empty JIRA database and for defining what to read out into an xml backup.  For an existing JIRA, you would need to manually create the table.

You'd then have to implement all the code required to read and write the table, and you would be unsopported by Atlassian.

Use the AO tables, they're not ideal for some uses, but they are the recommended approach.

Hi again,

So I have followed this tutorial you gave me: https://developer.atlassian.com/docs/atlassian-platform-common-components/active-objects/getting-started-with-active-objects

the plugin has been built succesfully and i downloaded it in my jira software but I didn't see any table created

When I run some script to list all the tables in my database (this script: SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;) I do see some tables names starting with AO, one of them is AO_5EFAF5_TODO. But when i run this script for exemple : select * from AO_5EFAF5_TODO;  I get this error : relation "ao_5efaf5_todo" does not exist. 

Okey I'm sorry it's working now!

Thank you so much.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

179 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you