# Database drift

In some cases, you may receive the following error when upgrading from DacPac:

```
Database has drifted from its registered data-tier application
```

When SQLWATCH is deployed, it registers itself as data-tier application, which adds a record in `msdb.dbo.sysdac_instances`.&#x20;

![](https://1837430838-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LamHUpIpVXoBUUDZZpO%2F-Ld_wO8fKTEE3IVdJFE5%2F-Ld_yWpGu1hAAN99AaRo%2Fimage.png?alt=media\&token=4a1e1c69-35c3-4f04-96d5-f5c7d3f32693)

This is userful to identify currently installed version of SQLWATCH.

The error may happen when database objects have been changed since the last deployment, for example, when you deploy SQLWATCH into your existing "dba\_tools" database and add or remove some other tables, not related to SQLWATCH.

## Unregister Data-Tier Application

To work around this issue, we have to unregister data-tier application. This can be done in SQL Server Management Studio:

Right click database -> Tasks -> Delete Data-Tier Application

![](https://1837430838-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LamHUpIpVXoBUUDZZpO%2F-Ld_wO8fKTEE3IVdJFE5%2F-Ld_z7UVa8rJjYLEH4Lj%2Fimage.png?alt=media\&token=b46df844-64fb-46d1-9d90-6e1f273bde3f)

Alternatively, you can use T-SQL to achieve the same:

```
declare @instance_id uniqueidentifier
declare @database_name sysname = 'SQLWATCH'

select @instance_id = instance_id
from msdb.dbo.sysdac_instances dp 
where dp.instance_name = @database_name

exec dbo.sp_sysdac_delete_instance 	
    @instance_id = @instance_id
    
exec dbo.sp_sysdac_update_history_entry 	
    @action_id=21,	
    @instance_id=@instance_id,	
    @action_type=14,	
    @dac_object_type=0,	
    @action_status=2,	
    @dac_object_name_pretran=@database_name,	
    @dac_object_name_posttran=@database_name,	
    @sqlscript=NULL,	
    @error_string=N''
```
