161 lines
8.4 KiB
PHP
161 lines
8.4 KiB
PHP
<?php
|
|
|
|
use humhub\components\Migration;
|
|
|
|
class m260402_050000_seed_requirement_default_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 = [
|
|
// Animal profile defaults from requirements
|
|
['animal_profile', 'dob', 'DOB', 'date', 0, 1, 'public', 112],
|
|
['animal_profile', 'age', 'Age', 'text', 0, 1, 'public', 113],
|
|
['animal_profile', 'previous_owner_user_id', 'Previous Owner User ID', 'number', 0, 1, 'internal', 114],
|
|
['animal_profile', 'previous_owner_name', 'Previous Owner Name', 'text', 0, 1, 'internal', 115],
|
|
['animal_profile', 'previous_owner_business_name', 'Previous Owner Business Name', 'text', 0, 1, 'internal', 116],
|
|
['animal_profile', 'previous_owner_street_address', 'Previous Owner Street Address', 'text', 0, 1, 'internal', 117],
|
|
['animal_profile', 'previous_owner_city', 'Previous Owner City', 'text', 0, 1, 'internal', 118],
|
|
['animal_profile', 'previous_owner_state', 'Previous Owner State', 'text', 0, 1, 'internal', 119],
|
|
['animal_profile', 'previous_owner_zip', 'Previous Owner Zip', 'text', 0, 1, 'internal', 120],
|
|
['animal_profile', 'previous_owner_cell_phone', 'Previous Owner Cell Phone', 'text', 0, 1, 'internal', 121],
|
|
['animal_profile', 'previous_owner_business_phone', 'Previous Owner Business Phone', 'text', 0, 1, 'internal', 122],
|
|
['animal_profile', 'previous_owner_email', 'Previous Owner Email', 'text', 0, 1, 'internal', 123],
|
|
['animal_profile', 'lineage', 'Lineage', 'textarea', 0, 1, 'public', 124],
|
|
['animal_profile', 'backstory', 'Backstory', 'textarea', 0, 1, 'public', 125],
|
|
['animal_profile', 'rescue', 'Rescue', 'text', 0, 1, 'internal', 126],
|
|
|
|
// Medical visit defaults from requirements
|
|
['animal_medical_visit', 'weight', 'Weight', 'text', 0, 1, 'internal', 210],
|
|
['animal_medical_visit', 'pulse', 'Pulse', 'text', 0, 1, 'internal', 211],
|
|
['animal_medical_visit', 'blood_pressure', 'Blood Pressure', 'text', 0, 1, 'internal', 212],
|
|
['animal_medical_visit', 'oxygen', 'Oxygen', 'text', 0, 1, 'internal', 213],
|
|
['animal_medical_visit', 'chronic_conditions', 'Chronic Conditions', 'textarea', 0, 1, 'internal', 214],
|
|
['animal_medical_visit', 'acute_conditions', 'Acute Conditions', 'textarea', 0, 1, 'internal', 215],
|
|
['animal_medical_visit', 'special_needs', 'Special Needs', 'textarea', 0, 1, 'internal', 216],
|
|
['animal_medical_visit', 'date_of_most_recent_medical_visit', 'Date of Most Recent Medical Visit', 'date', 0, 1, 'internal', 217],
|
|
|
|
['animal_medical_visit', 'physician_name', 'Physician Name', 'text', 0, 1, 'internal', 218],
|
|
['animal_medical_visit', 'physician_business_name', 'Physician Business Name', 'text', 0, 1, 'internal', 219],
|
|
['animal_medical_visit', 'physician_street_address', 'Physician Street Address', 'text', 0, 1, 'internal', 220],
|
|
['animal_medical_visit', 'physician_city', 'Physician City', 'text', 0, 1, 'internal', 221],
|
|
['animal_medical_visit', 'physician_state', 'Physician State', 'text', 0, 1, 'internal', 222],
|
|
['animal_medical_visit', 'physician_zip', 'Physician Zip', 'text', 0, 1, 'internal', 223],
|
|
['animal_medical_visit', 'physician_cell_phone', 'Physician Cell Phone', 'text', 0, 1, 'internal', 224],
|
|
['animal_medical_visit', 'physician_business_phone', 'Physician Business Phone', 'text', 0, 1, 'internal', 225],
|
|
['animal_medical_visit', 'physician_license_number', 'Physician License Number', 'text', 0, 1, 'internal', 226],
|
|
|
|
['animal_medical_visit', 'second_physician_name', 'Second Physician Name', 'text', 0, 1, 'internal', 227],
|
|
['animal_medical_visit', 'second_physician_business_name', 'Second Physician Business Name', 'text', 0, 1, 'internal', 228],
|
|
['animal_medical_visit', 'second_physician_street_address', 'Second Physician Street Address', 'text', 0, 1, 'internal', 229],
|
|
['animal_medical_visit', 'second_physician_city', 'Second Physician City', 'text', 0, 1, 'internal', 230],
|
|
['animal_medical_visit', 'second_physician_state', 'Second Physician State', 'text', 0, 1, 'internal', 231],
|
|
['animal_medical_visit', 'second_physician_zip', 'Second Physician Zip', 'text', 0, 1, 'internal', 232],
|
|
['animal_medical_visit', 'second_physician_cell_phone', 'Second Physician Cell Phone', 'text', 0, 1, 'internal', 233],
|
|
['animal_medical_visit', 'second_physician_business_phone', 'Second Physician Business Phone', 'text', 0, 1, 'internal', 234],
|
|
['animal_medical_visit', 'second_physician_license_number', 'Second Physician License Number', 'text', 0, 1, 'internal', 235],
|
|
|
|
['animal_medical_visit', 'previous_physicians', 'Previous Physician(s)', 'textarea', 0, 1, 'internal', 236],
|
|
|
|
// Progress defaults from requirements
|
|
['animal_progress_update', 'progress_notes', 'Notes', 'textarea', 0, 1, 'internal', 310],
|
|
['animal_progress_update', 'routine_updates', 'Updates', 'textarea', 0, 1, 'internal', 311],
|
|
['animal_progress_update', 'media_reference', 'Media', 'text', 0, 1, 'internal', 312],
|
|
];
|
|
|
|
foreach ($rows as $row) {
|
|
[$groupKey, $fieldKey, $label, $inputType, $required, $isActive, $visibility, $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' => $groupKey,
|
|
'field_key' => $fieldKey,
|
|
'label' => $label,
|
|
'input_type' => $inputType,
|
|
'required' => $required,
|
|
'is_core' => 0,
|
|
'is_active' => $isActive,
|
|
'visibility' => $visibility,
|
|
'options' => '{}',
|
|
'sort_order' => $sortOrder,
|
|
'created_at' => $createdAt,
|
|
'updated_at' => $createdAt,
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function safeDown()
|
|
{
|
|
if ($this->db->getSchema()->getTableSchema('rescue_field_definition', true) === null) {
|
|
return;
|
|
}
|
|
|
|
$fieldKeys = [
|
|
'dob',
|
|
'age',
|
|
'previous_owner_user_id',
|
|
'previous_owner_name',
|
|
'previous_owner_business_name',
|
|
'previous_owner_street_address',
|
|
'previous_owner_city',
|
|
'previous_owner_state',
|
|
'previous_owner_zip',
|
|
'previous_owner_cell_phone',
|
|
'previous_owner_business_phone',
|
|
'previous_owner_email',
|
|
'lineage',
|
|
'backstory',
|
|
'rescue',
|
|
'pulse',
|
|
'blood_pressure',
|
|
'oxygen',
|
|
'chronic_conditions',
|
|
'acute_conditions',
|
|
'special_needs',
|
|
'date_of_most_recent_medical_visit',
|
|
'physician_name',
|
|
'physician_business_name',
|
|
'physician_street_address',
|
|
'physician_city',
|
|
'physician_state',
|
|
'physician_zip',
|
|
'physician_cell_phone',
|
|
'physician_business_phone',
|
|
'physician_license_number',
|
|
'second_physician_name',
|
|
'second_physician_business_name',
|
|
'second_physician_street_address',
|
|
'second_physician_city',
|
|
'second_physician_state',
|
|
'second_physician_zip',
|
|
'second_physician_cell_phone',
|
|
'second_physician_business_phone',
|
|
'second_physician_license_number',
|
|
'previous_physicians',
|
|
'progress_notes',
|
|
'routine_updates',
|
|
'media_reference',
|
|
];
|
|
|
|
$this->delete('rescue_field_definition', [
|
|
'module_id' => 'animal_management',
|
|
'field_key' => $fieldKeys,
|
|
'is_core' => 0,
|
|
]);
|
|
}
|
|
}
|