From 029e7b8828adbbe6c68d5f3809abaca5f704ad3c Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 28 Jun 2010 02:05:47 +0000 Subject: #838438 by Damien Tournoud, chx: Added basic tests for D6 => D7 upgrade path, and framework for further extending upgrade test coverage. W00t! :D --- scripts/dump-database-d6.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 scripts/dump-database-d6.sh (limited to 'scripts') diff --git a/scripts/dump-database-d6.sh b/scripts/dump-database-d6.sh new file mode 100644 index 000000000..ff21aedf2 --- /dev/null +++ b/scripts/dump-database-d6.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env php + $data) { + // Remove descriptions to save time and code. + unset($data['description']); + foreach ($data['fields'] as &$field) { + unset($field['description']); + } + + // Dump the table structure. + $output .= "db_create_table('" . $table . "', " . drupal_var_export($data) . ");\n"; + + // Don't output values for those tables. + if (substr($table, 0, 5) == 'cache' || $table == 'sessions' || $table == 'watchdog') { + $output .= "\n"; + continue; + } + + // Prepare the export of values. + $result = db_query('SELECT * FROM {'. $table .'}'); + $insert = ''; + while ($record = db_fetch_array($result)) { + // users.uid is a serial and inserting 0 into a serial can break MySQL. + // So record uid + 1 instead of uid for every uid and once all records + // are in place, fix them up. + if ($table == 'users') { + $record['uid']++; + } + $insert .= '->values('. drupal_var_export($record) .")\n"; + } + + // Dump the values if there are some. + if ($insert) { + $output .= "db_insert('". $table . "')->fields(". drupal_var_export(array_keys($data['fields'])) .")\n"; + $output .= $insert; + $output .= "->execute();\n"; + } + + // Add the statement fixing the serial in the user table. + if ($table == 'users') { + $output .= "db_query('UPDATE {users} SET uid = uid - 1');\n"; + } + + $output .= "\n"; +} + +print $output; -- cgit v1.2.3