From: Mikael Nordfeldth Date: Thu, 19 Feb 2015 20:21:39 +0000 (+0100) Subject: unique keys and indexes must be NOT NULL or MySQL fucks up X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b54710950f3cfb01f0867e20e4da9e20448d802d;p=quix0rs-gnu-social.git unique keys and indexes must be NOT NULL or MySQL fucks up If this merge throws exception on scripts/upgrade.php and you recently tried a nightly (i.e. during 2015-02-19) then just go back a commit or two and try again. Or delete the duplicate entries. Find the entries like this: SELECT COUNT(*), urlhash FROM file_redirection GROUP BY urlhash HAVING COUNT(*) > 1; then for each urlhash (or come up with a smart SQL query) do: DELETE FROM file_redirection WHERE urlhash='hashfrompreviousquery' LIMIT 1; You'll have to remove duplicates more than once if you have >2 identical urlhash entries. LIMIT -1 might do that for you. I'm not sure. --- diff --git a/classes/File.php b/classes/File.php index b4bf9f9a1f..c7239777ea 100644 --- a/classes/File.php +++ b/classes/File.php @@ -45,7 +45,7 @@ class File extends Managed_DataObject return array( 'fields' => array( 'id' => array('type' => 'serial', 'not null' => true), - 'urlhash' => array('type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'), + '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'), 'mimetype' => array('type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'), 'size' => array('type' => 'int', 'description' => 'size of resource when available'), diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 9309642553..ade04fbcbc 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -43,7 +43,7 @@ class File_redirection extends Managed_DataObject { return array( 'fields' => array( - 'urlhash' => array('type' => 'varchar', 'length' => 64, 'description' => 'sha256 hash of the URL'), + 'urlhash' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'sha256 hash of the URL'), 'url' => array('type' => 'text', 'description' => 'short URL (or any other kind of redirect) for file (id)'), 'file_id' => array('type' => 'int', 'description' => 'short URL for what URL/file'), 'redirections' => array('type' => 'int', 'description' => 'redirect count'),