microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
314 stars 19 forks source link

Import should show warning if the compat level is lower than the compat level in the bacpac #313

Open llali opened 1 year ago

llali commented 1 year ago

Steps to Reproduce:

  1. Create a db in Azure
  2. Create STATISTICS with AUTO_DROP = ON CREATE TABLE tb1 (c1 int NOT NULL); CREATE STATISTICS [stat] ON tb1(c1) WHERE c1 IS NULL WITH FULLSCAN, AUTO_DROP = ON;
  3. Export the database to a bacpac
  4. Import the bacpac to 2019

Expected: import should show a warning if compat level in the bacpac is 160 Actual: export fails with error that AUTO_DROP is not a valid option

Did this occur in prior versions? If not - which version(s) did it work in?

(DacFx/SqlPackage/SSMS/Azure Data Studio)

llali commented 1 year ago

DacFx export and import by default support Azure surface feature set. If an element or property is supported in Azure Dacfx supports export/import it. This means if importing the bacpac which that element/property to an older version of SQL Server, the import might fail. This is by design, but we can make the experience better for user. Azure by default uses Compat level 160. If user export from a db with compat level 160, it's not guarantee the import works on a db with lower compat level (e.g. 2019 is compat level 150). What DacFx can do is include the compat level of soruce database in the bacpac and at import time show a warning with some info of why the import might fail. Changing this bug as a feature task