Hi, I'm getting errors converting a mysql table to an SQLite. It all seems to be related to i18n

    SQLSTATE[HY000]: General error: 1 table block has no column named i18n_mode
    SQLSTATE[HY000]: General error: 1 table locales_target has no column named i18n_status
    SQLSTATE[HY000]: General error: 1 table menu_custom has no column named i18n_mode
    SQLSTATE[HY000]: General error: 1 table menu_links has no column named language
    SQLSTATE[HY000]: General error: 1 table taxonomy_term_data has no column named language
    SQLSTATE[HY000]: General error: 1 table taxonomy_vocabulary has no column named language

Comments

josh waihi’s picture

This looks very similar to #1230430: relation "locales_source" does not exist. From about comment #10.

Please be sure all update hooks have run before you try dbtng_migrator.

Please make this as a duplicate if #1230430: relation "locales_source" does not exist solves your issue.

rwt’s picture

No updates are available and cache was cleared.

#1230430 talks about changing the hook_schema_alter (because i18n adds new columns). How would I do that ?

josh waihi’s picture

LIne 27 of dbtng_migrator.batch.inc:

foreach ($modules as $module) {
    $schema = drupal_get_schema_unprocessed($module);
    _drupal_schema_initialize($schema, $module, FALSE);

    foreach ($schema as $name => $table) {
      db_set_active($destination);
      db_create_table($name, $table);
      $success = db_table_exists($name);

      // So that the locale module doesn't try query the new and
      // incomplete database during t(), we have to revert back to
      // the default database momentarily.
      db_set_active('default');
      if ($success) {
        drupal_set_message(t("@table was successfully created.", array('@table' => $name)));
      }
      else {
        drupal_set_message(t("@table could not be created.", array('@table' => $name)), 'error');
      }
    }
  }

This is the code to create each table in the new database. Which carries out the same task as drupal_install_schema which means the additional columns that i18n adds should also be present.

If you do some debugging around this piece of code, like inspecting the schema after its been generated, it may give indication as to why your issue is occurring.

felubra’s picture

Anyone solved this?

bartl’s picture

I saw the same bug: using drush, migration worked, but using the web admin interface, columns went missing, and the tables remained empty. And I think I got it fixed.

The problem is that the required hook_schema_alter functions were not being executed. And most likely the cause is that these hooks are in module.install files. So the functions simply did not exist, and the statement

drupal_alter('schema', $schema);

could not invoke them.

So what I need to do is load all module.install files.

So in file dbtng_migrator.batch.inc, function dbtng_migrator_batch_initialise_destination, right under line 11, which is

  include_once DRUPAL_ROOT . '/includes/install.inc';

I added the line:

  drupal_load_updates();   // load install files with schema alterations

This is a function defined in includes/install.inc.

I tried to run the migration again via the web interface, and this time it all worked well, for all tables.

josh waihi’s picture

Title: SQLITE Error, missing table column » Run Drupal schema alter hooks on schema installation.
Status: Active » Fixed

Thanks bartl, I've commited a slightly different patch that loads the install files in the same function the schema alter is called so that this should work when using the batch API in the web interface.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.