/// <summary> /// Generates the steps required to ensure the database. /// </summary> /// <param name="context"></param> /// <returns></returns> public IEnumerable <SqlDeploymentAction> Compile(SqlDeploymentCompileContext context) { // creates the database if it does not exist yield return(new SqlDeploymentCreateDatabaseAction( context.InstanceName, Name.Expand(context), DefaultDataFilePath?.Expand(context), DefaultLogFilePath?.Expand(context), Overwrite?.Expand <bool>(context) ?? false)); // potentially deploy a DAC package if (Package != null) { foreach (var s in Package.Compile(context, Name.Expand(context))) { yield return(s); } } // potentially alter the owner if (Owner != null) { yield return(new SqlDeploymentDatabaseOwnerAction(context.InstanceName, Name.Expand(context), Owner?.Expand(context))); } // apply any extended properties foreach (var extendedProperty in ExtendedProperties) { foreach (var s in extendedProperty.Compile(context, Name.Expand(context))) { yield return(s); } } // apply any publications foreach (var publication in Publications) { foreach (var s in publication.Compile(context, Name.Expand(context))) { yield return(s); } } // apply any subscriptions foreach (var subscription in Subscriptions) { foreach (var s in subscription.Compile(context, Name.Expand(context))) { yield return(s); } } }