# Upgrading to 6.0.0

## Database Module

* First upgrade to `5.0.0` - see [upgrade_v5.md](upgrade_v5.md).
* In your Snowflake provider configuration, change `account` to `account_name`, e.g.
  ```hcl
  provider "snowflake" {
    account_name = "orchard"
  }
  ```
* Remove any existing `imports.tf` file
* If `enable_account_roles` is not set or set to `false`:
  * Unset the Snowflake provider version in your `versions.tf` file to use the latest version of the provider.
* If `enable_account_roles` is set to true:
  * Set the Snowflake provider version to `0.100.0` in your `versions.tf` file.
  * Create a new `imports.tf` file and add the following imports to re-import the database-level account roles. If custom role names are used, amend the `id` values accordingly.
    ```hcl
    import {
      to = module.database.snowflake_account_role.db_create_schema_role[0]
      id = "${module.database.database_name}_DB_CREATE_SCHEMA"
    }
    
    import {
      to = module.database.snowflake_account_role.db_read_role[0]
      id = "${module.database.database_name}_DB_READ"
    }
    
    import {
      to = module.database.snowflake_account_role.db_readwrite_role[0]
      id = "${module.database.database_name}_DB_READWRITE"
    }
    ```
  * If schemas are configured, add the following imports to re-import the schema-level account roles:
    ```hcl
    import {
      for_each = { for schema in var.schemas : schema.name => schema if lookup(schema, "create_roles", true) }
    
      to = module.database.snowflake_account_role.schema_read_role[each.key]
      id = coalesce(each.value.read_role_name, "${module.database.database_name}_DB_${each.key}_SCHEMA_READ")
    }
    
    import {
      for_each = { for schema in var.schemas : schema.name => schema if lookup(schema, "create_roles", true) }
    
      to = module.database.snowflake_account_role.schema_readwrite_role[each.key]
      id = coalesce(each.value.read_write_role_name, "${module.database.database_name}_DB_${each.key}_SCHEMA_READWRITE")
    }
    ```
    
## Warehouse Modules

* First upgrade to `5.0.0` - see [upgrade_v5.md](upgrade_v5.md).
* In your Snowflake provider configuration, change `account` to `account_name`, e.g.
  ```hcl
  provider "snowflake" {
    account_name = "orchard"
  }
  ```
* Set the Snowflake provider version to `0.100.0` in your `versions.tf` file.
* Remove any existing `imports.tf` file
* Create a new `imports.tf` file and add an import for each warehouse in the following format:
  ```hcl
  import {
    to = module.warehouse.snowflake_account_role.access_role
    id = "${module.warehouse.name}_WAREHOUSE_ACCESS"
  }
  ```

## Service User Module

* First upgrade to `5.0.0` - see [upgrade_v5.md](upgrade_v5.md).
* In your Snowflake provider configuration, change `account` to `account_name`, e.g.
  ```hcl
  provider "snowflake" {
    account_name = "orchard"
  }
  ```
* Set the Snowflake provider version to `0.100.0` in your `versions.tf` file.
* Remove any existing `imports.tf` file
* Create a new `imports.tf` file and add an import to re-import the service user role. Set the `id` attribute to the name of the service user role.
  ```hcl
  import {
    to = module.service_user.snowflake_account_role.service_user_role
    id = "<ENV>_<SERVICE_NAME>_SERVICE_USER_ROLE"
  }
  ```