How can we help you today? How can we help you today?

Stop SQL Release dropping tables

Is there a way to stop SQL Release dropping tables? Or do we have to create a manual review step to check this?
meh-uk
0

Comments

2 comments

  • PeterG
    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
    PeterG
    0
  • meh-uk
    Thanks, I'll investigate.
    meh-uk
    0

Add comment

Please sign in to leave a comment.