The target database contains tables whose names collide with Bitbucket's tables
Asked by Rohit Dalvi:

We migrated our on-premise bitbucket server to AWS Outposts. But we still decided to use our old Microsoft SQL Server. When pointing the old DB to new BitBucket server this is the error we are getting,

```
The target database contains tables whose names collide with Bitbucket's tables. Please migrate to a clean, empty database. For more information about creating a database for use with Bitbucket, please refer to the Bitbucket documentation.	com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:226)	com.atlassian.stash.internal.migration.DefaultDatabaseMigrationService.validateConfiguration(DefaultDatabaseMigrationService.java:85)	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	...
```

Is there a way around to solve this problem without having to create a new empty DB and copy the old DB to it ?

Thank you in advance!


Answers:
author: Rohit Dalvi
body: Thanks [@Nic Brough -Adaptavist-](/t5/user/viewprofilepage/user-id/781454) for your suggestions. I figured out the problem, it was related to the connectivity to domain name. The new server could not connect by using the hostname it needed full hostname. I added that in properties file and everything started working.


author: Nic Brough -Adaptavist-
body: This sounds like you created a new, clean, Bitbucket installation on the AWS machine, but pointed it to an existing database.

This has confused the startup process because it is expecting to be connected to an empty database because it's a new installation of Bitbucket.

It is not hard to fix, the installation stops dead and doesn't do any damage.

You have two routes here broadly, either manually reconfiguring the new install so that it believes it is complete and your old database is valid, or letting it finish the installation with an empty database which you can then discard, and flip it over to the old one.

comments: author: Rohit Dalvi
body: [@Nic Brough -Adaptavist-](/t5/user/viewprofilepage/user-id/781454) how do you make it believe that the installation is complete and old DB is valid ? Since the installation in AWS machine is already done and I can access the user interface where it is asking me to set up the database.


author: Rohit Dalvi
body: I did point the database to internal and once the set up is ready I reconfigured the

bitbucket.properties file to point to the My sql DB and restarted the service but seems like it still does not like it. This is what I get in browser,  

A fatal error has occurred {#toc-hId--1214057463}
-------------------------------------------------

The following problem occurred, which prevents Atlassian Bitbucket from starting:

* SpringMVC dispatcher \[springMvc\] could not be started


author: Nic Brough -Adaptavist-
body: We'd need to see more of the log to see what the underlying error is there.

I can't remember off the top of my head how to fake the installation status, the clean and repoint is what we usually do. I do remember the one time we persevered with it, it involved setting up a second copy from scratch and manually comparing the installation files


author: Nic Brough -Adaptavist-
body: Ok, the error says your database is misconfigured - see "Cannot use default schema name dbo on Microsoft SQL Server because the login schema of the current user (guest) is different and MSSQL does not support setting the default schema per session."


author: Rohit Dalvi
body: The database is actually the same from old BitBucket server. We are just pointing the new server to existing database. So I think the database is configured correctly.


author: Rohit Dalvi
body: Another thing I noticed is, I am seeing this log when the service is started, I am wondering if this is causing the issue ? Does the service needs to be run by root user or any specific user ?

The following issues were found with the mask "u=rwx,g=rx,o=rx" (0022):

- Access is allowed to 'others'. It is recommended that 'others' be denied

all access for security reasons.

The recommended umask for Bitbucket is "u=,g=w,o=rwx" (0027) and can be

configured in _start-webapp.sh


author: Nic Brough -Adaptavist-
body: Sorry, I meant the configuration of the connection to the database - the error message is telling you the user does not have the right access.


author: Rohit Dalvi
body: Hi [@Nic Brough -Adaptavist-](/t5/user/viewprofilepage/user-id/781454) thank you for response. I am attaching the log files, please let me know if there is anything I can try to resolve the issue. Also if you happened to know the work around without creating new empty DB please let me know.

<br />

<br />

ERROR \[spring-startup\] c.a.j.s.w.s.JohnsonDispatcherServlet SpringMVC dispatcher \[springMvc\] could not be started

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'crowdAliasDao': Unsatisfied dependency expressed through method 'setSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sharedHomeLockAcquirer' defined in class path resource \[stash-context.xml\]: Cannot resolve reference to bean 'licenseHelper' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'licenseHelper' defined in URL \[jar:file:/data/atlassian-bitbucket-6.10.0/app/WEB-INF/lib/bitbucket-service-impl-6.10.0.jar!/com/atlassian/stash/internal/license/DefaultLicenseHelper.class\]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapLiquibase' defined in class path resource \[stash-context.xml\]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Cannot use default schema name dbo on Microsoft SQL Server because the login schema of the current user (guest) is different and MSSQL does not support setting the default schema per session.

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:676)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)

at javax.servlet.GenericServlet.init(GenericServlet.java:158)

at java.lang.Thread.run(Thread.java:748)

... 18 frames trimmed

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sharedHomeLockAcquirer' defined in class path resource \[stash-context.xml\]: Cannot resolve reference to bean 'licenseHelper' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'licenseHelper' defined in URL \[jar:file:/data/atlassian-bitbucket-6.10.0/app/WEB-INF/lib/bitbucket-service-impl-6.10.0.jar!/com/atlassian/stash/internal/license/DefaultLicenseHelper.class\]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapLiquibase' defined in class path resource \[stash-context.xml\]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Cannot use default schema name dbo on Microsoft SQL Server because the login schema of the current user (guest) is different and MSSQL does not support setting the default schema per session.

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:314)

... 5 common frames omitted

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'licenseHelper' defined in URL \[jar:file:/data/atlassian-bitbucket-6.10.0/app/WEB-INF/lib/bitbucket-service-impl-6.10.0.jar!/com/atlassian/stash/internal/license/DefaultLicenseHelper.class\]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapLiquibase' defined in class path resource \[stash-context.xml\]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Cannot use default schema name dbo on Microsoft SQL Server because the login schema of the current user (guest) is different and MSSQL does not support setting the default schema per session.

at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)

... 5 common frames omitted

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapLiquibase' defined in class path resource \[stash-context.xml\]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Cannot use default schema name dbo on Microsoft SQL Server because the login schema of the current user (guest) is different and MSSQL does not support setting the default schema per session.

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)

... 5 common frames omitted

Caused by: java.lang.RuntimeException: Cannot use default schema name dbo on Microsoft SQL Server because the login schema of the current user (guest) is different and MSSQL does not support setting the default schema per session.

at liquibase.database.core.MSSQLDatabase.setDefaultSchemaName(MSSQLDatabase.java:118)

at liquibase.database.ExtendedSpringLiquibase.createDatabase(ExtendedSpringLiquibase.java:51)

at liquibase.integration.spring.SpringLiquibase.createLiquibase(SpringLiquibase.java:324)

at liquibase.database.ExtendedSpringLiquibase.afterPropertiesSet(ExtendedSpringLiquibase.java:32)

... 5 common frames omitted


Tags: bitbucket-server

database

server