Managing configuration objects in Drupal 8|9 for Migrations 
Tags: drupal, drupal8, drupal9, drupalmigrations
Published: 2020-04-08 01:54:42

---
title: Managing configuration objects in Drupal 8|9 for Migrations 
published: true
description: Tips and Tricks for managing config objects when you're migrating in Drupal. 
tags: drupal, drupal8, drupal9, drupal migrations
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/w5kugk0263qwx5ujn0si.jpg
---
- Image from Unsplash, [user Denis Chick, @drc1948](https://unsplash.com/@drc1948)

## Introduction
Well, I was working in some migrations and I thought that it would be interesting to gather some tools for working with configuration objects, especially from the point of view of Drupal migrations based on a treatment as configuration (not as code).

**You can learn the differences between both approaches (Migration as code or Migration as configuration) in this article:** [https://www.therussianlullaby.com/blog/thinking-about-drupal-migrations-examples](https://www.therussianlullaby.com/blog/thinking-about-drupal-migrations-examples/).

But maybe the most important point right now it's that **if you decide to manage a Drupal Migration as a Configuration entity, then, you'll create a new active configuration Object in your Drupal Installation**. This change all the whole workflow of a single migration as code, due to (now), you're putting your new migration inside the processes and workflows of the Configuration Management System of Drupal. Ok? Let's see. 

I'm working in a basic migration example using a classical .csv file as datasource. I'm building the basic scaffolding in a custom module, with the next structure: 

```txt
/project/web/modules/custom/  
                     \__migration_csv_module/  
                         \__migration_csv_module.info.yml
                          \__csv/
                               \_migration_csv_articles.csv
                           \__config/
                              \__install/
                                 \__migrate_plus.migration.csv_import.yml
```

In order to run the migration using drush commands for migrations, First I will have to load the new active configuration object. Ok. 

You can use the User Interface in path: 
/admin/config/development/configuration/single/export   

![Loading a migration config object](https://dev-to-uploads.s3.amazonaws.com/i/tdc4vlc5552q335o5epf.png)

And finally, if I decide stop the migration and delete the results, I have to eliminate this config object. Let's see some tactics. 

## Auto delete the active config object
When you're working with Drupal migrations as config, then you have to ensure the delete of the new migration-related config object in your Drupal System. **You have to declare your own custom module as a forced dependency of the migration**, and so when you disabled the module, then this config object will disappear.  

**I mean: file** migrate_plus.migration.article_csv_import.yml   
with content: 

```yml
uuid: 1bcec3e7-0a49-4473-87a2-6dca09b91aba
id: article_csv_import
label: 'Migrating articles'
langcode: en
status: true
dependencies:
  enforced:
    module:
      - migration_csv_module
```


## Reviewing configuration objects
You can use this contrib module in order to test and review config:   
[Configuration Inspector Module](https://www.drupal.org/project/config_inspector).  
I didn't know it, but in the context of [this issue](https://www.drupal.org/project/humanstxt/issues/3123129), [Pedro Cambra](https://www.drupal.org/u/pcambra) recommended me to use it.  With this module you'll can review a config: 

![Configuration Inspector Module Feedback](https://dev-to-uploads.s3.amazonaws.com/i/cst9f8dexdrw8alm12gc.png)

## Deleting configuration objects
Also you can use the classical tools from drush and drupal console (both are Drupal CLIs) in order to delete some config objects.

### Using drush    
**:~$** drush config-delete 'migrate_plus.migration.csv_import'   
**:~$** drush config:delete "migrate_plus.migration.csv_import"       
**:~$** drush cdel migrate_plus.migration.csv_import      
 
### Using Drupal Console
**:~$** drupal config:delete active "mymigration.active_config_object"      
**:~$** drupal cd active mymigration.active_config_object     

You can use this contrib module from [Goran Nikolovski](https://www.drupal.org/u/gnikolovski):  
[Config Delete Module](https://www.drupal.org/project/config_delete).  
Just install this module and visit the following page:  
```yml
/admin/config/development/configuration/delete
```
Then you'll be able to select the Config Object and delete it.