CC-3605 : Create 2.1 upgrades

This commit is contained in:
Naomi Aro 2012-04-10 18:07:39 +02:00
parent 3b80c7c018
commit 428d04d77f
7 changed files with 32 additions and 170 deletions

View File

@ -42,7 +42,6 @@ class CcPlaylistTableMap extends TableMap {
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, '');
$this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', false, 6, null);
$this->addColumn('LPTIME', 'DbLPtime', 'TIMESTAMP', false, 6, null);
$this->addForeignKey('CREATOR_ID', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00');

View File

@ -49,12 +49,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $utime;
/**
* The value for the lptime field.
* @var string
*/
protected $lptime;
/**
* The value for the creator_id field.
* @var int
@ -206,39 +200,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
/**
* Get the [optionally formatted] temporal [lptime] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the raw DateTime object will be returned.
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
* @throws PropelException - if unable to parse/validate the date/time value.
*/
public function getDbLPtime($format = 'Y-m-d H:i:s')
{
if ($this->lptime === null) {
return null;
}
try {
$dt = new DateTime($this->lptime);
} catch (Exception $x) {
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lptime, true), $x);
}
if ($format === null) {
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
return $dt;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $dt->format('U'));
} else {
return $dt->format($format);
}
}
/**
* Get the [creator_id] column value.
*
@ -407,55 +368,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this;
} // setDbUtime()
/**
* Sets the value of [lptime] column to a normalized version of the date/time value specified.
*
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
* be treated as NULL for temporal objects.
* @return CcPlaylist The current object (for fluent API support)
*/
public function setDbLPtime($v)
{
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
// -- which is unexpected, to say the least.
if ($v === null || $v === '') {
$dt = null;
} elseif ($v instanceof DateTime) {
$dt = $v;
} else {
// some string/numeric value passed; we normalize that so that we can
// validate it.
try {
if (is_numeric($v)) { // if it's a unix timestamp
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
// We have to explicitly specify and then change the time zone because of a
// DateTime bug: http://bugs.php.net/bug.php?id=43003
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
} else {
$dt = new DateTime($v);
}
} catch (Exception $x) {
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
}
}
if ( $this->lptime !== null || $dt !== null ) {
// (nested ifs are a little easier to read in this case)
$currNorm = ($this->lptime !== null && $tmpDt = new DateTime($this->lptime)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
if ( ($currNorm !== $newNorm) // normalized values don't match
)
{
$this->lptime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
$this->modifiedColumns[] = CcPlaylistPeer::LPTIME;
}
} // if either are not null
return $this;
} // setDbLPtime()
/**
* Set the value of [creator_id] column.
*
@ -564,10 +476,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->lptime = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
$this->description = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->length = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
$this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->resetModified();
$this->setNew(false);
@ -576,7 +487,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 8; // 8 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 7; // 7 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcPlaylist object", $e);
@ -934,15 +845,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->getDbUtime();
break;
case 4:
return $this->getDbLPtime();
break;
case 5:
return $this->getDbCreatorId();
break;
case 6:
case 5:
return $this->getDbDescription();
break;
case 7:
case 6:
return $this->getDbLength();
break;
default:
@ -973,10 +881,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$keys[1] => $this->getDbName(),
$keys[2] => $this->getDbMtime(),
$keys[3] => $this->getDbUtime(),
$keys[4] => $this->getDbLPtime(),
$keys[5] => $this->getDbCreatorId(),
$keys[6] => $this->getDbDescription(),
$keys[7] => $this->getDbLength(),
$keys[4] => $this->getDbCreatorId(),
$keys[5] => $this->getDbDescription(),
$keys[6] => $this->getDbLength(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcSubjs) {
@ -1026,15 +933,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->setDbUtime($value);
break;
case 4:
$this->setDbLPtime($value);
break;
case 5:
$this->setDbCreatorId($value);
break;
case 6:
case 5:
$this->setDbDescription($value);
break;
case 7:
case 6:
$this->setDbLength($value);
break;
} // switch()
@ -1065,10 +969,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDbMtime($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbLPtime($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbDescription($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setDbLength($arr[$keys[7]]);
if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]);
}
/**
@ -1084,7 +987,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if ($this->isColumnModified(CcPlaylistPeer::NAME)) $criteria->add(CcPlaylistPeer::NAME, $this->name);
if ($this->isColumnModified(CcPlaylistPeer::MTIME)) $criteria->add(CcPlaylistPeer::MTIME, $this->mtime);
if ($this->isColumnModified(CcPlaylistPeer::UTIME)) $criteria->add(CcPlaylistPeer::UTIME, $this->utime);
if ($this->isColumnModified(CcPlaylistPeer::LPTIME)) $criteria->add(CcPlaylistPeer::LPTIME, $this->lptime);
if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) $criteria->add(CcPlaylistPeer::CREATOR_ID, $this->creator_id);
if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) $criteria->add(CcPlaylistPeer::LENGTH, $this->length);
@ -1152,7 +1054,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$copyObj->setDbName($this->name);
$copyObj->setDbMtime($this->mtime);
$copyObj->setDbUtime($this->utime);
$copyObj->setDbLPtime($this->lptime);
$copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbDescription($this->description);
$copyObj->setDbLength($this->length);
@ -1405,7 +1306,6 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->name = null;
$this->mtime = null;
$this->utime = null;
$this->lptime = null;
$this->creator_id = null;
$this->description = null;
$this->length = null;

View File

@ -26,7 +26,7 @@ abstract class BaseCcPlaylistPeer {
const TM_CLASS = 'CcPlaylistTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 8;
const NUM_COLUMNS = 7;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -43,9 +43,6 @@ abstract class BaseCcPlaylistPeer {
/** the column name for the UTIME field */
const UTIME = 'cc_playlist.UTIME';
/** the column name for the LPTIME field */
const LPTIME = 'cc_playlist.LPTIME';
/** the column name for the CREATOR_ID field */
const CREATOR_ID = 'cc_playlist.CREATOR_ID';
@ -71,12 +68,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbCreatorId', 'DbDescription', 'DbLength', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbCreatorId', 'dbDescription', 'dbLength', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::LPTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'LPTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'lptime', 'creator_id', 'description', 'length', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
/**
@ -86,12 +83,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbLPtime' => 4, 'DbCreatorId' => 5, 'DbDescription' => 6, 'DbLength' => 7, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbLPtime' => 4, 'dbCreatorId' => 5, 'dbDescription' => 6, 'dbLength' => 7, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::LPTIME => 4, self::CREATOR_ID => 5, self::DESCRIPTION => 6, self::LENGTH => 7, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'LPTIME' => 4, 'CREATOR_ID' => 5, 'DESCRIPTION' => 6, 'LENGTH' => 7, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'lptime' => 4, 'creator_id' => 5, 'description' => 6, 'length' => 7, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
/**
@ -167,7 +164,6 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn(CcPlaylistPeer::NAME);
$criteria->addSelectColumn(CcPlaylistPeer::MTIME);
$criteria->addSelectColumn(CcPlaylistPeer::UTIME);
$criteria->addSelectColumn(CcPlaylistPeer::LPTIME);
$criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID);
$criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION);
$criteria->addSelectColumn(CcPlaylistPeer::LENGTH);
@ -176,7 +172,6 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn($alias . '.NAME');
$criteria->addSelectColumn($alias . '.MTIME');
$criteria->addSelectColumn($alias . '.UTIME');
$criteria->addSelectColumn($alias . '.LPTIME');
$criteria->addSelectColumn($alias . '.CREATOR_ID');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.LENGTH');

View File

@ -10,7 +10,6 @@
* @method CcPlaylistQuery orderByDbName($order = Criteria::ASC) Order by the name column
* @method CcPlaylistQuery orderByDbMtime($order = Criteria::ASC) Order by the mtime column
* @method CcPlaylistQuery orderByDbUtime($order = Criteria::ASC) Order by the utime column
* @method CcPlaylistQuery orderByDbLPtime($order = Criteria::ASC) Order by the lptime column
* @method CcPlaylistQuery orderByDbCreatorId($order = Criteria::ASC) Order by the creator_id column
* @method CcPlaylistQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcPlaylistQuery orderByDbLength($order = Criteria::ASC) Order by the length column
@ -19,7 +18,6 @@
* @method CcPlaylistQuery groupByDbName() Group by the name column
* @method CcPlaylistQuery groupByDbMtime() Group by the mtime column
* @method CcPlaylistQuery groupByDbUtime() Group by the utime column
* @method CcPlaylistQuery groupByDbLPtime() Group by the lptime column
* @method CcPlaylistQuery groupByDbCreatorId() Group by the creator_id column
* @method CcPlaylistQuery groupByDbDescription() Group by the description column
* @method CcPlaylistQuery groupByDbLength() Group by the length column
@ -43,7 +41,6 @@
* @method CcPlaylist findOneByDbName(string $name) Return the first CcPlaylist filtered by the name column
* @method CcPlaylist findOneByDbMtime(string $mtime) Return the first CcPlaylist filtered by the mtime column
* @method CcPlaylist findOneByDbUtime(string $utime) Return the first CcPlaylist filtered by the utime column
* @method CcPlaylist findOneByDbLPtime(string $lptime) Return the first CcPlaylist filtered by the lptime column
* @method CcPlaylist findOneByDbCreatorId(int $creator_id) Return the first CcPlaylist filtered by the creator_id column
* @method CcPlaylist findOneByDbDescription(string $description) Return the first CcPlaylist filtered by the description column
* @method CcPlaylist findOneByDbLength(string $length) Return the first CcPlaylist filtered by the length column
@ -52,7 +49,6 @@
* @method array findByDbName(string $name) Return CcPlaylist objects filtered by the name column
* @method array findByDbMtime(string $mtime) Return CcPlaylist objects filtered by the mtime column
* @method array findByDbUtime(string $utime) Return CcPlaylist objects filtered by the utime column
* @method array findByDbLPtime(string $lptime) Return CcPlaylist objects filtered by the lptime column
* @method array findByDbCreatorId(int $creator_id) Return CcPlaylist objects filtered by the creator_id column
* @method array findByDbDescription(string $description) Return CcPlaylist objects filtered by the description column
* @method array findByDbLength(string $length) Return CcPlaylist objects filtered by the length column
@ -266,37 +262,6 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
return $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime, $comparison);
}
/**
* Filter the query on the lptime column
*
* @param string|array $dbLPtime The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlaylistQuery The current query, for fluid interface
*/
public function filterByDbLPtime($dbLPtime = null, $comparison = null)
{
if (is_array($dbLPtime)) {
$useMinMax = false;
if (isset($dbLPtime['min'])) {
$this->addUsingAlias(CcPlaylistPeer::LPTIME, $dbLPtime['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbLPtime['max'])) {
$this->addUsingAlias(CcPlaylistPeer::LPTIME, $dbLPtime['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcPlaylistPeer::LPTIME, $dbLPtime, $comparison);
}
/**
* Filter the query on the creator_id column
*

View File

@ -224,7 +224,6 @@
<column name="name" phpName="DbName" type="VARCHAR" size="255" required="true" defaultValue=""/>
<column name="mtime" phpName="DbMtime" type="TIMESTAMP" size="6" required="false"/>
<column name="utime" phpName="DbUtime" type="TIMESTAMP" size="6" required="false"/>
<column name="lptime" phpName="DbLPtime" type="TIMESTAMP" size="6" required="false"/>
<column name="creator_id" phpName="DbCreatorId" type="INTEGER" required="false"/>
<column name="description" phpName="DbDescription" type="VARCHAR" size="512" required="false"/>
<column name="length" phpName="DbLength" type="VARCHAR" sqlType="interval" defaultValue="00:00:00"/>

View File

@ -296,7 +296,6 @@ CREATE TABLE "cc_playlist"
"name" VARCHAR(255) default '' NOT NULL,
"mtime" TIMESTAMP(6),
"utime" TIMESTAMP(6),
"lptime" TIMESTAMP(6),
"creator_id" INTEGER,
"description" VARCHAR(512),
"length" interval default '00:00:00',

View File

@ -14,6 +14,11 @@ class Version20120410143340 extends AbstractMigration
$this->_addSql("ALTER TABLE cc_playlist ADD creator_id integer");
$this->_addSql("UPDATE cc_playlist SET creator_id = (SELECT id FROM cc_subjs WHERE creator = login)");
$this->_addSql("ALTER TABLE cc_playlist DROP COLUMN creator");
$this->_addSql("ALTER TABLE cc_playlist ADD CONSTRAINT cc_playlist_createdby_fkey FOREIGN KEY (creator_id) REFERENCES cc_subjs(id) NOT DEFERRABLE INITIALLY IMMEDIATE");
$this->_addSql("ALTER TABLE cc_playlist ADD utime timestamp(6)");
$this->_addSql("ALTER TABLE cc_playlist ADD mtime timestamp(6)");
}
public function down(Schema $schema)