CC-5896: Store cloud files in separate table, inherited from cc_files
Added delete on cascade for cloud files
This commit is contained in:
parent
f6aa2e5a3b
commit
6fa7ddba9a
6 changed files with 12 additions and 9 deletions
|
@ -120,7 +120,7 @@ class CcFilesTableMap extends TableMap
|
|||
$this->addRelation('FkOwner', 'CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null);
|
||||
$this->addRelation('CcSubjsRelatedByDbEditedby', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null);
|
||||
$this->addRelation('CcMusicDirs', 'CcMusicDirs', RelationMap::MANY_TO_ONE, array('directory' => 'id', ), null, null);
|
||||
$this->addRelation('CloudFile', 'CloudFile', RelationMap::ONE_TO_MANY, array('id' => 'cc_file_id', ), null, null, 'CloudFiles');
|
||||
$this->addRelation('CloudFile', 'CloudFile', RelationMap::ONE_TO_MANY, array('id' => 'cc_file_id', ), 'CASCADE', null, 'CloudFiles');
|
||||
$this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcShowInstancess');
|
||||
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcPlaylistcontentss');
|
||||
$this->addRelation('CcBlockcontents', 'CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcBlockcontentss');
|
||||
|
|
|
@ -39,7 +39,7 @@ class CloudFileTableMap extends TableMap
|
|||
$this->setUseIdGenerator(true);
|
||||
$this->setPrimaryKeyMethodInfo('cloud_file_id_seq');
|
||||
// columns
|
||||
$this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null);
|
||||
$this->addColumn('resource_id', 'ResourceId', 'LONGVARCHAR', true, null, null);
|
||||
$this->addForeignKey('cc_file_id', 'CcFileId', 'INTEGER', 'cc_files', 'id', false, null, null);
|
||||
// validators
|
||||
|
@ -50,7 +50,7 @@ class CloudFileTableMap extends TableMap
|
|||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('cc_file_id' => 'id', ), null, null);
|
||||
$this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('cc_file_id' => 'id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
|
|
|
@ -3405,10 +3405,9 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
|
|||
|
||||
if ($this->cloudFilesScheduledForDeletion !== null) {
|
||||
if (!$this->cloudFilesScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cloudFilesScheduledForDeletion as $cloudFile) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cloudFile->save($con);
|
||||
}
|
||||
CloudFileQuery::create()
|
||||
->filterByPrimaryKeys($this->cloudFilesScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->cloudFilesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -700,6 +700,9 @@ abstract class BaseCcFilesPeer
|
|||
*/
|
||||
public static function clearRelatedInstancePool()
|
||||
{
|
||||
// Invalidate objects in CloudFilePeer instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
CloudFilePeer::clearInstancePool();
|
||||
// Invalidate objects in CcShowInstancesPeer instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
CcShowInstancesPeer::clearInstancePool();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue