25 lines
588 B
PHP
25 lines
588 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class PreventDuplicateAppointmentSlots extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$db = \Config\Database::connect();
|
|
|
|
$db->query(
|
|
'ALTER TABLE `appointments` ADD UNIQUE KEY `appointments_doctor_slot_unique` (`doctor_id`, `appointment_date`, `appointment_time`)'
|
|
);
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
$db = \Config\Database::connect();
|
|
|
|
$db->query('ALTER TABLE `appointments` DROP INDEX `appointments_doctor_slot_unique`');
|
|
}
|
|
}
|