Hi There,
I want to extend the CDbMigration class because I regularly write migrations and I need to generate Uuid records.
So I have a class like this:
class m130829_193947_addasap extends EzyPortalCDbMigration
{
public function up()
{
$this->insert("tbl_address", array(
'active' => '1',
'createdAt' => time(),
'modifiedAt' => time(),
'streetLine1' => '53 Glenvale Crescent',
'streetLine2' => 'Mulgrave',
'suburb' => 'Mulgrave',
'city' => 'Melbourne',
'postcode' => '3170',
'region' => 'Victoria',
'country' => 13,
));
$asapPhysicalAddress_id = Yii::app()->db->getLastInsertID();
$this->addUuid("tbl_address",$asapPhysicalAddress_id);
}
}
And in my other file: EzyPortalCDbMigration
class EzyPortalCDbMigration extends CDbMigration
{
public function addUuid($table, $recordId )
{
require_once 'models/Uuid.php';
require_once 'components/UuidGenerator.php';
$uuid = new Uuid;
$uuid->recordTable = $table;
$uuid->recordId = $recordId;
$uuid->save();
$this->update($table, array('uuid' => $uuid->uuid),'id='.$recordId);
}
}
But yiic migrate doesn’t seem to include the path when I run the migration. How do I include the file without having to put require_once ‘models/EzyPortalCDbMigration.php’; or something in the script? Is there a place where i can set it up? I checked here:
// autoloading model and component classes in main.php
'import'=>array(
'application.models.*',
),
but it doesnt seem to include it.