Initial import of animal_management module
This commit is contained in:
117
migrations/m260402_030000_medical_progress_field_values.php
Normal file
117
migrations/m260402_030000_medical_progress_field_values.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use humhub\components\Migration;
|
||||
|
||||
class m260402_030000_medical_progress_field_values extends Migration
|
||||
{
|
||||
public function safeUp()
|
||||
{
|
||||
$this->safeCreateTable('rescue_animal_medical_visit_field_value', [
|
||||
'id' => $this->primaryKey(),
|
||||
'medical_visit_id' => $this->integer()->notNull(),
|
||||
'field_definition_id' => $this->integer()->notNull(),
|
||||
'value_text' => $this->text()->null(),
|
||||
'value_json' => $this->text()->null(),
|
||||
'created_at' => $this->dateTime()->null(),
|
||||
'updated_at' => $this->dateTime()->null(),
|
||||
]);
|
||||
|
||||
$this->safeCreateIndex(
|
||||
'ux_rescue_medical_visit_field_value_unique',
|
||||
'rescue_animal_medical_visit_field_value',
|
||||
['medical_visit_id', 'field_definition_id'],
|
||||
true
|
||||
);
|
||||
$this->safeCreateIndex(
|
||||
'idx_rescue_medical_visit_field_value_visit',
|
||||
'rescue_animal_medical_visit_field_value',
|
||||
'medical_visit_id',
|
||||
false
|
||||
);
|
||||
$this->safeCreateIndex(
|
||||
'idx_rescue_medical_visit_field_value_definition',
|
||||
'rescue_animal_medical_visit_field_value',
|
||||
'field_definition_id',
|
||||
false
|
||||
);
|
||||
|
||||
$this->safeAddForeignKey(
|
||||
'fk_rescue_medical_visit_field_value_visit',
|
||||
'rescue_animal_medical_visit_field_value',
|
||||
'medical_visit_id',
|
||||
'rescue_animal_medical_visit',
|
||||
'id',
|
||||
'CASCADE',
|
||||
'CASCADE'
|
||||
);
|
||||
|
||||
if ($this->db->getSchema()->getTableSchema('rescue_field_definition', true) !== null) {
|
||||
$this->safeAddForeignKey(
|
||||
'fk_rescue_medical_visit_field_value_definition',
|
||||
'rescue_animal_medical_visit_field_value',
|
||||
'field_definition_id',
|
||||
'rescue_field_definition',
|
||||
'id',
|
||||
'CASCADE',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
$this->safeCreateTable('rescue_animal_progress_update_field_value', [
|
||||
'id' => $this->primaryKey(),
|
||||
'progress_update_id' => $this->integer()->notNull(),
|
||||
'field_definition_id' => $this->integer()->notNull(),
|
||||
'value_text' => $this->text()->null(),
|
||||
'value_json' => $this->text()->null(),
|
||||
'created_at' => $this->dateTime()->null(),
|
||||
'updated_at' => $this->dateTime()->null(),
|
||||
]);
|
||||
|
||||
$this->safeCreateIndex(
|
||||
'ux_rescue_progress_update_field_value_unique',
|
||||
'rescue_animal_progress_update_field_value',
|
||||
['progress_update_id', 'field_definition_id'],
|
||||
true
|
||||
);
|
||||
$this->safeCreateIndex(
|
||||
'idx_rescue_progress_update_field_value_update',
|
||||
'rescue_animal_progress_update_field_value',
|
||||
'progress_update_id',
|
||||
false
|
||||
);
|
||||
$this->safeCreateIndex(
|
||||
'idx_rescue_progress_update_field_value_definition',
|
||||
'rescue_animal_progress_update_field_value',
|
||||
'field_definition_id',
|
||||
false
|
||||
);
|
||||
|
||||
$this->safeAddForeignKey(
|
||||
'fk_rescue_progress_update_field_value_update',
|
||||
'rescue_animal_progress_update_field_value',
|
||||
'progress_update_id',
|
||||
'rescue_animal_progress_update',
|
||||
'id',
|
||||
'CASCADE',
|
||||
'CASCADE'
|
||||
);
|
||||
|
||||
if ($this->db->getSchema()->getTableSchema('rescue_field_definition', true) !== null) {
|
||||
$this->safeAddForeignKey(
|
||||
'fk_rescue_progress_update_field_value_definition',
|
||||
'rescue_animal_progress_update_field_value',
|
||||
'field_definition_id',
|
||||
'rescue_field_definition',
|
||||
'id',
|
||||
'CASCADE',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
$this->safeDropTable('rescue_animal_progress_update_field_value');
|
||||
$this->safeDropTable('rescue_animal_medical_visit_field_value');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user