Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-78951

DB migration from Oracle to PostgreSQL, the XML import process fails due to a not-null constraint violation for tables and the Impact table definitions.

XMLWordPrintable

      Issue Summary

      During the migration from Oracle to PostgreSQL, the import process fails due to a not-null constraint violation. It fails with the error: "null value in column 'Column_Name' of relation 'Table_Name' violates not-null constraint."

      Steps to Reproduce

      1. Spin up two instances, one with Oracle and the other with PostgreSQL installed. For PostgreSQL, we need to setup certain configurations, which will be done using the Setup Wizard.
      2. Install apps such as Zyphyr, BigPicture, etc., and create sample data in the application tables.
      3. Take an XML backup from a site with Zephyr installed on the Oracle instance.
      4. Navigate to your instance where PostgreSQL is installed and use this option to open the Setup Wizard on PostgreSQL: https://support.atlassian.com/jira/kb/importing-data-via-setup-wizard/
      5. Click “I’ll set it up myself.”
      6. Click “my own database” and fill out all required fields.
      7. After the Jira tables are created, click “import your data.”
      8. Start the import process.

      Note:- Zephyr Essential (Version:9.7.2.97209927) & Zephyr (Version:11.2.1-jira9)

      Expected Results

      Ideally import should not fail with the given error, as this will change the table descriptions, as it was observed that activeobjects.xml definitions for discrepancies between Oracle and PostgreSQL exports.

      Actual Results

      The following exception is thrown in the atlassian-jira.log file for one of the sample tables:

      2025-07-04 16:25:40,490+0530 JiraImportTaskExecutionThread-1 INFO   [c.a.j.bc.dataimport.DefaultDataImportService] Importing data is 90% complete...
      2025-07-04 16:25:40,523+0530 JiraImportTaskExecutionThread-1 INFO   [c.a.j.bc.dataimport.DefaultDataImportService] Finished storing Generic Values.
      2025-07-04 16:25:40,632+0530 JiraImportTaskExecutionThread-1 DEBUG   [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] startCleaning
      2025-07-04 16:25:40,643+0530 JiraImportTaskExecutionThread-1 DEBUG   [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] stopCleaning
      2025-07-04 16:25:41,735+0530 JiraImportTaskExecutionThread-1 ERROR   [c.a.j.bc.dataimport.DefaultDataImportService] Error during ActiveObjects restore
      com.atlassian.activeobjects.spi.ActiveObjectsImportExportException: There was an error during import/export with <unknown plugin> (table AO_7DEABF_CUSTOM_FIELD):
      	at com.atlassian.activeobjects.backup.ImportExportErrorServiceImpl.newImportExportSqlException(ImportExportErrorServiceImpl.java:26)
      	at com.atlassian.dbexporter.importer.DataImporter$BatchInserter.flush(DataImporter.java:430)
      	at com.atlassian.dbexporter.importer.DataImporter$BatchInserter.close(DataImporter.java:435)
      	at com.atlassian.dbexporter.importer.DataImporter.importTable(DataImporter.java:121)
      	at com.atlassian.dbexporter.importer.DataImporter.access$000(DataImporter.java:42)
      	at com.atlassian.dbexporter.importer.DataImporter$1.call(DataImporter.java:72)
      	at com.atlassian.dbexporter.importer.DataImporter$1.call(DataImporter.java:65)
      	at com.atlassian.dbexporter.jdbc.JdbcUtils.withConnection(JdbcUtils.java:29)
      	at com.atlassian.dbexporter.importer.DataImporter.doImportNode(DataImporter.java:65)
      	at com.atlassian.dbexporter.importer.AbstractImporter.importNode(AbstractImporter.java:49)
      	at com.atlassian.dbexporter.DbImporter.importData(DbImporter.java:73)
      	at com.atlassian.activeobjects.backup.ActiveObjectsBackup.restore(ActiveObjectsBackup.java:170)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.restoreActiveObjects(DefaultDataImportService.java:561)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.performImport(DefaultDataImportService.java:736)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.doImport(DefaultDataImportService.java:323)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.unsafeCall(DataImportAsyncCommand.java:82)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:64)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:30)
      	at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:177)
      	at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:149)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
      	at java.base/java.lang.Thread.run(Thread.java:840)
      Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO public."AO_7DEABF_CUSTOM_FIELD" ("ALIAS_NAME", "CREATED_BY", "CREATED_ON", "CUSTOM_FIELD_TYPE", "DEFAULT_VALUE", "DESCRIPTION", "DISPLAY_FIELD_TYPE", "DISPLAY_NAME", "ID", "IS_ACTIVE", "MODIFIED_BY", "MODIFIED_ON", "NAME", "PROJECT_ID", "ZFJENTITY_TYPE") VALUES ((NULL), ('admin'), ('2025-07-01 17:16:59.641+05:30'), ('NUMBER'), (NULL), (NULL), ('Number Field'), (NULL), ('1'::numeric), ('FALSE'), (NULL), (NULL), ('TEST'), (NULL), ('EXECUTION')) was aborted: ERROR: null value in column "PROJECT_ID" of relation "AO_7DEABF_CUSTOM_FIELD" violates not-null constraint
       Detail: Failing row contains (null, admin, 2025-07-01 17:16:59.641, NUMBER, null, null, Number Field, null, 1, f, null, null, TEST, null, EXECUTION). Call getNextException to see other errors in the batch.
      	at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:165)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2413)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:579)
      	at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:912)
      	at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:936)
      	at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1733)
      	at org.apache.commons.dbcp2.DelegatingStatement.executeBatch(DelegatingStatement.java:241)
      	at org.apache.commons.dbcp2.DelegatingStatement.executeBatch(DelegatingStatement.java:241)
      	at com.atlassian.jira.ofbiz.sql.StatementWrapper.executeBatch(StatementWrapper.java:154)
      	at com.atlassian.jira.diagnostic.connection.DiagnosticPreparedStatement.lambda$executeBatch$17(DiagnosticPreparedStatement.java:146)
      	at com.atlassian.diagnostics.internal.platform.monitor.db.DefaultDatabaseDiagnosticsCollector.recordExecutionTime(DefaultDatabaseDiagnosticsCollector.java:91)
      	at com.atlassian.jira.diagnostic.connection.DatabaseDiagnosticsCollectorDelegate.recordExecutionTime(DatabaseDiagnosticsCollectorDelegate.java:62)
      	at com.atlassian.jira.diagnostic.connection.DiagnosticPreparedStatement.executeBatch(DiagnosticPreparedStatement.java:146)
      	at com.atlassian.dbexporter.importer.DataImporter$BatchInserter.flush(DataImporter.java:423)
      	... 24 more
      Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "PROJECT_ID" of relation "AO_7DEABF_CUSTOM_FIELD" violates not-null constraint
       Detail: Failing row contains (null, admin, 2025-07-01 17:16:59.641, NUMBER, null, null, Number Field, null, 1, f, null, null, TEST, null, EXECUTION).
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2412)
      	... 36 more
      

      Workaround

      • Here is the suggested workaround for the error you observed related to the tables:- 
      1. Export all the Jira data from the source instance (backup file)
      2. Unzip the backup file
      3. Open the activeobjects.xml file from the extracted backup files
      4. Locate the line that corresponds to the database column AO_7DEABF_CUSTOM_FIELD. In the example below, it is line 3.
        <table name="AO_7DEABF_CUSTOM_FIELD">
        ...    
        <column name="PROJECT_ID" primaryKey="false" autoIncrement="true" sqlType="2" precision="20"/> 
         ....
        </table>
        
        
      1. Change this line from autoIncrement="true" to autoIncrement="false" as in the following example:
          <table name="AO_7DEABF_CUSTOM_FIELD">
        ....    
         <column name="PROJECT_ID" primaryKey="false" autoIncrement="false" sqlType="2" precision="20"/>
        ....
          </table>
        
        
      1. Zip the backup files again
      2. Import the changed backup file into the target instance

              Unassigned Unassigned
              4fddfa0e271a Vishal Sharma
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: