Image Assist Repair Script

This post will contain a copy of the T-SQL script that I use(d) to ‘upgrade’ the D7 database to show the images that were placed in the D6 database nodes using the retired Contributed Module Image Assist.

Copying Tables Between Databases

To copy tables between database (on the same server) use this syntax:

CREATE TABLE New Table_name
SELECT * FROM Original Table_name;

So my code snippet is:

CREATE TABLE `xfer_db.image`
SELECT * FROM `cnueu_drpldb.image`;
CREATE TABLE `xfer_db.files`
SELECT * FROM `cnueu_drpldb.files`;

Note to self: try always to create snippets that can be run in phpMyAdmin or in the mysql command shell. Hence one reason to use back ticks to enclose field names in MySQL as shown.

Moving Databases

phpMyAdmin includes import and export facilities but the size of the file is limited by a number of differing locations across the system. Its a real PITA to remember, find and change them all each time I run up a new system on a VM.

So I have opted not to use them, but instead to use command line options where possible. (The one exception is our current hosting service UK2, which doesn’t give SSH access to non-business users.) So I have book marked this location that shows how to do it in the mysql command line (inside a shell).

Then this one shows how to use mysqldump from the shell command line

The nice thing about both of these is ‘>’ dumps out to a file and ‘<' imports from an existing dump file. Where there is no access to a terminal shell, e.g. with SSH then this is possible in the SQL window of phpMyAdmin as well as within a mysql command shell:
use db_name;
source backup-file.sql;


It also occurs to me that this last is also the way to run any script from a command line or within phpMyAdmin.