'name' => 'Extension',
'class' => 'CRM_Core_DAO_Extension',
'table' => 'civicrm_extension',
- ],
- 'CRM_Core_DAO_File' => [
- 'name' => 'File',
- 'class' => 'CRM_Core_DAO_File',
- 'table' => 'civicrm_file',
- ],
- 'CRM_Core_DAO_LocationType' => [
+ ) ,
+ 'CRM_Core_DAO_LocationType' => array(
'name' => 'LocationType',
'class' => 'CRM_Core_DAO_LocationType',
'table' => 'civicrm_location_type',
'name' => 'Email',
'class' => 'CRM_Core_DAO_Email',
'table' => 'civicrm_email',
- ],
- 'CRM_Core_DAO_EntityFile' => [
- 'name' => 'EntityFile',
- 'class' => 'CRM_Core_DAO_EntityFile',
- 'table' => 'civicrm_entity_file',
- ],
- 'CRM_Core_DAO_IM' => [
+ ) ,
+ 'CRM_Core_DAO_File' => array(
+ 'name' => 'File',
+ 'class' => 'CRM_Core_DAO_File',
+ 'table' => 'civicrm_file',
+ ) ,
+ 'CRM_Core_DAO_IM' => array(
'name' => 'IM',
'class' => 'CRM_Core_DAO_IM',
'table' => 'civicrm_im',
'name' => 'Discount',
'class' => 'CRM_Core_DAO_Discount',
'table' => 'civicrm_discount',
- ],
- 'CRM_Core_DAO_EntityTag' => [
+ ) ,
+ 'CRM_Core_DAO_EntityFile' => array(
+ 'name' => 'EntityFile',
+ 'class' => 'CRM_Core_DAO_EntityFile',
+ 'table' => 'civicrm_entity_file',
+ ) ,
+ 'CRM_Core_DAO_EntityTag' => array(
'name' => 'EntityTag',
'class' => 'CRM_Core_DAO_EntityTag',
'table' => 'civicrm_entity_tag',
*
* Generated from xml/schema/CRM/Core/File.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:996b2702471b24fb13c740ef104ea1f9)
+ * (GenCodeChecksum:c0230af2b9234e9f83dca829a0490cf3)
*/
/**
*/
public $upload_date;
+ /**
+ * FK to civicrm_contact, who uploaded this file
+ *
+ * @var int unsigned
+ */
+ public $created_id;
/**
* Class constructor.
*/
parent::__construct();
}
+ /**
+ * Returns foreign keys and entity references.
+ *
+ * @return array
+ * [CRM_Core_Reference_Interface]
+ */
+ static function getReferenceColumns() {
+ if (!isset(Civi::$statics[__CLASS__]['links'])) {
+ Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+ Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
+ CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
+ }
+ return Civi::$statics[__CLASS__]['links'];
+ }
/**
* Returns all the column names of this table
*
'bao' => 'CRM_Core_BAO_File',
'localizable' => 0,
],
+ 'created_id' => [
+ 'name' => 'created_id',
+ 'type' => CRM_Utils_Type::T_INT,
+ 'title' => ts('Created By Contact ID') ,
+ 'description' => 'FK to civicrm_contact, who uploaded this file',
+ 'table_name' => 'civicrm_file',
+ 'entity' => 'File',
+ 'bao' => 'CRM_Core_BAO_File',
+ 'FKClassName' => 'CRM_Contact_DAO_Contact',
+ ],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
$this->addTask('CRM-21733: Add status_override_end_date field to civicrm_membership table', 'addColumn', 'civicrm_membership', 'status_override_end_date',
"date DEFAULT NULL COMMENT 'The end date of membership status override if (Override until selected date) override type is selected.'");
+ $this->addTask('CRM-19948 - Add created_id column to civicrm_file', 'addFileCreatedIdColumn');
}
/*
$dataType = 'datetime';
}
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_mailing CHANGE created_date created_date {$dataType} NULL DEFAULT NULL COMMENT 'Date and time this mailing was created.'");
+
+ return TRUE;
+ }
+
+ public static function addFileCreatedIdColumn(CRM_Queue_TaskContext $ctx) {
+ self::addColumn($ctx, 'civicrm_file', 'created_id', "int unsigned COMMENT 'FK to civicrm_contact, who uploaded this file'");
+
+ $fileTable = 'civicrm_file';
+ $fkName = 'FK_civicrm_file_created_id';
+
+ CRM_Core_BAO_SchemaHandler::safeRemoveFK($fileTable, $fkName);
+
+ CRM_Core_DAO::executeQuery("
+ ALTER TABLE `{$fileTable}`
+ ADD CONSTRAINT `{$fkName}`
+ FOREIGN KEY (`created_id`)
+ REFERENCES `civicrm_contact`(`id`)
+ ON DELETE SET NULL
+ ON UPDATE CASCADE;
+ ");
+
return TRUE;
}
<comment>Date and time that this attachment was uploaded or written to server.</comment>
<add>1.5</add>
</field>
+ <field>
+ <name>created_id</name>
+ <type>int unsigned</type>
+ <title>Created By Contact ID</title>
+ <comment>FK to civicrm_contact, who uploaded this file</comment>
+ <add>4.7</add>
+ </field>
+ <foreignKey>
+ <name>created_id</name>
+ <table>civicrm_contact</table>
+ <key>id</key>
+ <add>4.7</add>
+ <onDelete>SET NULL</onDelete>
+ </foreignKey>
</table>