Skip to content

Commit

Permalink
fix(spanner): replace table when certain fields are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
newtonnthiga committed Jul 18, 2024
1 parent 67aeb7f commit 0412d88
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/spanner/alis_google_spanner_table_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -103,18 +105,30 @@ func (r *spannerTableResource) Schema(_ context.Context, _ resource.SchemaReques
regexp.MustCompile(utils.SpannerPostgresSqlTableIdRegex),
}, "Name must be a valid Spanner Table ID, See https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#naming_conventions"),
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"project": schema.StringAttribute{
Required: true,
Description: "The Google Cloud project ID in which the table belongs.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"instance": schema.StringAttribute{
Required: true,
Description: "The name of the Spanner instance.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"database": schema.StringAttribute{
Required: true,
Description: "The name of the parent database.",
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
},
},
"schema": schema.SingleNestedAttribute{
Required: true,
Expand Down

0 comments on commit 0412d88

Please sign in to comment.