diff --git a/helper/schema/resource.go b/helper/schema/resource.go index cc759e0d6c40..571fe18a6038 100644 --- a/helper/schema/resource.go +++ b/helper/schema/resource.go @@ -119,7 +119,7 @@ func (r *Resource) Apply( if s.ID != "" { // Destroy the resource since it is created if err := r.Delete(data, meta); err != nil { - return data.State(), err + return r.recordCurrentSchemaVersion(data.State()), err } // Make sure the ID is gone. diff --git a/helper/schema/resource_test.go b/helper/schema/resource_test.go index b27bd193a2b5..e35979eb2f16 100644 --- a/helper/schema/resource_test.go +++ b/helper/schema/resource_test.go @@ -180,6 +180,7 @@ func TestResourceApply_destroyPartial(t *testing.T) { Optional: true, }, }, + SchemaVersion: 3, } r.Delete = func(d *ResourceData, m interface{}) error { @@ -209,10 +210,13 @@ func TestResourceApply_destroyPartial(t *testing.T) { "id": "bar", "foo": "42", }, + Meta: map[string]string{ + "schema_version": "3", + }, } if !reflect.DeepEqual(actual, expected) { - t.Fatalf("bad: %#v", actual) + t.Fatalf("expected:\n%#v\n\ngot:\n%#v", expected, actual) } }