blob: 9d8ede59b794259d7183d97ee1450ef243f93233 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
class HashOpengraphTable extends Migration
{
public function up()
{
//Prevent duplicate entries in one of the following queries
//by deleting all entries in the opengraphdata table:
DBManager::get()->exec("DELETE FROM `opengraphdata`");
$query = "ALTER TABLE `opengraphdata`
ADD COLUMN `hash` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' AFTER `opengraph_id`";
DBManager::get()->exec($query);
$query = "UPDATE `opengraphdata` SET `hash` = MD5(`url`)";
DBManager::get()->exec($query);
$query = "ALTER TABLE `opengraphdata`
DROP INDEX `url`,
ADD UNIQUE KEY `hash` (`hash`)";
DBManager::get()->exec($query);
}
public function down()
{
$query = "ALTER TABLE `opengraphdata`
DROP COLUMN `hash`,
ADD UNIQUE INDEX `url` (`url`(512))";
DBManager::get()->exec($query);
}
}
|