drupal8 dursh config-import使用簡介
- GIT CLONE 代碼
- 正常流程 stander 安裝drupal8
- 修改/sites/default/settings.php 指定 config 文件夾位置
$config_directories['sync'] = 'sites/config/sync';
- 執行drush命令導入config
drush config-import
提示報錯:
Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in [error]
Drupal\Core\Config\ConfigImporter->validate() (line 728 of
/var/www/spark-crm/core/lib/Drupal/Core/Config/ConfigImporter.php).
The import failed due for the following reasons: [error]
Site UUID in source storage does not match the target storage.
Entities exist of type <em class="placeholder">Shortcut link</em> and <em class="placeholder"></em> <em
class="placeholder">Default</em>. These entities need to be deleted before importing.
- 修復
Site UUID in source storage does not match the target storage.
錯誤
在要導入的config文件夾中找到system.site.yml
文件,複製裡面的uuid值,執行以下drush設置命令
drush cset system.site uuid 4a0b2a69-2df3-4ee3-8936-c6a2a03fc03d
- 修復
Entities exist of type ... These entities need to be deleted before importing.
錯誤
可以在web頁面管理content中刪除相應的內容,也可以執行php代碼
entity_delete_multiple('shortcut', \Drupal::entityQuery('shortcut')->execute());
- 再次執行
drush config-import
命令,成功導入。