mapTableName example

->setSettings($field_settings)
      ->getColumns()[$type_parts[1]];

    // Merge back custom settings.     return $schema + $custom_settings;
  }

  /** * {@inheritdoc} */
  public function getRowBySource(array $source_id_values) {
    $query = $this->getDatabase()->select($this->mapTableName(), 'map')
      ->fields('map');
    $query->condition($this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
    $result = $query->execute();
    return $result->fetchAssoc();
  }

  /** * {@inheritdoc} */
  public function getRowByDestination(array $destination_id_values) {
    $query = $this->getDatabase()->select($this->mapTableName(), 'map')
      

  public function testMultipleMigrationWithoutIdConflicts() {
    // Create a node of type page.     $node = Node::create(['type' => 'page', 'title' => 'foo']);
    $node->moderation_state->value = 'published';
    $node->save();

    // Insert data in the d6_node:page migration mapping table to simulate a     // previously migrated node.     $id_map = $this->getMigration('d6_node:page')->getIdMap();
    $table_name = $id_map->mapTableName();
    $id_map->getDatabase()->insert($table_name)
      ->fields([
        'source_ids_hash' => 1,
        'sourceid1' => 1,
        'destid1' => 1,
      ])
      ->execute();

    // Audit the IDs of the d6_node migrations for the page & article node type.     // There should be no conflicts since the highest destination ID should be     // equal to the highest migrated ID, as found in the aggregated mapping
protected function rerunMigration($new_row = []) {
    $title = $this->randomString();
    $source_connection = Database::getConnection('default', 'migrate');
    $source_connection->update('node_revisions')
      ->fields([
        'title' => $title,
        'format' => 2,
      ])
      ->condition('vid', 3)
      ->execute();
    $migration = $this->getMigration('d6_node:story');
    $table_name = $migration->getIdMap()->mapTableName();
    $default_connection = \Drupal::database();
    $default_connection->truncate($table_name)->execute();
    if ($new_row) {
      $hash = $migration->getIdMap()->getSourceIdsHash(['nid' => $new_row['sourceid1']]);
      $new_row['source_ids_hash'] = $hash;
      $default_connection->insert($table_name)
        ->fields($new_row)
        ->execute();
    }
    $this->executeMigration($migration);
    return $title;
  }

  public function testMultipleMigrationWithoutIdConflicts() {
    // Create a node of type page.     $node = Node::create(['type' => 'page', 'title' => 'foo']);
    $node->moderation_state->value = 'published';
    $node->save();

    // Insert data in the d7_node:page migration mapping table to simulate a     // previously migrated node.     $id_map = $this->getMigration('d7_node:page')->getIdMap();
    $table_name = $id_map->mapTableName();
    $id_map->getDatabase()->insert($table_name)
      ->fields([
        'source_ids_hash' => 1,
        'sourceid1' => 1,
        'destid1' => 1,
      ])
      ->execute();

    // Audit the IDs of the d7_node migrations for the page & article node type.     // There should be no conflicts since the highest destination ID should be     // equal to the highest migrated ID, as found in the aggregated mapping
$this->assertEntity('menu-fixedlang', 'is', 'FixedLang', '');

    // Test that we can re-import using the ConfigEntityBase destination.     Database::getConnection('default', 'migrate')
      ->update('menu_custom')
      ->fields(['title' => 'Home Navigation'])
      ->condition('menu_name', 'navigation')
      ->execute();

    $migration = $this->getMigration('d7_menu');
    \Drupal::database()
      ->truncate($migration->getIdMap()->mapTableName())
      ->execute();
    $this->executeMigration($migration);

    $navigation_menu = Menu::load('tools');
    $this->assertSame('Home Navigation', $navigation_menu->label());
  }

}
$this->assertSame('\L\O\N\G l, F j, Y - H:i', $long_date_format->getPattern());

    // Test that we can re-import using the EntityDateFormat destination.     Database::getConnection('default', 'migrate')
      ->update('variable')
      ->fields(['value' => serialize('\S\H\O\R\T d/m/Y - H:i')])
      ->condition('name', 'date_format_short')
      ->execute();

    $migration = $this->getMigration('d6_date_formats');
    \Drupal::database()
      ->truncate($migration->getIdMap()->mapTableName())
      ->execute();

    $this->executeMigration($migration);

    $short_date_format = DateFormat::load('short');
    $this->assertSame('\S\H\O\R\T d/m/Y - H:i', $short_date_format->getPattern());

  }

}

    try {
      $id_map->lookupDestinationIds(['nid' => 1, 'aaa' => '2']);
      $this->fail('Unknown source ID key should throw');
    }
    catch (MigrateException $e) {
      $this->assertEquals("Extra unknown items for map migrate_map_sql_idmap_test in source IDs: array (\n 'aaa' => '2',\n)", $e->getMessage());
    }

    // Verify that we are looking up by source_id_hash when all source IDs are     // passed in.     $id_map->getDatabase()->update($id_map->mapTableName())
      ->condition('sourceid1', 1)
      ->condition('sourceid2', 'en')
      ->fields([TestSqlIdMap::SOURCE_IDS_HASH => uniqid()])
      ->execute();
    $this->assertNotEquals([[101, 'en']]$id_map->lookupDestinationIds([1, 'en']));
  }

  /** * Tests the getRowByDestination method. */
  public function testGetRowByDestination() {
    
/** * Tests the Drupal 6 files to Drupal 8 migration. */
  public function testFiles() {
    $this->assertEntity(1, 'Image1.png', 39325, 'public://image-1.png', 'image/png', 1);
    $this->assertEntity(2, 'Image2.jpg', 1831, 'public://image-2.jpg', 'image/jpeg', 1);
    $this->assertEntity(3, 'image-3.jpg', 1831, 'public://image-3.jpg', 'image/jpeg', 1);
    $this->assertEntity(4, 'html-1.txt', 19, 'public://html-1.txt', 'text/plain', 1);
    // Ensure temporary file was not migrated.     $this->assertNull(File::load(6));

    $map_table = $this->getMigration('d6_file')->getIdMap()->mapTableName();
    $map = \Drupal::database()
      ->select($map_table, 'm')
      ->fields('m', ['sourceid1', 'destid1'])
      ->execute()
      ->fetchAllKeyed();
    $map_expected = [
      // The 4 files from the fixture.       1 => '1',
      2 => '2',
      // The file updated in migrateDumpAlter().       3 => '3',
      
$this->assertSame($expected$navigation_menu->getDescription());

    // Test that we can re-import using the ConfigEntityBase destination.     Database::getConnection('default', 'migrate')
      ->update('menu_custom')
      ->fields(['title' => 'Home Navigation'])
      ->condition('menu_name', 'navigation')
      ->execute();

    $migration = $this->getMigration('d6_menu');
    \Drupal::database()
      ->truncate($migration->getIdMap()->mapTableName())
      ->execute();
    $this->executeMigration($migration);

    $navigation_menu = Menu::load('navigation');
    $this->assertSame('Home Navigation', $navigation_menu->label());
  }

}
$path_alias = $this->loadPathAliasByConditions($conditions);
    $this->assertPath(2, $conditions$path_alias);

    // Test that we can re-import using the UrlAlias destination.     Database::getConnection('default', 'migrate')
      ->update('url_alias')
      ->fields(['dst' => 'new-url-alias'])
      ->condition('src', 'node/2')
      ->execute();

    \Drupal::database()
      ->update($id_map->mapTableName())
      ->fields(['source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE])
      ->execute();
    $migration = $this->getMigration('d6_url_alias');
    $this->executeMigration($migration);

    $path_alias = $this->loadPathAliasByConditions(['id' => $path_alias->id()]);
    $conditions['alias'] = '/new-url-alias';
    $this->assertPath(2, $conditions$path_alias);

    $conditions = [
      'path' => '/node/3',
      

  private function auditEntityComplete(MigrationInterface $migration) {
    $map_table = $migration->getIdMap()->mapTableName();

    $database = \Drupal::database();
    if (!$database->schema()->tableExists($map_table)) {
      throw new \InvalidArgumentException();
    }

    $query = $database->select($map_table, 'map')
      ->fields('map', ['destid2'])
      ->range(0, 1)
      ->orderBy('destid2', 'DESC');
    $max = (int) $query->execute()->fetchField();

    
Home | Imprint | This part of the site doesn't use cookies.