I have read about SqlPackage tool, and I found it amazing, very useful. I'm struggling though to understand how it can work with the following scenario.
I have an Azure SQL DB, let's call it "MyDb", in a production environment, version 1.0. I would like to spin up a new environment. This new environment will a fresh "MyDb" with an updated schema, version 1.5, and no data.
"MyDb" can indeed receive schema updates and I would like to test my application using this DB with data coming from production. I would like to know if SqlPackage can migrate data from "MyDb" v1.0 to "MyDb" v1.5, keeping the schema in the target but migrating the data from source (v1.0) to target (v1.5).
I quickly tested SqlPackage, but it works rather in the opposite direction, basically that "MyDb" v1.0 receives the schema updates from "MyDb" v1.5. This would mean original data is kept and schema updated, but in my opinion the procedure would be cumbersome, with too many steps:
- Create a copy of "MyDb" v1.0 from the production environment in the test environment
- Create a new "MyDb" v1.5 in the test environment;
- Run SqlPackage to apply schema changes, with "MyDb" v1.5 as source and "MyDb" v1.0 as target;
- Destroy "MyDb" v1.5 in the test environment.
Perhaps this is the ideal sequence and I can't expect too much from this tool. In my mind, I thought this would be possible:
- Create a new "MyDb" v1.5 in the test environment;
- SqlPackage updates "MyDb" v1.5 with the data from "MyDb" v1.0 from production environment, keeping the schema in "MyDb" v1.5 intact. It would also "figure out" how to migrate data if there are schema changes, but maybe I'm too optimistic.
Thank you.