bp/app/Database/Migrations/2026-02-08-120006_CreateTas...

70 lines
1.9 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateTaskAttachmentsTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'task_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => false,
],
'file_name' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => false,
],
'file_path' => [
'type' => 'VARCHAR',
'constraint' => 500,
'null' => false,
],
'file_size' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'file_type' => [
'type' => 'VARCHAR',
'constraint' => 100,
'default' => '',
],
'uploaded_by' => [
'type' => 'INT',
'constraint' => 11,
'null' => false,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addKey('task_id');
$this->forge->addForeignKey('task_id', 'tasks', 'id', '', 'CASCADE');
$this->forge->createTable('task_attachments');
}
public function down()
{
$this->forge->dropTable('task_attachments');
}
}