From d32926e5f70ef81539b7c389351cc5a4a0994e69 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 9 Aug 2012 08:40:56 -0700 Subject: [PATCH] Work-in-progress schema for Facts app Summary: See discussion in D3078 for why I've separated this. Pretty sure it's not quite ready yet -- I want to build a couple of things on it so we have a better idea of what we need (autoincrement ID? primary key? objectB column? valueZ?) and don't need to do a ton of schema patches. Test Plan: Applied patches, ran D3078. Reviewers: vrana, btrahan, majak Reviewed By: vrana CC: aran Maniphest Tasks: T1581, T1562 Differential Revision: https://secure.phabricator.com/D3088 --- resources/sql/patches/fact-raw.sql | 28 +++++++++++++++++++ .../patch/PhabricatorBuiltinPatchList.php | 8 ++++++ 2 files changed, 36 insertions(+) create mode 100644 resources/sql/patches/fact-raw.sql diff --git a/resources/sql/patches/fact-raw.sql b/resources/sql/patches/fact-raw.sql new file mode 100644 index 0000000000..474dfb89c2 --- /dev/null +++ b/resources/sql/patches/fact-raw.sql @@ -0,0 +1,28 @@ +CREATE TABLE {$NAMESPACE}_fact.fact_raw ( + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + `factType` VARCHAR(32) NOT NULL COLLATE utf8_bin, + `objectPHID` VARCHAR(64) NOT NULL COLLATE utf8_bin, + `objectA` VARCHAR(64) NOT NULL COLLATE utf8_bin, + `valueX` BIGINT NOT NULL, + `valueY` BIGINT NOT NULL, + `epoch` INT UNSIGNED NOT NULL, + KEY (objectPHID), + KEY (factType, epoch), + KEY (factType, objectA, epoch) +) ENGINE=InnoDB, COLLATE utf8_general_ci; + +CREATE TABLE {$NAMESPACE}_fact.fact_aggregate ( + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + `factType` VARCHAR(32) NOT NULL COLLATE utf8_bin, + `objectPHID` VARCHAR(64) NOT NULL COLLATE utf8_bin, + `valueX` BIGINT NOT NULL, + UNIQUE KEY (factType, objectPHID), + KEY (factType, valueX) +) ENGINE=InnoDB, COLLATE utf8_general_ci; + +CREATE TABLE {$NAMESPACE}_fact.fact_cursor ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(64) NOT NULL COLLATE utf8_bin, + `position` VARCHAR(64) NOT NULL COLLATE utf8_bin, + UNIQUE KEY (name) +) ENGINE=InnoDB, COLLATE utf8_general_ci; diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index a7473a34a0..ee4ef7dadd 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -159,6 +159,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'db', 'name' => 'cache', ), + 'db.fact' => array( + 'type' => 'db', + 'name' => 'fact', + ), '0000.legacy.sql' => array( 'type' => 'sql', 'name' => $this->getPatchPath('0000.legacy.sql'), @@ -944,6 +948,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'php', 'name' => $this->getPatchPath('migrate-project-edges.php'), ), + 'fact-raw.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('fact-raw.sql'), + ), ); }