快轉到主要內容

drupal8 dursh config-import使用簡介

285 字1 分鐘00
作者Y Cheung
  • GIT CLONE 代碼
  • 正常流程 stander 安裝drupal8
  • 修改/sites/default/settings.php 指定 config 文件夾位置
1$config_directories['sync'] = 'sites/config/sync';
  • 執行drush命令導入config
1drush config-import

提示報錯:

1Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in                      [error]
2Drupal\Core\Config\ConfigImporter->validate() (line 728 of
3/var/www/spark-crm/core/lib/Drupal/Core/Config/ConfigImporter.php).
4The import failed due for the following reasons:                                                                             [error]
5Site UUID in source storage does not match the target storage.
6Entities exist of type <em class="placeholder">Shortcut link</em> and <em class="placeholder"></em> <em
7class="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設置命令

1drush cset system.site uuid 4a0b2a69-2df3-4ee3-8936-c6a2a03fc03d
  • 修復 Entities exist of type ... These entities need to be deleted before importing. 錯誤

可以在web頁面管理content中刪除相應的內容,也可以執行php代碼

1entity_delete_multiple('shortcut', \Drupal::entityQuery('shortcut')->execute());
  • 再次執行 drush config-import 命令,成功導入。
分享

相關文章

drupal 7中操作遠程oracle數據庫

作者 Y Cheung582 字2 分鐘00

系統環境需求 PHP環境最好是 PHP 7,系統最好是紅帽系。 操作步驟 安裝Oracle Instant Client 在Oracle官網頁面中找到系統對應的客戶端下載安裝,比如 …

Drupal7中自定义表格输入

作者 Y Cheung1240 字3 分鐘00

Drupal默认的节点表单(entity form)输入有时候并不能满足我们的需求,比如我想做一个类似excel表格输入形式的表单呢? = DEMO点这里 (PS. 用 …

↑