Commit 1f958abb authored by catch's avatar catch

Issue #2843595 by hussainweb, heddn, jonhattan: Add indexes to migrate_map_* tables

parent 2740e709
......@@ -313,8 +313,10 @@ protected function ensureTables() {
// and map from the source field names to the map/msg field names.
$count = 1;
$source_id_schema = array();
$indexes = [];
foreach ($this->migration->getSourcePlugin()->getIds() as $id_definition) {
$mapkey = 'sourceid' . $count++;
$indexes['source'][] = $mapkey;
$source_id_schema[$mapkey] = $this->getFieldSchema($id_definition);
$source_id_schema[$mapkey]['not null'] = TRUE;
}
......@@ -369,6 +371,7 @@ protected function ensureTables() {
'description' => 'Mappings from source identifier value(s) to destination identifier value(s).',
'fields' => $fields,
'primary key' => array(static::SOURCE_IDS_HASH),
'indexes' => $indexes,
);
$this->getDatabase()->schema()->createTable($this->mapTableName, $schema);
......
......@@ -34,6 +34,10 @@ public function testEnsureTablesNotExist() {
'type' => 'int',
'not null' => TRUE,
);
$fields['sourceid2'] = array(
'type' => 'int',
'not null' => TRUE,
);
$fields['destid1'] = array(
'type' => 'varchar',
'length' => 255,
......@@ -72,6 +76,9 @@ public function testEnsureTablesNotExist() {
'description' => 'Mappings from source identifier value(s) to destination identifier value(s).',
'fields' => $fields,
'primary key' => array('source_ids_hash'),
'indexes' => [
'source' => ['sourceid1', 'sourceid2'],
],
);
$schema = $this->getMockBuilder('Drupal\Core\Database\Schema')
->disableOriginalConstructor()
......@@ -205,6 +212,9 @@ protected function runEnsureTablesTest($schema) {
'source_id_property' => array(
'type' => 'integer',
),
'source_id_property_2' => array(
'type' => 'integer',
),
));
$migration->expects($this->any())
->method('getSourcePlugin')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment