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

55 lines
1.4 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateTaskSubtasksTable 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,
],
'title' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'is_completed' => [
'type' => 'BOOLEAN',
'default' => false,
],
'order_index' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addForeignKey('task_id', 'tasks', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('task_subtasks');
}
public function down()
{
$this->forge->dropTable('task_subtasks');
}
}