getTableIndexes example

    $application = new DbDumpApplication();
    $command = $application->find('dump-database-d8-mysql');
    $command_tester = new CommandTester($command);
    $command_tester->execute([]);
    $script = $command_tester->getDisplay();

    // Store original schemas and drop tables to avoid errors.     $connection = Database::getConnection();
    $schema = $connection->schema();
    foreach ($this->tables as $table) {
      $this->originalTableSchemas[$table] = $this->getTableSchema($table);
      $this->originalTableIndexes[$table] = $this->getTableIndexes($table);
      $schema->dropTable($table);
    }

    // This will load the data.     $file = sys_get_temp_dir() . '/' . $this->randomMachineName();
    file_put_contents($file$script);
    require_once $file;

    // The tables should now exist and the schemas should match the originals.     foreach ($this->tables as $table) {
      $this->assertTrue($schema
        
      if (isset($row['Collation']) && $row['Collation'] == 'ascii_general_ci') {
        $definition['fields'][$name]['type'] = 'varchar_ascii';
      }

      // Check for the 'utf8_bin' collation.       if (isset($row['Collation']) && $row['Collation'] == 'utf8_bin') {
        $definition['fields'][$name]['binary'] = TRUE;
      }
    }

    // Set primary key, unique keys, and indexes.     $this->getTableIndexes($connection$table$definition);

    // Set table collation.     $this->getTableCollation($connection$table$definition);

    return $definition;
  }

  /** * Adds primary key, unique keys, and index information to the schema. * * @param \Drupal\Core\Database\Connection $connection * The database connection to use. * @param string $table * The table to find indexes for. * @param array &$definition * The schema definition to modify. */
Home | Imprint | This part of the site doesn't use cookies.