Initial import of animal_management module
This commit is contained in:
61
migrations/m260402_040000_add_image_profile_fields.php
Normal file
61
migrations/m260402_040000_add_image_profile_fields.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use humhub\components\Migration;
|
||||
|
||||
class m260402_040000_add_image_profile_fields extends Migration
|
||||
{
|
||||
public function safeUp()
|
||||
{
|
||||
if ($this->db->getSchema()->getTableSchema('rescue_field_definition', true) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$createdAt = date('Y-m-d H:i:s');
|
||||
$rows = [
|
||||
['cover_image_url', 'Cover image URL', 230],
|
||||
['profile_image_url', 'Profile image URL', 240],
|
||||
];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
[$fieldKey, $label, $sortOrder] = $row;
|
||||
|
||||
$exists = (new \yii\db\Query())
|
||||
->from('rescue_field_definition')
|
||||
->where(['module_id' => 'animal_management', 'field_key' => $fieldKey])
|
||||
->exists($this->db);
|
||||
|
||||
if ($exists) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->insert('rescue_field_definition', [
|
||||
'module_id' => 'animal_management',
|
||||
'group_key' => 'animal_profile',
|
||||
'field_key' => $fieldKey,
|
||||
'label' => $label,
|
||||
'input_type' => 'text',
|
||||
'required' => 0,
|
||||
'is_core' => 0,
|
||||
'is_active' => 1,
|
||||
'visibility' => 'public',
|
||||
'options' => '{}',
|
||||
'sort_order' => $sortOrder,
|
||||
'created_at' => $createdAt,
|
||||
'updated_at' => $createdAt,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
if ($this->db->getSchema()->getTableSchema('rescue_field_definition', true) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->delete('rescue_field_definition', [
|
||||
'module_id' => 'animal_management',
|
||||
'field_key' => ['cover_image_url', 'profile_image_url'],
|
||||
'is_core' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user