From 6a2659ed67577b3f33c5c4d55067744a4b812a06 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 10 Aug 2010 11:45:34 -0700 Subject: [PATCH] Workaround for index setup on SubMirror until I'm done w/ arbitrary index support for Schema setup. --- lib/mysqlschema.php | 2 +- plugins/SubMirror/SubMirrorPlugin.php | 3 +++ plugins/SubMirror/classes/SubMirror.php | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/mysqlschema.php b/lib/mysqlschema.php index 464c718f99..f9552c1dcd 100644 --- a/lib/mysqlschema.php +++ b/lib/mysqlschema.php @@ -333,7 +333,7 @@ class MysqlSchema extends Schema } if (empty($name)) { - $name = "$table_".implode("_", $columnNames)."_idx"; + $name = "{$table}_".implode("_", $columnNames)."_idx"; } $res = $this->conn->query("ALTER TABLE $table ". diff --git a/plugins/SubMirror/SubMirrorPlugin.php b/plugins/SubMirror/SubMirrorPlugin.php index 7289e77938..80c6c5a88f 100644 --- a/plugins/SubMirror/SubMirrorPlugin.php +++ b/plugins/SubMirror/SubMirrorPlugin.php @@ -120,6 +120,9 @@ class SubMirrorPlugin extends Plugin { $schema = Schema::get(); $schema->ensureTable('submirror', SubMirror::schemaDef()); + + // @hack until key definition support is merged + SubMirror::fixIndexes($schema); return true; } diff --git a/plugins/SubMirror/classes/SubMirror.php b/plugins/SubMirror/classes/SubMirror.php index 4e7e005db2..bd8fc80a5f 100644 --- a/plugins/SubMirror/classes/SubMirror.php +++ b/plugins/SubMirror/classes/SubMirror.php @@ -76,6 +76,22 @@ class SubMirror extends Memcached_DataObject null, false)); } + /** + * Temporary hack to set up the compound index, since we can't do + * it yet through regular Schema interface. (Coming for 1.0...) + * + * @param Schema $schema + * @return void + */ + static function fixIndexes($schema) + { + try { + $schema->createIndex('submirror', array('subscribed', 'subscriber')); + } catch (Exception $e) { + common_log(LOG_ERR, __METHOD__ . ': ' . $e->getMessage()); + } + } + /** * return key definitions for DB_DataObject * -- 2.39.5