Options

Stop SQL Release dropping tables

meh-ukmeh-uk Posts: 3 New member
edited June 2, 2016 10:50AM in DLM Automation
Is there a way to stop SQL Release dropping tables? Or do we have to create a manual review step to check this?

Comments

  • Options
    Hi,

    SQL Release will always drop tables if they aren't being source controlled. But you do have some ways to stop it.

    The simplest way is to add a filter that ignores the tables that are being dropped (https://documentation.red-gate.com/disp ... QL+Release), this works if the tables that are being dropped are always the same ones.
    Alternatively you can check all tables into Source Control.

    You can add a manual review step or interrogate the warnings with powershell and stop if there is a table drop:
    $ErrorActionPreference = "Stop"
    
    $db = New-DlmDatabaseConnection -ServerInstance .sql2012 -Database northwind
    $scripts = "C:Northwind"
    
    $release = New-DlmDatabaseRelease -Source $scripts -Target $db
    
    if ($release.Warnings.Details -match "The table S* is being dropped") {
        throw "Table being dropped"
    }
    

    If you mean you want to rename instead of Drop/create you can use Migrations for this https://documentation.red-gate.com/disp ... on+scripts


    Peter Gerrard
    Developer - DLM Automation
    Peter Gerrard

    Software Engineer
    Redgate Software
  • Options
    meh-ukmeh-uk Posts: 3 New member
    Thanks, I'll investigate.
Sign In or Register to comment.