/** * Creates the model's table. * * @return null */ public function createTable() { parent::createTable(); // There's no TemplateCachesRecord – need to set the FK manually craft()->db->createCommand()->addForeignKey($this->getTableName(), 'cacheId', 'templatecaches', 'id', static::CASCADE); }