32 lines
691 B
PHP
32 lines
691 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use App\Models\SpecializationModel;
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class SeedDefaultSpecializations extends Migration
|
|
{
|
|
|
|
public function up(): void
|
|
{
|
|
if (! $this->db->tableExists('specializations')) {
|
|
return;
|
|
}
|
|
|
|
$model = new SpecializationModel();
|
|
$model->ensureNamesExist(SpecializationModel::defaultNames());
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if (! $this->db->tableExists('specializations')) {
|
|
return;
|
|
}
|
|
|
|
$this->db->table('specializations')
|
|
->whereIn('name', SpecializationModel::defaultNames())
|
|
->delete();
|
|
}
|
|
}
|