Index: mail_edit.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mail_edit/mail_edit.install,v
retrieving revision 1.1.4.3
diff -u -r1.1.4.3 mail_edit.install
--- mail_edit.install	10 Jul 2008 19:28:23 -0000	1.1.4.3
+++ mail_edit.install	7 Dec 2008 17:36:12 -0000
@@ -2,6 +2,12 @@
 // $Id: mail_edit.install,v 1.1.4.3 2008/07/10 19:28:23 litwol Exp $
 
 function mail_edit_install() {
+  if (db_table_exists('mail_edit') && !db_table_exists('mail_edit_registry')) {
+    // This must be a left-over from the (incompatible!) D5 version, see #318324.
+    // We need to handle it as an update:
+    mail_edit_update_6000();
+    return;
+  }
   drupal_install_schema('mail_edit');
 }
 
@@ -45,10 +51,9 @@
         'description' => t(''),
       ),
     ),
+    'primary key' => array('id', 'language'),
     'indexes' => array(
-      '`unique entry`'        => array('`id`', '`language`'),
-      '`id`'        => array('`id`'),
-      '`language`'       => array('`language`'),
+      'language' => array('language'),
     ),
   );
   $schema['mail_edit_registry'] = array(
@@ -79,8 +84,36 @@
         'description' => t(''),
       ),      
     ),
-    '`primary key`' => array('`id`'),
+    'primary key' => array('id'),
   );  
   
   return $schema;
-}
\ No newline at end of file
+}
+
+/**
+ * Do one of two things to install on D6:
+ *  -- If this is an upgrade from a 5.x-1.x installation:
+ *     The D5 {mail_edit} table cannot be migrated to D6, so we move it away and do a full install.
+ *     Modules that have used Mail Editor under D5 can pick up their old records from {mail_edit_D5}.
+ *  -- If we already have an early 6.x-1.x installation, then fix the schema.
+ */
+function mail_edit_update_6000() {
+  $ret = array();
+  if (db_table_exists('mail_edit') && !db_table_exists('mail_edit_registry'))
+  {
+    // We have a D5 installation and need to move the old table out of the way:
+    db_rename_table(&$ret, 'mail_edit', 'mail_edit_d5');
+    if ($ret[0]['success']) {
+      watchdog('mail_edit', 'The %mail_edit table has been renamed to %mail_edit_d5.', array('%mail_edit' => '{mail_edit}', '%mail_edit_d5' => '{mail_edit_d5}'), $severity = WATCHDOG_NOTICE);
+    }
+    $ret = array_merge($ret, drupal_install_schema('mail_edit'));
+  }
+  else {
+    // Fix the schema of the 2008-Oct-08 snapshot release:
+    db_drop_index($ret, 'mail_edit', '`unique entry`');
+    db_drop_index($ret, 'mail_edit', '`id`');
+    db_add_primary_key($ret, 'mail_edit', array('id', 'language'));
+    db_add_primary_key($ret, 'mail_edit_registry', array('id'));
+  }
+  return $ret;
+}
Index: mail_edit.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mail_edit/mail_edit.module,v
retrieving revision 1.4.2.4
diff -u -r1.4.2.4 mail_edit.module
--- mail_edit.module	7 Oct 2008 19:24:39 -0000	1.4.2.4
+++ mail_edit.module	7 Dec 2008 17:36:12 -0000
@@ -13,7 +13,8 @@
   $items = array();
   $items['admin/build/mail-edit'] = array(
     'access arguments' => array('administer site configuration'),
-    'page callback' => 'mail_edit_list',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('mail_edit_list_form'),
     'description' => t('Edit mails being sent out by Drupal.'),
     'title' => t('Mail templates'),
   );
@@ -226,6 +227,16 @@
   }
 }
 
+function mail_edit_list_form() {
+  $form = array();
+  $form['mail_templates'] = array( 
+    '#type' => 'item',
+    '#value' => mail_edit_list(),
+    '#weight' => 0,
+  );
+  return $form;
+}
+
 function mail_edit_list() {
   _mail_edit_include();
   _mail_edit_key_registry_rebuild();      //update mail_edit_registry table
