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

Fix to not drop MySQL and PostgreSQL DB when storage_mb value is changed #1532

Merged
merged 3 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 0 additions & 1 deletion azurerm/resource_arm_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func resourceArmMySqlServer() *schema.Resource {
"storage_mb": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validateIntBetweenDivisibleBy(5120, 4194304, 1024),
},
"backup_retention_days": {
Expand Down
10 changes: 9 additions & 1 deletion azurerm/resource_arm_mysql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,20 @@ func TestAccAzureRMMySQLServer_basicFiveSevenUpdated(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMySQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "B_Gen5_2"),
resource.TestCheckResourceAttr(resourceName, "version", "5.7"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "51200"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMySQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "B_Gen5_1"),
resource.TestCheckResourceAttr(resourceName, "version", "5.7"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
},
Expand Down Expand Up @@ -261,7 +269,7 @@ resource "azurerm_mysql_server" "test" {
}

storage_profile {
storage_mb = 51200
storage_mb = 640000
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}
Expand Down
1 change: 0 additions & 1 deletion azurerm/resource_arm_postgresql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func resourceArmPostgreSQLServer() *schema.Resource {
"storage_mb": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the docs to mention that this is no longer ForceNew? (And above)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about that after I did the initial push. I'll update those now.

Copy link
Collaborator Author

@WodansSon WodansSon Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at the documentation and the original text does not mention that it will ForceNew so I believe this is a no op:

  • storage_mb - (Required) Max storage allowed for a server. Possible values are between 5120 MB(5GB) and 1048576 MB(1TB) for the Basic SKU and between 5120 MB(5GB) and 4194304 MB(4TB) for General Purpose/Memory Optimized SKUs. For more information see the product documentation.

ValidateFunc: validateIntBetweenDivisibleBy(5120, 4194304, 1024),
},

Expand Down
16 changes: 12 additions & 4 deletions azurerm/resource_arm_postgresql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ func TestAccAzureRMPostgreSQLServer_updatePassword(t *testing.T) {
})
}

func TestAccAzureRMPostgreSQLServer_updateSKU(t *testing.T) {
func TestAccAzureRMPostgreSQLServer_updated(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"
ri := acctest.RandInt()
location := testLocation()
config := testAccAzureRMPostgreSQLServer_basicNinePointSix(ri, location)
updatedConfig := testAccAzureRMPostgreSQLServer_basicNinePointSixUpdatedSKU(ri, location)
updatedConfig := testAccAzureRMPostgreSQLServer_basicNinePointSixUpdated(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -185,12 +185,20 @@ func TestAccAzureRMPostgreSQLServer_updateSKU(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPostgreSQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "B_Gen4_2"),
resource.TestCheckResourceAttr(resourceName, "version", "9.6"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "51200"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPostgreSQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "B_Gen4_1"),
resource.TestCheckResourceAttr(resourceName, "version", "9.6"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
},
Expand Down Expand Up @@ -388,7 +396,7 @@ resource "azurerm_postgresql_server" "test" {
`, rInt, location, rInt)
}

func testAccAzureRMPostgreSQLServer_basicNinePointSixUpdatedSKU(rInt int, location string) string {
func testAccAzureRMPostgreSQLServer_basicNinePointSixUpdated(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -408,7 +416,7 @@ resource "azurerm_postgresql_server" "test" {
}

storage_profile {
storage_mb = 51200
storage_mb = 640000
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}
Expand Down