Data Layer Applications - Mail Deployment

It is such a simple thing that even asking here makes me feel stupid, but since I have been stuck with this for a long time, I will ask about it here. I am working on a data tier application in a visual studio. I have ordinary things like tables stored by procs and some data after deployment. By default, the data-tier application comes with the Scripts / Post-Deployment folder. Inside this folder is a file called Script.PostDeployment.sql. To be a little more organized, I create folders inside Post-Deployment like StaticData and TestData. My inserts for creating data are localized inside these folders. Therefore, based on this structure, I add the following code to my Script.PostDeployment.sql:

    /*
Post-Deployment Script Template                         
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be appended to the build script.       
 Use SQLCMD syntax to include a file in the post-deployment script.         
 Example:      :r .\myfile.sql                              
 Use SQLCMD syntax to reference a variable in the post-deployment script.       
 Example:      :setvar TableName MyTable                            
               SELECT * FROM [$(TableName)]                 
--------------------------------------------------------------------------------------
*/

:r .\StaticData\States.sql
:r .\TestData\Logins.sql

, . stonnge deploy States.sql Logins.sql / , . - - ? , . , , . !

+3
3

. , SQL 2008 Visual Studio 2010, , , ; , , .

, , , . 100% ( DAC, ), , DAC - Script\Post-deployment; , . , DACCompiler, , post-deployment script .

. - script , , :

• , Script.PostDeployment.sql script. , DAC . , .

, , : r, .

, DACCompiler.

:

, , , - , , ! , , , , ; , , .

, . , , , - Connect.

.

+6

, , , . dacpac - zip , xml SQL-. zip, , . postdeploy.sql - script , .

0

Visual Studio 2013, .

    IF ( '$(DeployType)' = 'Qualification' ) 
    BEGIN --Run scripts 
        PRINT 'Deploying Qualification Specific scripts.'     
        :r .\Qualification\"QualificationSpecificTestScript.sql"
    END 
    ELSE IF ( '$(DeployType)' = 'Production' ) 
    BEGIN --Run scripts 
        PRINT 'Deploying Production Specific scripts.' 
        :r .\Production\"ProductionSpecificTestScript.sql"
    END

QualificationSpecificTestScript.sql ProductionSpecificScript.sql Post Deployment script.

Here is the generated script file (only the relevant section):

     IF ( '$(DeployType)' = 'Qualification' ) 
     BEGIN --Run scripts 
        PRINT 'Deploying Qualification Specific scripts.'     
            begin transaction;
            PRINT 'IN QUALIFICATION ENVIRONMENT POST DEPLOYMENT SCRIPT'
            commit transaction;
     END
     ELSE IF ( '$(DeployType)' = 'Production' ) 
     BEGIN --Run scripts 
        PRINT 'Deploying Production Specific scripts.' 
            begin transaction;
            PRINT 'IN PRODUCTION ENVIRONMENT POST DEPLOYMENT SCRIPT'
            -- TODO:  Confirm this record should be deleted
            --DELETE TB_VariableName where Id = 9514
            commit transaction;
     END
0
source

Source: https://habr.com/ru/post/1794995/


All Articles