i'm looking switch dacpacs our database changes, i'm bit @ loss when comes more complex database updates. illustrate mean, let me use simple example has same problem.
say have customer table live , want add new customertype table foreign key customer customertype. new column in customer should required (not nullable), should not have default value.
i want use arbitrary formula setup initial type existing customers upon upgrading. how accomplish using dacpac?
the dacpac know there's new column , try add customer table, of course fail because required. setting default value undesirable, allowing null values.
since dacpac should usable upgrade every state latest, don't see kind of configuration or pre/post scripts should setup make work.
various searches have produced disappointing lack of useful results :(
i hope there's here can out. in advance.
the answer vary bit depending on how you're planning deploy dacpac(s). 1 common case having dacpac replace collection of t-sql update scripts executed in sequence update database schema 1 version next. in case might choose have 1 dacpac file each schema-version of database , update database plan publish dacpacs in sequence update database latest version.
in case, it's possible use post-deploy script fix schema appropriate. example scenario, can model database in database project new column specified null , without fk relationship new table. then, in post-deploy script can author t-sql necessary execute update statement fill new table , new column, alter statement change column's type null not null, , add foreign key relationship.
then moving forward can remove post-deploy script , model new column , table proper column type , fk relationship.
Comments
Post a Comment