throw new Horde_Exception(Horde_Core_Translation::t("The History system is disabled."));
}
- $ob = Horde_History::factory('Sql', $GLOBALS['conf']['sql']);
- $ob->setLogger($injector->getInstance('Horde_Log_Logger'));
-
- return $ob;
+ return $injector->getInstance('Horde_History_Sql');
}
-
}
protected $_logger;
/**
- * Attempts to return a reference to a concrete History instance.
- *
- * @param string $driver The driver to use.
- * @param array $params Parameters needed for the driver.
- *
- * @return Horde_History The concrete Horde_History reference.
- * @throws Horde_History_Exception
- */
- static public function factory($driver, $params = array())
- {
- $injector = new Horde_Injector(new Horde_Injector_TopLevel());
-
- $injector->bindFactory(
- __CLASS__,
- __CLASS__ . '_Factory',
- 'getHistory'
- );
-
- $config = new stdClass;
- $config->driver = $driver;
- $config->params = $params;
- $injector->setInstance(__CLASS__ . '_Config', $config);
-
- return $injector->getInstance(__CLASS__);
- }
-
- /**
* Set the log handler.
*
* @param Horde_Log_Logger $logger The log handler.
* that entry instead of creating a new one.
*
* @throws Horde_History_Exception
- * @throws InvalidArgumentException
*/
public function log($guid, array $attributes = array(),
$replaceAction = false)
{
if (!is_string($guid)) {
- throw new InvalidArgumentException('The guid needs to be a string!');
+ throw new Horde_History_Exception('The guid needs to be a string!');
}
$history = $this->getHistory($guid);
* @return Horde_History_Log A Horde_History_Log object.
*
* @throws Horde_History_Exception
- * @throws InvalidArgumentException
*/
public function getHistory($guid)
{
if (!is_string($guid)) {
- throw new InvalidArgumentException('The guid needs to be a string!');
+ throw new Horde_History_Exception('The guid needs to be a string!');
}
return $this->_getHistory($guid);
}
* none matched the criteria.
*
* @throws Horde_History_Exception
- * @throws InvalidArgumentException
*/
public function getByTimestamp($cmp, $ts, array $filters = array(),
$parent = null)
{
if (!is_string($cmp)) {
- throw new InvalidArgumentException('The comparison operator needs to be a string!');
+ throw new Horde_History_Exception('The comparison operator needs to be a string!');
}
if (!is_integer($ts)) {
- throw new InvalidArgumentException('The timestamp needs to be an integer!');
+ throw new Horde_History_Exception('The timestamp needs to be an integer!');
}
return $this->_getByTimestamp($cmp, $ts, $filters, $parent);
}
*
* @return integer The timestamp, or 0 if no matching entry is found.
*
- * @throws InvalidArgumentException If the input parameters are not of
- * type string.
+ * @throws Horde_History_Exception If the input parameters are not of type string.
*/
public function getActionTimestamp($guid, $action)
{
if (!is_string($guid) || !is_string($action)) {
- throw new InvalidArgumentException('$guid and $action need to be strings!');
+ throw new Horde_History_Exception('$guid and $action need to be strings!');
}
try {
* @throws Horde_History_Exception
*/
abstract public function removeByNames(array $names);
-
}
+++ /dev/null
-<?php
-/**
- * A factory for history handlers.
- *
- * PHP version 5
- *
- * @category Horde
- * @package History
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=History
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * The Horde_History_Factory:: provides a method for generating
- * a Horde_History handler.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package History
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=History
- */
-class Horde_History_Factory
-{
- /**
- * Creates a concrete Horde_History instance.
- *
- * @param Horde_Injector $injector The environment for creating the
- * instance.
- *
- * @return Horde_History The new Horde_History instance.
- *
- * @throws Horde_History_Exception If the injector provides no
- * configuration.
- */
- static public function getHistory(Horde_Injector $injector)
- {
- try {
- $config = $injector->getInstance('Horde_History_Config');
- } catch (ReflectionException $e) {
- throw new Horde_History_Exception(
- sprintf(
- 'The configuration for the History driver is missing: %s',
- $e->getMessage()
- )
- );
- }
-
- switch (ucfirst($config->driver)) {
- case 'Sql':
- return Horde_History_Factory::getHistorySql($injector, $config->params);
- case 'Mock':
- return Horde_History_Factory::getHistoryMock($config->params);
- default:
- throw new Horde_History_Exception(sprintf("Driver %s not supported!", $config->driver));
- }
- }
-
- /**
- * Creates a concrete Horde_History_Sql instance.
- *
- * @param Horde_Injector $injector The environment for creating the
- * instance.
- * @param array $params The db connection parameters if the
- * environment does not already provide a
- * connection.
- *
- * @return Horde_History_Sql The new Horde_History_Sql instance.
- *
- * @throws Horde_History_Exception If the injector provides no
- * configuration or creating the database
- * connection failed.
- */
- static protected function getHistorySql(Horde_Injector $injector, array $params)
- {
- try {
- /* See if there is a specific write db instance available */
- $write_db = $injector->getInstance('DB_common_write');
- $history = new Horde_History_Sql($write_db);
- try {
- /* See if there is a specific read db instance available */
- $read_db = $injector->getInstance('DB_common_read');
- $history->setReadDb($read_db);
- } catch (ReflectionException $e) {
- }
- } catch (ReflectionException $e) {
- /* No DB instances. Use the configuration. */
- $write_db = Horde_History_Factory::getDb($params);
-
- $history = new Horde_History_Sql($write_db);
-
- /* Check if we need to set up the read DB connection
- * seperately. */
- if (!empty($params['splitread'])) {
- $params = array_merge($params, $params['read']);
- $read_db = Horde_History_Factory::getDb($params);
- $history->setReadDb($read_db);
- }
- }
- return $history;
- }
-
- /**
- * Creates a concrete Horde_History_Mock instance.
- *
- * @param Horde_Injector $injector The environment for creating the
- * instance.
- * @param array $params The db connection parameters if the
- * environment does not already provide a
- * connection.
- *
- * @return Horde_History_Mock The new Horde_History_Mock instance.
- *
- * @throws Horde_History_Exception If the injector provides no
- * configuration or creating the database
- * connection failed.
- */
- static protected function getHistoryMock(array $params)
- {
- return new Horde_History_Mock();
- }
-
- /**
- * Creates a database connection.
- *
- * @param array $params The database connection parameters.
- *
- * @return DB_common
- *
- * @throws Horde_History_Exception In case the database connection failed.
- */
- static protected function getDb(array $params)
- {
- $db = DB::connect($params);
-
- /* Set DB portability options. */
- $portability = DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_ERRORS;
-
- if ($db instanceOf DB_common) {
- if ($db->phptype == 'mssql') {
- $portability |= DB_PORTABILITY_RTRIM;
- }
- $db->setOption('portability', $portability);
- }
- return $db;
- }
-}
class Horde_History_Sql extends Horde_History
{
/**
- * Pointer to a DB instance to manage the history.
+ * Horde_Db_Adapter instance to manage the history.
*
- * @var DB_common
+ * @var Horde_Db_Adapter
*/
protected $_db;
/**
- * Handle for the current database connection, used for writing. Defaults
- * to the same handle as $_db if a separate write database is not
- * required.
- *
- * @var DB_common
- */
- protected $_write_db;
-
- /**
* Constructor.
*
- * @param DB_common $db The database connection.
- *
- * @throws Horde_History_Exception
- */
- public function __construct($db)
- {
- $this->handleError($db);
- $this->_write_db = $db;
- $this->_db = $db;
- }
-
- /**
- * Sets a separate read database connection if you want to split read and
- * write access to the db.
- *
- * @param DB_common $db The database connection.
+ * @param Horde_Db_Adapter $db The database connection.
*
* @throws Horde_History_Exception
*/
- public function setReadDb($db)
+ public function __construct(Horde_Db_Adapter $db, Horde_Log_Logger $logger)
{
- $this->handleError($db);
$this->_db = $db;
+ $this->_logger = $logger;
}
/**
*
* @return integer The timestamp, or 0 if no matching entry is found.
*
- * @throws InvalidArgumentException If the input parameters are not of
- * type string.
+ * @throws Horde_History_Exception If the input parameters are not of type string.
*/
public function getActionTimestamp($guid, $action)
{
if (!is_string($guid) || !is_string($action)) {
- throw new InvalidArgumentException('$guid and $action need to be strings!');
+ throw new Horde_History_Exception('$guid and $action need to be strings!');
}
- $result = $this->_db->getOne('SELECT MAX(history_ts) FROM horde_histories WHERE history_action = ? AND object_uid = ?', array($action, $guid));
try {
- $this->handleError($result);
- } catch (Horde_History_Exception $e) {
+ $result = $this->_db->selectValue('SELECT MAX(history_ts) FROM horde_histories WHERE history_action = ? AND object_uid = ?', array($action, $guid));
+ } catch (Horde_Db_Exception $e) {
return 0;
}
$replaceAction = false)
{
/* If we want to replace an entry with the same action, try and find
- * one. Track whether or not we succeed in $done, so we know whether
- * or not to add the entry later. */
+ * one. Track whether or not we succeed in $done, so we know whether or
+ * not to add the entry later. */
$done = false;
if ($replaceAction && !empty($attributes['action'])) {
foreach ($history as $entry) {
: null;
$values[] = $entry['id'];
- $r = $this->_write_db->query(
- 'UPDATE horde_histories SET history_ts = ?,' .
- ' history_who = ?,' .
- ' history_desc = ?,' .
- ' history_extra = ? WHERE history_id = ?', $values
- );
+ try {
+ $r = $this->_db->update(
+ 'UPDATE horde_histories SET history_ts = ?,' .
+ ' history_who = ?,' .
+ ' history_desc = ?,' .
+ ' history_extra = ? WHERE history_id = ?', $values
+ );
+ } catch (Horde_Db_Exception $e) {
+ if ($this->_logger) {
+ $this->_logger->err($e);
+ throw new Horde_History_Exception($e);
+ }
+ }
- $this->handleError($r);
$done = true;
break;
}
/* If we're not replacing by action, or if we didn't find an entry to
* replace, insert a new row. */
if (!$done) {
- $history_id = $this->_write_db->nextId('horde_histories');
- $this->handleError($history_id);
-
$values = array(
- $history_id,
$history->uid,
$attributes['ts'],
$attributes['who'],
? serialize($attributes)
: null;
- $r = $this->_write_db->query(
- 'INSERT INTO horde_histories (history_id, object_uid, history_ts, history_who, history_desc, history_action, history_extra)' .
- ' VALUES (?, ?, ?, ?, ?, ?, ?)', $values
- );
- $this->handleError($r);
+ try {
+ $this->_db->insert(
+ 'INSERT INTO horde_histories (object_uid, history_ts, history_who, history_desc, history_action, history_extra)' .
+ ' VALUES (?, ?, ?, ?, ?, ?)', $values
+ );
+ } catch (Horde_Db_Exception $e) {
+ if ($this->_logger) {
+ $this->_logger->err($e);
+ throw new Horde_History_Exception($e);
+ }
+ }
}
}
*/
public function _getHistory($guid)
{
- $rows = $this->_db->getAll('SELECT * FROM horde_histories WHERE object_uid = ?', array($guid), DB_FETCHMODE_ASSOC);
- $this->handleError($rows);
+ $rows = $this->_db->selectAll('SELECT * FROM horde_histories WHERE object_uid = ?', array($guid));
return new Horde_History_Log($guid, $rows);
}
$where[] = 'object_uid LIKE ' . $this->_db->quote($parent . ':%');
}
- $result = $this->_db->getAssoc('SELECT DISTINCT object_uid, history_id FROM horde_histories WHERE ' . implode(' AND ', $where));
- $this->handleError($result);
- return $result;
+ return $this->_db->selectAssoc('SELECT DISTINCT object_uid, history_id FROM horde_histories WHERE ' . implode(' AND ', $where));
}
/**
$ids = array();
foreach ($names as $name) {
- $ids[] = $this->_write_db->quote($name);
+ $ids[] = $this->_db->quote($name);
}
- $this->handleError($this->_write_db->query('DELETE FROM horde_histories WHERE object_uid IN (' . implode(',', $ids) . ')'));
- }
-
- /**
- * Determines if the given result is a PEAR error. If it is, logs the event
- * and throws an exception.
- *
- * @param mixed $result The result to check.
- *
- * @throws Horde_History_Exception
- */
- protected function handleError($result)
- {
- if ($result instanceof PEAR_Error) {
- if (!empty($this->_logger)) {
- $this->_logger->error($result->getMessage());
- } else {
- Horde::logMessage($result, 'ERR');
- }
- throw new Horde_History_Exception($result->getMessage());
- }
+ $this->_db->delete('DELETE FROM horde_histories WHERE object_uid IN (' . implode(',', $ids) . ')');
}
}
<dir name="Horde">
<dir name="History">
<file name="Exception.php" role="php" />
- <file name="Factory.php" role="php" />
<file name="Log.php" role="php" />
<file name="Mock.php" role="php" />
<file name="Sql.php" role="php" />
<filelist>
<install as="Horde/History.php" name="lib/Horde/History.php" />
<install as="Horde/History/Exception.php" name="lib/Horde/History/Exception.php" />
- <install as="Horde/History/Factory.php" name="lib/Horde/History/Factory.php" />
<install as="Horde/History/Log.php" name="lib/Horde/History/Log.php" />
<install as="Horde/History/Mock.php" name="lib/Horde/History/Mock.php" />
<install as="Horde/History/Sql.php" name="lib/Horde/History/Sql.php" />
*/
/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
* A test suite for the Horde_History:: interface. DOX format is suggested for
* the PHPUnit test report.
*
*/
class Horde_History_InterfaceTest extends PHPUnit_Framework_TestCase
{
- /** The basic mock environment */
- const ENVIRONMENT_MOCK = 'Mock';
-
- /** The environment using a database */
- const ENVIRONMENT_DB = 'Sql';
-
- /**
- * Path to the temporary sqlite db used for testing the db environment.
- */
- private $_db_file;
-
- /**
- * Test setup.
- */
- public function setUp()
- {
- if (in_array(self::ENVIRONMENT_DB, $this->getEnvironments())) {
- /* PEAR DB is not E_STRICT safe. */
- $this->_errorReporting = error_reporting(E_ALL & ~E_STRICT);
- }
- }
-
- /**
- * Test cleanup.
- */
- public function tearDown()
- {
- if (in_array(self::ENVIRONMENT_DB, $this->getEnvironments())) {
- error_reporting($this->_errorReporting);
- }
- if (!empty($this->_db_file)) {
- unlink($this->_db_file);
- }
- }
-
/**
* Identify the environments we want to run our tests in.
*
if (empty($this->_environments)) {
/* The db environment provides our only test scenario before
* refactoring. */
- $this->_environments = array(
- self::ENVIRONMENT_MOCK,
- /** Uncomment if you want to run a sqlity based test */
- //self::ENVIRONMENT_DB,
- );
+ $this->_environments = array('Mock', 'Sql');
}
return $this->_environments;
}
public function initializeEnvironment($environment)
{
switch ($environment) {
- case self::ENVIRONMENT_DB:
- global $conf;
-
- $this->_db_file = Horde::getTempFile('Horde_Test', false);
- $this->_db = sqlite_open($this->_db_file, '0640');
+ case 'Sql':
$table = <<<EOL
CREATE TABLE horde_histories (
- history_id INT UNSIGNED NOT NULL,
+ history_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
object_uid VARCHAR(255) NOT NULL,
history_action VARCHAR(32) NOT NULL,
history_ts BIGINT NOT NULL,
history_desc TEXT,
history_who VARCHAR(255),
- history_extra TEXT,
---
- PRIMARY KEY (history_id)
-);
+ history_extra TEXT
+)
EOL;
- sqlite_exec($this->_db, $table);
- sqlite_exec($this->_db, 'CREATE INDEX history_action_idx ON horde_histories (history_action);');
- sqlite_exec($this->_db, 'CREATE INDEX history_ts_idx ON horde_histories (history_ts);');
- sqlite_exec($this->_db, 'CREATE INDEX history_uid_idx ON horde_histories (object_uid);');
- sqlite_close($this->_db);
-
- $conf['sql']['database'] = $this->_db_file;
- $conf['sql']['mode'] = '0640';
- $conf['sql']['charset'] = 'utf-8';
- $conf['sql']['phptype'] = 'sqlite';
-
- $injector = new Horde_Injector(new Horde_Injector_TopLevel());
- $injector->bindFactory(
- 'Horde_History',
- 'Horde_History_Factory',
- 'getHistory'
- );
+ $db = new Horde_Db_Adapter_Pdo_Sqlite(array('dbname' => ':memory:'));
+ $db->execute($table);
+ $db->execute('CREATE INDEX history_action_idx ON horde_histories (history_action)');
+ $db->execute('CREATE INDEX history_ts_idx ON horde_histories (history_ts)');
+ $db->execute('CREATE INDEX history_uid_idx ON horde_histories (object_uid)');
- $config = new stdClass;
- $config->driver = 'Sql';
- $config->params = $conf['sql'];
- $injector->setInstance('Horde_History_Config', $config);
- break;
- case self::ENVIRONMENT_MOCK:
- $injector = new Horde_Injector(new Horde_Injector_TopLevel());
- $injector->bindImplementation(
- 'Horde_History',
- 'Horde_History_Mock'
- );
+ $logger = new Horde_Log_Logger(new Horde_Log_Handler_Null());
+
+ return new Horde_History_Sql($db, $logger);
+
+ case 'Mock':
+ return new Horde_History_Mock();
}
- return $injector;
}
/**
public function getHistory($environment)
{
if (!isset($this->_histories[$environment])) {
- $injector = $this->initializeEnvironment($environment);
- $this->_histories[$environment] = $injector->getInstance('Horde_History');
+ $this->_histories[$environment] = $this->initializeEnvironment($environment);
}
return $this->_histories[$environment];
}
- public function testMethodFactoryHasResultHordehistory()
- {
- foreach ($this->getEnvironments() as $environment) {
- $history = $this->getHistory($environment);
- $history1 = Horde_History::factory($environment);
- $this->assertType('Horde_History', $history1);
- $history2 = Horde_History::factory($environment);
- $this->assertType('Horde_History', $history2);
- }
- }
-
public function testMethodLogHasPostConditionThatTimestampAndActorAreAlwaysRecorded()
{
foreach ($this->getEnvironments() as $environment) {
$history = $this->getHistory($environment);
- $history->log('test', array('action' => 'test'));
+ $history->log('test', array('who' => 'me','action' => 'test'));
$this->assertTrue($history->getActionTimestamp('test', 'test') > 0);
$data = $history->getHistory('test');
$this->assertTrue(isset($data[0]['who']));
try {
$history->log(array());
$this->fail('No exception!');
- } catch (InvalidArgumentException $e) {
+ } catch (Horde_History_Exception $e) {
}
}
}
try {
$history->getHistory(array());
$this->fail('No exception!');
- } catch (InvalidArgumentException $e) {
+ } catch (Horde_History_Exception $e) {
}
}
}
try {
$history->getByTimestamp(array(), 1);
$this->fail('No exception!');
- } catch (InvalidArgumentException $e) {
+ } catch (Horde_History_Exception $e) {
}
}
}
try {
$history->getByTimestamp('>', 'hello');
$this->fail('No exception!');
- } catch (InvalidArgumentException $e) {
+ } catch (Horde_History_Exception $e) {
}
}
}
try {
$history->getActionTimestamp(array(), 'test');
$this->fail('No exception!');
- } catch (InvalidArgumentException $e) {
+ } catch (Horde_History_Exception $e) {
}
}
}
try {
$history->getActionTimestamp('test', array());
$this->fail('No exception!');
- } catch (InvalidArgumentException $e) {
+ } catch (Horde_History_Exception $e) {
}
}
}
public function testMethodGetactiontimestampHasResultIntegerZeroIfGethistoryReturnsAnError()
{
- if (!in_array(self::ENVIRONMENT_DB, $this->getEnvironments())) {
- return;
- }
- $injector = $this->initializeEnvironment(self::ENVIRONMENT_DB);
- $mock = new Dummy_Db();
- $injector->setInstance('DB_common_write', $mock);
- $history = $injector->getInstance('Horde_History');
+ $history = $this->getHistory('Sql');
$this->assertEquals(0, $history->getActionTimestamp('test', 'test'));
}
}
}
- public function testHordehistorysqlConvertsPearErrorToHordeexceptions()
+ public function testHordehistorysqlConvertsDbExceptionsToHordeHistoryExceptions()
{
- if (!in_array(self::ENVIRONMENT_DB, $this->getEnvironments())) {
- return;
- }
- $injector = $this->initializeEnvironment(self::ENVIRONMENT_DB);
- $mock = new Dummy_Db();
- $injector->setInstance('DB_common_write', $mock);
- $history = $injector->getInstance('Horde_History');
+ $db = new Horde_Db_Adapter_Pdo_Sqlite(array('dbname' => ':memory:'));
+ $logger = new Horde_Log_Logger(new Horde_Log_Handler_Null());
+ $history = new Horde_History_Sql($db, $logger);
try {
$history->log('test', array('who' => 'me', 'ts' => 1000, 'action' => 'test'));
$this->fail('No exception was thrown!');
} catch (Horde_Exception $e) {
}
-
+
try {
$history->getHistory('test');
$this->fail('No exception was thrown!');
}
}
}
-
-if (!class_exists('DB_common')) {
- class DB_common {}
-}
-
-/**
- * A dummy database connection producing nothing bot errors.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package History
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=History
- */
-class Dummy_Db extends DB_common
-{
- public function &query($query, $params = array())
- {
- $e = new PEAR_Error('Error');
- return $e;
- }
-
- public function nextId($seq_name, $ondemand = true)
- {
- return new PEAR_Error('Error');
- }
-
- public function &getAll($query, $params = array(),
- $fetchmode = DB_FETCHMODE_DEFAULT)
- {
- $e = new PEAR_Error('Error');
- return $e;
- }
-
- public function &getAssoc($query, $force_array = false, $params = array(),
- $fetchmode = DB_FETCHMODE_DEFAULT, $group = false)
- {
- $e = new PEAR_Error('Error');
- return $e;
- }
-}
CREATE TABLE horde_histories (
- history_id INT UNSIGNED NOT NULL,
+ history_id INT UNSIGNED NOT NULL IDENTITY PRIMARY KEY,
object_uid VARCHAR(255) NOT NULL,
history_action VARCHAR(32) NOT NULL,
history_ts BIGINT NOT NULL,
history_desc VARCHAR(MAX),
history_who VARCHAR(255),
- history_extra VARCHAR(MAX),
---
- PRIMARY KEY (history_id)
+ history_extra VARCHAR(MAX)
);
CREATE INDEX history_action_idx ON horde_histories (history_action);
--- /dev/null
+CREATE TABLE horde_histories (
+ history_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ object_uid VARCHAR(255) NOT NULL,
+ history_action VARCHAR(32) NOT NULL,
+ history_ts BIGINT NOT NULL,
+ history_desc TEXT,
+ history_who VARCHAR(255),
+ history_extra TEXT
+);
+
+CREATE INDEX history_action_idx ON horde_histories (history_action);
+CREATE INDEX history_ts_idx ON horde_histories (history_ts);
+CREATE INDEX history_uid_idx ON horde_histories (object_uid);
--- /dev/null
+CREATE TABLE horde_histories (
+ history_id SERIAL PRIMARY KEY,
+ object_uid VARCHAR(255) NOT NULL,
+ history_action VARCHAR(32) NOT NULL,
+ history_ts BIGINT NOT NULL,
+ history_desc TEXT,
+ history_who VARCHAR(255),
+ history_extra TEXT
+);
+
+CREATE INDEX history_action_idx ON horde_histories (history_action);
+CREATE INDEX history_ts_idx ON horde_histories (history_ts);
+CREATE INDEX history_uid_idx ON horde_histories (object_uid);
+++ /dev/null
-CREATE TABLE horde_histories (
- history_id INT UNSIGNED NOT NULL,
- object_uid VARCHAR(255) NOT NULL,
- history_action VARCHAR(32) NOT NULL,
- history_ts BIGINT NOT NULL,
- history_desc TEXT,
- history_who VARCHAR(255),
- history_extra TEXT,
---
- PRIMARY KEY (history_id)
-);
-
-CREATE INDEX history_action_idx ON horde_histories (history_action);
-CREATE INDEX history_ts_idx ON horde_histories (history_ts);
-CREATE INDEX history_uid_idx ON horde_histories (object_uid);