Closed (fixed)
Project:
Migrate
Version:
7.x-2.5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2012 at 01:05 UTC
Updated:
18 Apr 2013 at 13:00 UTC
Jump to comment: Most recent file
Hello. I've got a trouble with update to migrate version 2.5. When i tried to migrate new data from source, used earlier, i've got an error message
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rollback_action' in 'field list':
The problem was a prefixed database (i use a "drupal_" table prefix in my database), as i understand.
As i've seen in code (migrate.install), migrate_update_7202 uses a "db_find_tables" function, which does not work with prefixes.
I've made an "ugly hack", using a schema module (schema_unprefix_table) and tablePrefix() function.
Below is a my version of update code.
i am not a professional drupal-programmer, so if someone will find a more "pro"-way to solve this, it would be great.
Hope this will be helpful.
/**
* Add rollback_action field to all map tables
*/
function migrate_update_7202() {
$ret = array();
foreach (db_find_tables(Database::getConnection()->tablePrefix() . 'migrate_map_%') as $tablename) {
if (!db_field_exists(schema_unprefix_table($tablename), 'rollback_action')) {
db_add_field(schema_unprefix_table($tablename), 'rollback_action', array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
));
}
}
$ret[] = t('Added rollback_action column to all map tables');
return $ret;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | migrate-table_prefix_update-1844316-4.patch | 699 bytes | jkruppa |
Comments
Comment #1
mikeryanUnfortunately, there's not much that can be done at this point. I suppose if we fixed it in -dev now, anyone going from, say, 2.4 to 2.6 in the future in a prefixed db would be spared some trouble. But we're certainly not going to introduce a dependency on the schema module just for the sake of an update function.
I'm thinking a better approach would be to pass %migrate_map_% to db_find_tables, then strip anything before migrate_map_ in the resulting table names... I don't have a prefixed environment to test on, though.
Comment #2
drewish commentedRan into a problem with this if you store the map tables in another schema with the source tables. It didn't up
loaddate them.Comment #3
mikeryanBetter late than never... I put the code to add a missing rollback_action column into MigrateSQLMap::ensureTables(), so it will get added before any attempt is made to use it.
Comment #4
jkruppa commentedSame problem here.
Here is a patch inspired from #1, without dependency on the schema module. I'm using a MySQL database, so I couldn't test it with others.
Maybe it can be helpful for someone.