space import error (insert or update on table "spacepermissions" violates foreign key constraint)
Asked by raintuur:

When importing previously exported space I get this error  

<br />

ERROR: insert or update on table "spacepermissions" violates foreign key constraint "someVeryLongKeyBlaBlaBla" Detail: Key (spaceid)=(123456789) is not present in table "spaces".  

note: I changed key constraint value and spaceid  

What does it mean and how to resolve it?  
Do I need to do something special when exporting space. It used to work without any problems.


Answers:
author: Miguel Ramon
body: Reporting I'm running into the same error. This is popping up after I try to import a space exported from a Confluence Cloud instance into another Confluence Cloud instance.

**EDIT:**I've raised a support request on this and will get back here if I learn anything.

**EDIT 2:**Heard back from support, this is a known recent bug impacting the XML export process of the space, documented here:

<https://jira.atlassian.com/browse/CONFCLOUD-76197>

Workaround is to do a CSV export and import that instead.

comments: author: Pronojit Saha
body: I tried the CSV export still getting the same error. Any other options here?


author: Pronojit Saha
body: Getting the exact same issue even with CSV export-import.


author: Nicholas Ayala
body: **Migrating from Server to Cloud**

I am running into this issue as well. Not sure what is going on. I tried this around November of last year for the 8 spaces that have failed due to attachment errors. But now I am getting the error you have reported with the foreign key constraint and I am also (for other spaces) getting the "Transaction rolled back because it has been marked as rollback-only" error.

These are the same exact spaces so I am not sure as to why these are now failing to import. This was the only option I had to migrated these over due to the fact that they continued to fail to migrate through the migration assistant for "Failed to migrate space attachments".

Also since I am going from Server to Cloud there is no CSV option. I only have HTML, XML, and PDF.

*** ** * ** ***

#### **UPDATE (2/29/2024):** {#toc-hId-294157772}

Yea the CSV thing doesnt really work.

**MUST HAVE ORG-ADMIN PERMISSIONS FOR THE SOLUTION BELLOW.**

One option that can work **( I have not tried this myself since my issue is specifically my sandbox )** is doing the **import** into the confluence cloud sandbox instance.

* If they import successfully, you can then use the copy product data feature in admin.atlassian.com

![copyProductData.png](https://community.atlassian.com/t5/image/serverpage/image-id/309440i8D9A1EF7D07E19E0/image-size/large?v=v2&px=999 "copyProductData.png")

* From here you will select the select the source as the sandbox and the destination as your production environment

![confluenceSourceDest.png](https://community.atlassian.com/t5/image/serverpage/image-id/309441i9363708EE206A3A5/image-size/large?v=v2&px=999 "confluenceSourceDest.png")

Select the projects that you have imported to copy over and start. They will notify you once the process is complete.

My specific problem seem to have steemed from corrupted data within my confluence for the specfic projects I had to import. Since they existed before and then they were deleted in order to test the migration again, this had some weird effect on the import. When I did this within a different confluence instance the import worked just fine.


author: Roger
body: I am receiving the same error when attempting to import multiple spaces yesterday and today. Out of 5 spaces none have succeeded, all reporting this same error, or the more generic "Transaction rolled back because it has been marked as rollback-only" with no further information. It seems to sometimes alternate between the two errors upon re-attempts to import the spaces.

comments: author: Nicholas Ayala
body: Hey [@Roger Groom](/t5/user/viewprofilepage/user-id/2298559) ,

Have you tried importing them 1 at a time? I used to get this same error. A lot of the attempts that failed were due to thinking that the space has been deleted (I re-imported several times for testing reasons) but when you delete a space it goes to the trash (soft delete). You need to navigate to trash and remove it there (hard delete). Give it about 5 to 10 minutes and then try again.

If this still doesnt work you can try to import it in a fresh sandbox environment and then try my solution above.


Tags: cloud

confluence-cloud