53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateDoctorBookingsTable extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => false, // Match appointments.id
|
|
'auto_increment' => true,
|
|
],
|
|
'appointment_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => false, // Match appointments.id
|
|
],
|
|
'doctor_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => false, // Match doctors.id
|
|
],
|
|
'booking_date' => [
|
|
'type' => 'DATE',
|
|
],
|
|
'booking_time' => [
|
|
'type' => 'TIME',
|
|
],
|
|
'status' => [
|
|
'type' => 'ENUM',
|
|
'constraint' => ['assigned', 'completed', 'cancelled'],
|
|
'default' => 'assigned',
|
|
],
|
|
'created_at datetime default current_timestamp',
|
|
]);
|
|
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addKey(['doctor_id', 'booking_date', 'booking_time']);
|
|
$this->forge->addForeignKey('appointment_id', 'appointments', 'id', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('doctor_bookings');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('doctor_bookings');
|
|
}
|
|
}
|