From d8960c204afef6bf8f9e29059778ae688fa0d5b1 Mon Sep 17 00:00:00 2001 From: winebarrel Date: Fri, 12 Mar 2021 10:50:01 +0900 Subject: [PATCH] Add ImportDatabase --- mysql/resource_database.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mysql/resource_database.go b/mysql/resource_database.go index 11f273bbb..b0ae28989 100644 --- a/mysql/resource_database.go +++ b/mysql/resource_database.go @@ -22,7 +22,7 @@ func resourceDatabase() *schema.Resource { Read: ReadDatabase, Delete: DeleteDatabase, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + State: ImportDatabase, }, Schema: map[string]*schema.Schema{ "name": { @@ -194,3 +194,13 @@ func extractIdentAfter(sql string, keyword string) string { return "" } + +func ImportDatabase(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + err := ReadDatabase(d, meta) + + if err != nil { + return nil, err + } + + return []*schema.ResourceData{d}, nil +}