- 
    
Bug
 - 
    Resolution: Cannot Reproduce
 - 
    
Medium
 
- 
        15
 - 
        Severity 2 - Major
 - 
        
 
NOTE: This bug report is for Confluence Cloud. Using Confluence Server? See the corresponding bug report.
Steps to Reproduce:
- Setup Confluence with Microsoft SQL Server, PostGreSQL or MySQL
 - Create a space
 - Create a page
 - Add restriction into the page you just created
 - Export this space
 - Import the exported space into Confluence instance that use Microsoft SQL Server as its database
 
Expected Results:
Confluence should be able to import this space as it could with Confluence that use PostGreSQL or MySQL database.
Actual Results:
Confluence with MS SQL server will failed to process the space import with the following stack traces:
Caused by: org.xml.sax.SAXException: Error while importing backup: Hibernate operation: could not insert: [com.atlassian.confluence.security.ContentPermission#8323117]; SQL []; Violation of UNIQUE KEY constraint 'cp_unique_user_groups'. Cannot insert duplicate key in object 'dbo.CONTENT_PERM'. The duplicate key value is (8257543, View, <NULL>, <NULL>).; nested exception is java.sql.SQLException: Violation of UNIQUE KEY constraint 'cp_unique_user_groups'. Cannot insert duplicate key in object 'dbo.CONTENT_PERM'. The duplicate key value is (8257543, View, <NULL>, <NULL>). org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not insert: [com.atlassian.confluence.security.ContentPermission#8323117]; SQL []; Violation of UNIQUE KEY constraint 'cp_unique_user_groups'. Cannot insert duplicate key in object 'dbo.CONTENT_PERM'. The duplicate key value is (8257543, View, <NULL>, <NULL>).; nested exception is java.sql.SQLException: Violation of UNIQUE KEY constraint 'cp_unique_user_groups'. Cannot insert duplicate key in object 'dbo.CONTENT_PERM'. The duplicate key value is (8257543, View, <NULL>, <NULL>). at com.atlassian.confluence.importexport.xmlimport.parser.BackupParser.endElement(BackupParser.java:53)
Workaround 1
Remove all page restrictions from the source Confluence before generating the space export. Then re-add the restrictions in the target instance after the import
Workaround 2
- Drop the constraint in the target instance:
ALTER TABLE CONTENT_PERM DROP CONSTRAINT cp_unique_user_groups;
 - Restore the Space
 - Re-add the constraint:
ALTER TABLE CONTENT_PERM ADD CONSTRAINT [cp_unique_user_groups] UNIQUE NONCLUSTERED ( [CPS_ID] ASC, [CP_TYPE] ASC, [USERNAME] ASC, [GROUPNAME] ASC );
 
Workaround 3
Migrate your Confluence database server to other supported database.
- is related to
 - 
                    
CONFSERVER-33777 Space Export Containing Page Restriction Fails during import into Confluence with SQL Server
-         
 - Closed
 
 -