Skip to content

Commit 95424d2

Browse files
committed
fix update version and auto-forcenew issue with mysql paytype
1 parent 9051ada commit 95424d2

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
6262
"pay_type": {
6363
Type: schema.TypeInt,
6464
Deprecated: "It has been deprecated from version 1.36.0.",
65-
ForceNew: true,
6665
Optional: true,
6766
ValidateFunc: validateAllowedIntValue([]int{MysqlPayByMonth, MysqlPayByUse}),
6867
ConflictsWith: []string{"charge_type", "prepaid_period"},
@@ -76,6 +75,20 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
7675
ValidateFunc: validateAllowedStringValue([]string{MYSQL_CHARGE_TYPE_PREPAID, MYSQL_CHARGE_TYPE_POSTPAID}),
7776
ConflictsWith: []string{"pay_type", "period"},
7877
Default: MYSQL_CHARGE_TYPE_POSTPAID,
78+
DiffSuppressFunc: func(k, olds, news string, d *schema.ResourceData) bool {
79+
if (olds == "" && news == MYSQL_CHARGE_TYPE_POSTPAID) ||
80+
(olds == MYSQL_CHARGE_TYPE_POSTPAID && news == "") {
81+
if v, ok:= d.GetOkExists("pay_type"); ok&& v.(int) == MysqlPayByUse{
82+
return true
83+
}
84+
}else if(olds == ""&& news == MYSQL_CHARGE_TYPE_PREPAID) ||
85+
(olds == MYSQL_CHARGE_TYPE_PREPAID && news == ""){
86+
if v, ok:= d.GetOkExists("pay_type"); ok&& v.(int) == MysqlPayByMonth{
87+
return true
88+
}
89+
}
90+
return olds == news
91+
},
7992
Description: "Pay type of instance, valid values are `PREPAID`, `POSTPAID`. Default is `POSTPAID`.",
8093
},
8194
"period": {

website/docs/r/mysql_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The following arguments are supported:
6161
* `internet_service` - (Optional) Indicates whether to enable the access to an instance from public network: 0 - No, 1 - Yes.
6262
* `intranet_port` - (Optional) Public access port, rang form 1024 to 65535 and default value is 3306.
6363
* `parameters` - (Optional) List of parameters to use.
64-
* `pay_type` - (Optional, ForceNew, **Deprecated**) It has been deprecated from version 1.36.0. Pay type of instance, 0: prepaid, 1: postpaid.
64+
* `pay_type` - (Optional, **Deprecated**) It has been deprecated from version 1.36.0. Pay type of instance, 0: prepaid, 1: postpaid.
6565
* `period` - (Optional, **Deprecated**) It has been deprecated from version 1.36.0. Period of instance. NOTES: Only supported prepaid instance.
6666
* `prepaid_period` - (Optional) Period of instance. NOTES: Only supported prepaid instance.
6767
* `project_id` - (Optional) Project ID, default value is 0.

website/docs/r/mysql_readonly_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The following arguments are supported:
4343
* `charge_type` - (Optional, ForceNew) Pay type of instance, valid values are `PREPAID`, `POSTPAID`. Default is `POSTPAID`.
4444
* `force_delete` - (Optional) Indicate whether to delete instance directly or not. Default is false. If set true, the instance will be deleted instead of staying recycle bin. Note: only works for `PREPAID` instance. When the main mysql instance set true, this para of the readonly mysql instance will not take effect.
4545
* `intranet_port` - (Optional) Public access port, rang form 1024 to 65535 and default value is 3306.
46-
* `pay_type` - (Optional, ForceNew, **Deprecated**) It has been deprecated from version 1.36.0. Pay type of instance, 0: prepaid, 1: postpaid.
46+
* `pay_type` - (Optional, **Deprecated**) It has been deprecated from version 1.36.0. Pay type of instance, 0: prepaid, 1: postpaid.
4747
* `period` - (Optional, **Deprecated**) It has been deprecated from version 1.36.0. Period of instance. NOTES: Only supported prepaid instance.
4848
* `prepaid_period` - (Optional) Period of instance. NOTES: Only supported prepaid instance.
4949
* `security_groups` - (Optional) Security groups to use.

0 commit comments

Comments
 (0)