Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--database/migrations/2017_02_04_025727_add_link_table_indexes.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/database/migrations/2017_02_04_025727_add_link_table_indexes.php b/database/migrations/2017_02_04_025727_add_link_table_indexes.php
index c799a7f..4b6dc2a 100644
--- a/database/migrations/2017_02_04_025727_add_link_table_indexes.php
+++ b/database/migrations/2017_02_04_025727_add_link_table_indexes.php
@@ -20,7 +20,21 @@ class AddLinkTableIndexes extends Migration
$table->index('long_url_hash', 'links_long_url_index');
});
- DB::statement("UPDATE links SET long_url_hash = crc32(long_url);");
+ // MySQL only statement
+ // DB::statement("UPDATE links SET long_url_hash = crc32(long_url);");
+
+ DB::table('links')->select(['id', 'long_url_hash', 'long_url'])
+ ->chunk(100, function($links) {
+ foreach ($links as $link) {
+ DB::table('links')
+ ->where('id', $link->id)
+ ->update([
+ 'long_url_hash' => sprintf('%u', crc32($link->long_url))]
+ );
+ }
+ });
+
+
}
public function down()