Initial import of animal_management module
This commit is contained in:
55
migrations/m260403_120000_create_animal_gallery_link.php
Normal file
55
migrations/m260403_120000_create_animal_gallery_link.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use humhub\components\Migration;
|
||||
|
||||
class m260403_120000_create_animal_gallery_link extends Migration
|
||||
{
|
||||
public function safeUp()
|
||||
{
|
||||
if ($this->db->getSchema()->getTableSchema('rescue_animal_gallery_link', true) !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->safeCreateTable('rescue_animal_gallery_link', [
|
||||
'id' => $this->primaryKey(),
|
||||
'animal_id' => $this->integer()->notNull(),
|
||||
'gallery_id' => $this->integer()->notNull(),
|
||||
'contentcontainer_id' => $this->integer()->notNull(),
|
||||
'created_at' => $this->dateTime()->null(),
|
||||
'updated_at' => $this->dateTime()->null(),
|
||||
]);
|
||||
|
||||
$this->safeCreateIndex('idx_rescue_animal_gallery_link_animal', 'rescue_animal_gallery_link', 'animal_id', true);
|
||||
$this->safeCreateIndex('idx_rescue_animal_gallery_link_gallery', 'rescue_animal_gallery_link', 'gallery_id', true);
|
||||
$this->safeCreateIndex('idx_rescue_animal_gallery_link_container', 'rescue_animal_gallery_link', 'contentcontainer_id', false);
|
||||
|
||||
if ($this->db->getSchema()->getTableSchema('rescue_animal', true) !== null) {
|
||||
$this->safeAddForeignKey(
|
||||
'fk_rescue_animal_gallery_link_animal',
|
||||
'rescue_animal_gallery_link',
|
||||
'animal_id',
|
||||
'rescue_animal',
|
||||
'id',
|
||||
'CASCADE',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->db->getSchema()->getTableSchema('gallery_gallery', true) !== null) {
|
||||
$this->safeAddForeignKey(
|
||||
'fk_rescue_animal_gallery_link_gallery',
|
||||
'rescue_animal_gallery_link',
|
||||
'gallery_id',
|
||||
'gallery_gallery',
|
||||
'id',
|
||||
'CASCADE',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
$this->safeDropTable('rescue_animal_gallery_link');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user