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

59 lines
1.6 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateTaskChecklistsTable 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,
],
'title' => [
'type' => 'VARCHAR',
'constraint' => 255,
'null' => false,
],
'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->addKey('task_id');
$this->forge->addForeignKey('task_id', 'tasks', 'id', '', 'CASCADE');
$this->forge->createTable('task_checklists');
}
public function down()
{
$this->forge->dropTable('task_checklists');
}
}