From 0e6c83e5215f8cf0088ca471d108d6f57ff31174 Mon Sep 17 00:00:00 2001
From: Mikael Nordfeldth <mmn@hethane.se>
Date: Thu, 19 Feb 2015 22:06:43 +0100
Subject: [PATCH] Had to avoid using indexes in the migration phase

File and File_redirection still had their indexes in the temporary migration table definition.
---
 classes/File.php             | 10 ++++++++--
 classes/File_redirection.php |  8 +++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/classes/File.php b/classes/File.php
index c7239777ea..34cd4cdbc7 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -46,7 +46,7 @@ class File extends Managed_DataObject
             'fields' => array(
                 'id' => array('type' => 'serial', 'not null' => true),
                 'urlhash' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'sha256 of destination URL (url field)'),
-                'url' => array('type' => 'text', 'description' => 'destination URL after following redirections'),
+                'url' => array('type' => 'text', 'description' => 'destination URL after following possible redirections'),
                 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'),
                 'size' => array('type' => 'int', 'description' => 'size of resource when available'),
                 'title' => array('type' => 'varchar', 'length' => 191, 'description' => 'title of resource when available'),
@@ -629,8 +629,14 @@ class File extends Managed_DataObject
         $schemadef['fields']['urlhash'] = array (
                                               'type' => 'varchar',
                                               'length' => 64,
-                                              'description' => 'sha256 of destination URL after following redirections',
+                                              'not null' => true,
+                                              'description' => 'sha256 of destination URL (url field)',
                                             );
+        $schemadef['fields']['url'] = array (
+                                              'type' => 'text',
+                                              'description' => 'destination URL after following possible redirections',
+                                            );
+        unset($schemadef['unique keys']);
         $schema->ensureTable($table, $schemadef);
         echo "DONE.\n";
 
diff --git a/classes/File_redirection.php b/classes/File_redirection.php
index ade04fbcbc..8c64c58a80 100644
--- a/classes/File_redirection.php
+++ b/classes/File_redirection.php
@@ -373,8 +373,14 @@ class File_redirection extends Managed_DataObject
         $schemadef['fields']['urlhash'] = array (
                                               'type' => 'varchar',
                                               'length' => 64,
-                                              'description' => 'sha256 of destination URL after following redirections',
+                                              'not null' => true,
+                                              'description' => 'sha256 hash of the URL',
                                             );
+        $schemadef['fields']['url'] = array (
+                                              'type' => 'text',
+                                              'description' => 'short URL (or any other kind of redirect) for file (id)',
+                                            );
+        unset($schemadef['primary key']);
         $schema->ensureTable($table, $schemadef);
         echo "DONE.\n";
 
-- 
2.39.5