Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to Rename SQL database #5009

Merged
merged 9 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ResourceManager/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Added ability to rename database using Set-AzureRmSqlDatabase

## Version 4.0.1
* Fixed assembly loading issue that caused some cmdlets to fail when executing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.15.1.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.1.8.0-preview\lib\net452\Microsoft.Azure.Management.Sql.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.1.10.0-preview\lib\net452\Microsoft.Azure.Management.Sql.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage">
Expand Down Expand Up @@ -263,7 +262,7 @@
<None Include="ScenarioTests\DatabaseCrudStretchTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ServerDnsAliasTests.ps1" >
<None Include="ScenarioTests\ServerDnsAliasTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ServerUpgradeTests.ps1">
Expand Down Expand Up @@ -668,6 +667,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseRemove.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseRename.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -989,16 +991,16 @@
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.VirtualNetworkRuleTest\TestVirtualNetworkRuleRemove.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestCreateServerDnsAlias.json">
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestCreateServerDnsAlias.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestServerDnsAliasGet.json">
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestServerDnsAliasGet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestServerDnsAliasUpdate.json">
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestServerDnsAliasUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestServerDnsAliasRemove.json">
<None Include=".\SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDnsAliasTests\TestServerDnsAliasRemove.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public void TestDatabaseUpdateWithZoneRedundancyNotSpecified()
RunPowerShellTest("Test-UpdateDatabaseWithZoneRedundantNotSpecified");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseRename()
{
RunPowerShellTest("Test-RenameDatabase");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseGet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,48 @@ function Test-UpdateDatabaseWithZoneRedundantNotSpecified ()
}
}

<#
.SYNOPSIS
Tests renaming a database
#>
function Test-RenameDatabase
{
# Setup
$rg = Create-ResourceGroupForTest

try
{
$location = "westcentralus"
$server = Create-ServerForTest $rg $location

# Create with default values
$databaseName = Get-DatabaseName
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -MaxSizeBytes 1GB
Assert-AreEqual $db1.DatabaseName $databaseName

# Rename with params
$name2 = "name2"
$db2 = Set-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -NewName $name2
Assert-AreEqual $db2.DatabaseName $name2

Assert-ThrowsContains -script { $db1 | Get-AzureRmSqlDatabase } -message "not found"
$db2 | Get-AzureRmSqlDatabase

# Rename with piping
$name3 = "name3"
$db3 = $db2 | Set-AzureRmSqlDatabase -NewName $name3
Assert-AreEqual $db3.DatabaseName $name3

Assert-ThrowsContains -script { $db1 | Get-AzureRmSqlDatabase } -message "not found"
Assert-ThrowsContains -script { $db2 | Get-AzureRmSqlDatabase } -message "not found"
$db3 | Get-AzureRmSqlDatabase
}
finally
{
Remove-ResourceGroupForTest $rg
}
}


<#
.SYNOPSIS
Expand Down
Loading