0

I try to migrate old blog article to a drupal website here is my migration class :

class Article extends SqlBase {

  /**
   *{@inheritDoc}
   */
  public function query() {
    $query = $this->select('news', 'n')
      ->fields('n', array(
        'id',
        'title',
        'content',
      ));
      return $query;
  }

  /**
   * {@inheritDoc}
   */
  public function fields(){
    $fields = array(
      'id' => $this->t('Autoincrement ID'),
      'title' => $this->t('Article name'),
      'content' => $this->t('HTML content'),
    );
    return $fields;
  }

  /**
   * {@inheritDoc}
   */
  public function getIds() {
    return [
      'id' => [
        'type' => 'integer',
        'alias' => 'n',
      ],
    ];
  }
}

my migrate_plus.migration.article.yml :

#Migration metadata
id: article
label: Migrate list of articles
migration_group: article_migration

#Source plugin, id defined in the @MigrateSource annotation
# in the src/Plugin/migrate/source/Article.php file.
source:
  plugin: article
  key: migrate

 # Process plugin
process:
  title: title
  body: content

# Destination plugin
destination:
  plugin: entity:node
  default_bundle: article



# Nothing needed here, it is a single table without any other relation.
migration_dependencies: {}

when i lunch drush ms i have this :

$ drush migrate-status
 --------------------------------------- ----------------------------------- -------- ------- ---------- ------------- ---------------
  Group                                   Migration ID                        Status   Total   Imported   Unprocessed   Last Imported
 --------------------------------------- ----------------------------------- -------- ------- ---------- ------------- ---------------
  article_migration (article_migration)   article                             Idle     290     0          290

  Default (default)                       block_content_type                  Idle     1       0          1

So the multiple database connection is working yet when i run $ drush migrate-import article

i have that error that i don't understant :

 [error]  Migration failed with source plugin exception: SQLSTATE[42000]: Syntax error or access violation: 1049 Unknown database 'jiyblog2&#039

article migration failed.
  • The error is telling you that it can't find the jiyblog2 DB. Either you're connecting to the wrong DB host or the credentials you're using doesn't allow access to that DB. – Shawn Conn Jul 30 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.