doctor-appointment-system/app/Database/Migrations/2026-04-14-170000_DropActivityLogs.php
2026-04-14 18:42:34 +05:30

78 lines
2.2 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class DropActivityLogs extends Migration
{
public function up(): void
{
if ($this->db->tableExists('activity_logs')) {
$this->forge->dropTable('activity_logs', true);
}
}
public function down(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'user_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => true,
],
'user_role' => [
'type' => 'ENUM',
'constraint' => ['admin', 'doctor', 'patient', 'system'],
'null' => true,
],
'action' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'description' => [
'type' => 'TEXT',
'null' => true,
],
'target_type' => [
'type' => 'VARCHAR',
'constraint' => 50,
'null' => true,
],
'target_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => true,
],
'ip_address' => [
'type' => 'VARCHAR',
'constraint' => 45,
'null' => true,
],
'user_agent' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => false,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addKey('user_id');
$this->forge->addKey('action');
$this->forge->addKey('created_at');
$this->forge->createTable('activity_logs', true);
}
}