Fix for auto_increment parameter in auto-created tables via checkschema.
Update FeedSub plugin for non-Plugin_DataObject setup and working checkschema updates.
This commit is contained in:
parent
7a2d72fe28
commit
783a2e249b
@ -74,6 +74,7 @@ class ColumnDef
|
|||||||
* @param string $key type of key
|
* @param string $key type of key
|
||||||
* @param value $default default value
|
* @param value $default default value
|
||||||
* @param value $extra unused
|
* @param value $extra unused
|
||||||
|
* @param boolean $auto_increment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($name=null, $type=null, $size=null,
|
function __construct($name=null, $type=null, $size=null,
|
||||||
|
@ -523,6 +523,10 @@ class Schema
|
|||||||
} else {
|
} else {
|
||||||
$sql .= ($cd->nullable) ? "null " : "not null ";
|
$sql .= ($cd->nullable) ? "null " : "not null ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($cd->auto_increment)) {
|
||||||
|
$sql .= " auto_increment ";
|
||||||
|
}
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,11 @@ class FeedSubPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// auto increment seems to be broken
|
|
||||||
function onCheckSchema() {
|
function onCheckSchema() {
|
||||||
|
// warning: the autoincrement doesn't seem to set.
|
||||||
|
// alter table feedinfo change column id id int(11) not null auto_increment;
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
$schema->ensureDataObject('Feedinfo');
|
$schema->ensureTable('feedinfo', Feedinfo::schemaDef());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class FeedDBException extends FeedSubException
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Feedinfo extends Plugin_DataObject
|
class Feedinfo extends Memcached_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'feedinfo';
|
public $__table = 'feedinfo';
|
||||||
|
|
||||||
@ -56,34 +56,90 @@ class Feedinfo extends Plugin_DataObject
|
|||||||
return parent::staticGet(__CLASS__, $k, $v);
|
return parent::staticGet(__CLASS__, $k, $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tableDef()
|
/**
|
||||||
|
* return table definition for DB_DataObject
|
||||||
|
*
|
||||||
|
* DB_DataObject needs to know something about the table to manipulate
|
||||||
|
* instances. This method provides all the DB_DataObject needs to know.
|
||||||
|
*
|
||||||
|
* @return array array of column definitions
|
||||||
|
*/
|
||||||
|
|
||||||
|
function table()
|
||||||
{
|
{
|
||||||
class_exists('Schema'); // autoload hack
|
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
||||||
// warning: the autoincrement doesn't seem to set.
|
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
||||||
// alter table feedinfo change column id id int(11) not null auto_increment;
|
'feeduri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
||||||
return new TableDef($this->__table,
|
'homeuri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
||||||
array(new ColumnDef('id', 'integer',
|
'huburi' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
||||||
null, false, 'PRI', '0', null, true),
|
'verify_token' => DB_DATAOBJECT_STR,
|
||||||
new ColumnDef('profile_id', 'integer',
|
'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
|
||||||
null, false),
|
'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
|
||||||
new ColumnDef('feeduri', 'varchar',
|
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
|
||||||
255, false, 'UNI'),
|
'lastupdate' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
||||||
new ColumnDef('homeuri', 'varchar',
|
}
|
||||||
255, false),
|
|
||||||
new ColumnDef('huburi', 'varchar',
|
static function schemaDef()
|
||||||
255, false),
|
{
|
||||||
new ColumnDef('verify_token', 'varchar',
|
return array(new ColumnDef('id', 'integer',
|
||||||
32, true),
|
/*size*/ null,
|
||||||
new ColumnDef('sub_start', 'datetime',
|
/*nullable*/ false,
|
||||||
null, true),
|
/*key*/ 'PRI',
|
||||||
new ColumnDef('sub_end', 'datetime',
|
/*default*/ '0',
|
||||||
null, true),
|
/*extra*/ null,
|
||||||
new ColumnDef('created', 'datetime',
|
/*auto_increment*/ true),
|
||||||
null, false),
|
new ColumnDef('profile_id', 'integer',
|
||||||
new ColumnDef('lastupdate', 'datetime',
|
null, false),
|
||||||
null, false)));
|
new ColumnDef('feeduri', 'varchar',
|
||||||
|
255, false, 'UNI'),
|
||||||
|
new ColumnDef('homeuri', 'varchar',
|
||||||
|
255, false),
|
||||||
|
new ColumnDef('huburi', 'varchar',
|
||||||
|
255, false),
|
||||||
|
new ColumnDef('verify_token', 'varchar',
|
||||||
|
32, true),
|
||||||
|
new ColumnDef('sub_start', 'datetime',
|
||||||
|
null, true),
|
||||||
|
new ColumnDef('sub_end', 'datetime',
|
||||||
|
null, true),
|
||||||
|
new ColumnDef('created', 'datetime',
|
||||||
|
null, false),
|
||||||
|
new ColumnDef('lastupdate', 'datetime',
|
||||||
|
null, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return key definitions for DB_DataObject
|
||||||
|
*
|
||||||
|
* DB_DataObject needs to know about keys that the table has; this function
|
||||||
|
* defines them.
|
||||||
|
*
|
||||||
|
* @return array key definitions
|
||||||
|
*/
|
||||||
|
|
||||||
|
function keys()
|
||||||
|
{
|
||||||
|
return array('id' => 'P'); //?
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return key definitions for Memcached_DataObject
|
||||||
|
*
|
||||||
|
* Our caching system uses the same key definitions, but uses a different
|
||||||
|
* method to get them.
|
||||||
|
*
|
||||||
|
* @return array key definitions
|
||||||
|
*/
|
||||||
|
|
||||||
|
function keyTypes()
|
||||||
|
{
|
||||||
|
return $this->keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the StatusNet-side profile for this feed
|
||||||
|
* @return Profile
|
||||||
|
*/
|
||||||
public function getProfile()
|
public function getProfile()
|
||||||
{
|
{
|
||||||
return Profile::staticGet('id', $this->profile_id);
|
return Profile::staticGet('id', $this->profile_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user